【问题标题】:Web service Unmarshalling response error in WebSphereWebSphere 中的 Web 服务 Unmarshalling 响应错误
【发布时间】:2014-11-12 16:15:41
【问题描述】:

我正在开发一个 Web 服务客户端消费者。

客户端类是使用 cxf wsdltojava 代码生成器生成的。

当我在 tomcat 中运行客户端时,一切正常,但是当我将客户端部署到 WebSphere 7.0,我收到解组器错误:

org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperException: An internal assertion  
     error occurred. The com.mycompany.webservice.model.LoginResponse JAXB object does not have a LoginResponse xml property.
at org.apache.axis2.jaxws.wrapper.impl.JAXBWrapperToolImpl.unWrap(JAXBWrapperToolImpl.java:83)
at org.apache.axis2.jaxws.marshaller.impl.alt.DocLitWrappedMethodMarshaller.demarshalResponse(DocLitWrappedMethodMarshaller.java:144)
... 16 more

wsdl 是这样的:

<xsd:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
...
<xsd:element name="LoginResponse">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element minOccurs="1" maxOccurs="1" name="LoginResult" type="xsd:boolean"/>
            <xsd:element minOccurs="0" maxOccurs="1" name="ticketID" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>

实体响应类是:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"loginResult",
"ticketID"
})
@XmlRootElement(name = "LoginResponse")
public class LoginResponse {

@XmlElement(name = "LoginResult")
protected boolean loginResult;
protected String ticketID;

服务等级是:

@WebService(targetNamespace = "http://tempuri.org/", name = "AuthenticationSoap")
@XmlSeeAlso({ObjectFactory.class})
public interface AuthenticationSoap {

@RequestWrapper(localName = "Login", targetNamespace = "http://tempuri.org/", className = "com.mycompany.webservice.model.Login")
@WebMethod(operationName = "Login", action = "http://tempuri.org/Login")
@ResponseWrapper(localName = "LoginResponse", targetNamespace = "http://tempuri.org/", className = "com.mycompany.webservice.model.LoginResponse")
@WebResult(name = "LoginResponse", targetNamespace = "http://tempuri.org/")
public LoginResponse login(
    @WebParam(mode = WebParam.Mode.IN, name = "username", targetNamespace = "http://tempuri.org/")
    java.lang.String username,
    @WebParam(mode = WebParam.Mode.IN, name = "password", targetNamespace = "http://tempuri.org/")
    java.lang.String password,
    @WebParam(mode = WebParam.Mode.INOUT, name = "ticketID", targetNamespace = "http://tempuri.org/")
    javax.xml.ws.Holder<java.lang.String> ticketID,
    @WebParam(mode = WebParam.Mode.OUT, name = "LoginResult", targetNamespace = "http://tempuri.org/")
    javax.xml.ws.Holder<java.lang.Boolean> loginResult
);
}

有没有人知道我的定义中有什么问题?

真诚的。

【问题讨论】:

    标签: websphere jax-ws


    【解决方案1】:

    问题在于 wsdl2java 没有将属性“endpointInterface”添加到您的 @WebService 注释中。您需要确保您的 WSDL 包含 wsdl:portType。

    IBM 有一篇很棒的文章解释了 WSDL 到 Java 的映射:

    http://publib.boulder.ibm.com/infocenter/wsdoc400/v6r0/index.jsp?topic=/com.ibm.websphere.iseries.doc/info/ae/ae/rwbs_map.html

    【讨论】:

    • 感谢您的回复,但问题不在于那个。我的 wsdl 文件中有 portType。调用 Web 服务并返回成功响应。但在解组响应中,我面临着问题。我跟踪它,发现在tomcat中,mule CxfMessageDispatcher类使用JaxWsClientProxy作为代理类,但在WebSphere中,它使用JaxWsProxyHandler作为代理类。我最后将项目的类加载属性更改为父级,还通过在项目的清单文件中放置标志“DisableIBMJAXWSEngine:true”来禁用 WebSphere Web Service,但没有任何改变。真诚的。
    • 我明白了。我推荐的原因是我见过其他人遇到同样的问题,这是因为 webservice 注释上的 endpointInterface 属性丢失了。解组后,它无法确定类型。为了理智起见,您可以尝试手动将 endpointInterface 属性添加到您的 Web 服务注释中吗?
    【解决方案2】:

    我建议您检查您的 .wsdl 是否有 complexType,如 complexType name="LoginResponse"。如果不是,您可能想尝试添加 complexType name="LoginResponse"... 我推荐的第二件事是你可以切换你的 websphere 运行模式。如果您以开发模式运行,请取消单击该框,或者如果您在没有开发模式的情况下运行它,请检查该框并重试。我认为这是一个缺陷。一旦您可能想要升级您的 websphere,可能会使用修复包。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多