【发布时间】:2014-06-11 13:19:18
【问题描述】:
目前我们正在从 AS5 迁移到 AS6,现在一切正常,除了 SOAP 请求创建。 我知道 Jboss 6 正在使用“jbossws-cxf ...”库。 问题是现在我对 SOAP 请求感到奇怪:
ID: 6
Address: Some Address
Encoding: UTF-8
Content-Type: text/xml
Headers: {SOAPAction=["http://....."], Accept=[*/*]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetInfo xmlns="http://.....">
<ID>SomeId</ID><Username>SomeUN</Username><Password>SomePWD</Password></GetInfo></soap:Body></soap:Envelope>
--------------------------------------
2014-06-11 13:42:29,715 INFO [org.apache.cxf.interceptor.LoggingInInterceptor] (http-127.0.0.1-8080-5) Inbound Message
----------------------------
ID: 6
Response-Code: 500
Encoding: UTF-8
Content-Type: text/xml; charset=utf-8
Headers: {content-type=[text/xml; charset=utf-8], X-AspNet-Version=[2.0.50727], Date=[Wed, 11 Jun 2014 10:43:09 GMT],
Content-Length=[924], X-Powered-By=[ASP.NET], Server=[Microsoft-IIS/7.5], Cache-Control=[private]}
Payload: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode>
<faultstring>Invalid SOAP message due to XML Schema validation failure. The element 'GetInfo' in namespace 'http://...' has invalid child element 'ID' in namespace 'http://....'.
List of possible elements expected: 'Cred, Auth' in namespace 'http://....'.</faultstring><faultactor>http://....</faultactor><detail><exception code="00010222" xmlns="http://...." /></detail>
</soap:Fault></soap:Body></soap:Envelope>
2014-06-11 13:42:29,958 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web]. [localhost].[/HelloWorld].[resteasy-servlet]] (http-127.0.0.1-8080-5) Servlet.service()
for servlet resteasy-servlet threw exception: org.jboss.resteasy.spi.UnhandledException: javax.xml.ws.soap.SOAPFaultException: Invalid SOAP message due to XML Schema validation failure.
The element 'GetInfo' in namespace 'http://...' has invalid child element 'ID' in namespace 'http://....'. List of possible elements expected: 'Cred, Auth' in namespace 'http://...'.
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76) [:]
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212) [:]
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149) [:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372) [:]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) [:]
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) [:6.1.0.Final]
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) [:6.1.0.Final]
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) [:6.1.0.Final]
基本上出于某种原因,Jboss 6 删除了“Cred”包装节点,在 Jboss 5 上一切正常并且请求格式正确。
这是一个示例代码: .....
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"cred",
"auth"
})
@XmlRootElement(name = "GetInfo")
public class GetInfo {
@XmlElement(name = "Cred")
protected Cred cred;
@XmlElement(name = "Auth")
protected String auth;
....
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Cred", propOrder = {
"ID",
"username",
"password"
})
@XmlRootElement(name = "Cred")
public class Cred {
@XmlElement(name = "ID", required = true)
protected String ID;
@XmlElement(name = "Username", required = true)
protected String username;
@XmlElement(name = "Password", required = true)
protected String password;
....
@WebMethod(operationName = "GetInfo", action = "http://........")
@RequestWrapper(localName = "GetInfo", targetNamespace = "http://........", className = "com.test.GetInfo")
@ResponseWrapper(localName = "GetnfoResponse", targetNamespace = "http://......", className = "com.test.GetInfoResponse")
public void getInfo(
@WebParam(name = "Cred", targetNamespace = "http://.....")
Cred cred,
@WebParam(name = "Auth", targetNamespace = "http://.....", mode = WebParam.Mode.INOUT)
Holder<String> auth,
@WebParam(name = "AccInfo", targetNamespace = "http://.....", mode = WebParam.Mode.OUT)
Holder<AccountInfo> accInfo,
@WebParam(name = "Address", targetNamespace = "http://.....", mode = WebParam.Mode.OUT)
Holder<Address> address,
@WebParam(name = "Email", targetNamespace = ".....", mode = WebParam.Mode.OUT)
Holder<String> email);
谁能告诉我 Jboss 6 cxf 迁移有什么问题?
附:如果您在从 Jboss 5 迁移到 Jboss 6 时遇到问题,欢迎来问我
谢谢。
【问题讨论】:
标签: java web-services soap jboss cxf