简体   繁体   English

使用WS-Reliable Messaging时,在分配返回类型时会发生CXF Web服务ClassCastException

[英]CXF web service ClassCastException on assignment of return type when using WS-Reliable Messaging

I have a WSDL-first web service that is using CXF 2.7.6, using Wrapped-style. 我有一个使用CXF 2.7.6(使用包装样式)的WSDL优先Web服务。 The getState web service interface method returns an int value. getState Web服务接口方法返回一个int值。 However, when I call the web service from my CXF client code, I usually get a ClassCastException with the message 'can't cast a GetStateResponse object to an Integer'. 但是,当我从CXF客户端代码调用Web服务时,通常会收到ClassCastException,并显示消息“无法将GetStateResponse对象强制转换为Integer”。 I say usually because the ClassCastException does not occur every time I make the web service call. 我之所以这样说,通常是因为ClassCastException不会在每次进行Web服务调用时发生。 I also intermittently get a similar ClassCastException on calls to other methods in the web service interface. 我还间歇性地在调用Web服务接口中的其他方法时得到了类似的ClassCastException。 Interestingly, this exception only occurs with WS-Reliable Messaging configured. 有趣的是,此异常仅在配置了WS-Reliable Messaging的情况下发生。 We are deploying on a JBoss EAP 6 server but are using the CXF libraries directly (rather than using JBoss' built-in webservices subsystem) 我们正在JBoss EAP 6服务器上进行部署,但是直接使用CXF库(而不是使用JBoss的内置webservices子系统)

I'm able to work-around the issue by assigning the return value to an Object and then determining its type and handling it accordingly, but this is a definite hack and I'd like to find the root cause of the issue. 我可以通过将返回值分配给对象,然后确定其类型并进行相应处理来解决该问题,但这是一个明确的技巧,我想找到问题的根本原因。 Below are excerpts from the WSDL, schema and interface class. 以下是WSDL,架构和接口类的摘录。

WSDL excerpts: WSDL摘录:

<wsdl:definitions>
    <wsdl:message name="getState">
        <wsdl:part name="parameters" element="msgs:getState"/>
    </wsdl:message>

    <wsdl:portType>
        <wsdl:operation name="getState">
            <wsdl:input name="getState" message="tns:getState"/>
            <wsdl:output name="getStateResponse" message="tns:getStateResponse"/>
            <wsdl:fault name="SOAPFaultException" message="tns:SOAPFaultException"/>
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding>
        <wsdl:operation name="getState">
            <soap:operation soapAction="" style="document"/>
            <wsdl:input name="getState">
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output name="getStateResponse">
                <soap:body use="literal"/>
            </wsdl:output>
            <wsdl:fault name="SOAPFaultException">
                <soap:fault name="SOAPFaultException" use="literal"/>
            </wsdl:fault>
        </wsdl:operation>
    </wsdl:binding>
</wsdl:definitions>

SCHEMA referenced with 'msgs:' prefix above: 上面用'msgs:'前缀引用的SCHEMA:

<xs:element name="getState" type="tns:getState"/>

<xs:complexType name="getState">
    <xs:sequence>
        <xs:element minOccurs="0" name="param1" type="xs:string" />
        <xs:element minOccurs="0" name="param2" type="xs:string" />
    </xs:sequence>
</xs:complexType>

INTERFACE CLASS: 接口类:

@WebResult(name = "return", targetNamespace = "")
@RequestWrapper(localName = "getState", targetNamespace = "http://messages.space.my.name", className = "my.name.space.GetState")
@WebMethod
@ResponseWrapper(localName = "getStateResponse", targetNamespace = "http://messages.space.my.name", className = "my.name.space.GetStateResponse")
public int getState(
@WebParam(name = "param1", targetNamespace = "")
java.lang.String param1,
@WebParam(name = "param2", targetNamespace = "")
java.lang.String param2) throws SOAPFaultException;

Spring jaxws client configuration: Spring jaxws客户端配置:

<jaxws:client id="wsProxy" serviceClass="my.name.space.IWebServiceInterface">
    <jaxws:inInterceptors>
        <bean id="loggingInInterceptor" 
              class="org.apache.cxf.interceptor.LoggingInInterceptor" >
            <property name="prettyLogging" value="true" />
        </bean>
        <ref bean="rmLogicalIn"/>
        <ref bean="rmCodec"/>
    </jaxws:inInterceptors>
    <jaxws:outInterceptors>
        <bean id="loggingOutInterceptor" 
              class="org.apache.cxf.interceptor.LoggingOutInterceptor" >
            <property name="prettyLogging" value="true" />
        </bean>
        <ref bean="rmLogicalOut"/>
        <ref bean="rmCodec"/>
    </jaxws:outInterceptors>
</jaxws:client>

Stack trace: 堆栈跟踪:

[33m [0m [31m00:39:20,589 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/TEST_GUI].[jsp]] (ajp-/0.0.0.0:8009-9) JBWEB000236: 
Servlet.service() for servlet jsp threw exception: java.lang.ClassCastException: my.name.space.messages.GetStateResponse cannot be cast to java.lang.Integer [0m
[31m    at $Proxy139.getState(Unknown Source)   at org.apache.jsp.client.framework.MWS_005fTEST_jsp.waitForState(MWS_005fTEST_jsp.java:166) [0m
[31m    at org.apache.jsp.client.framework.MWS_005fTEST_jsp._jspService(MWS_005fTEST_jsp.java:508) [0m
[31m    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:69) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1] [0m
[31m    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:365) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:309) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:242) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1] [0m
[31m    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at mil.jpmis.cbrnis.client.framework.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:148) [TESTGUI.jar:] [0m
[31m    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.event(JBossWebContext.java:91) [0m
[31m    at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.invoke(JBossWebContext.java:72) [0m
[31m    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:512) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.4.3.Final-redhat-2.jar:7.4.3.Final-redhat-2] [0m
[31m    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:490) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:420) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.4.10.Final-redhat-1.jar:7.4.10.Final-redhat-1] [0m
[31m    at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0]

I also posted this on the cxf-users Nabble list, but no response yet. 我也将此发布在cxf-users Nabble列表上,但没有响应。 Any help would be appreciated! 任何帮助,将不胜感激!

更新,并在上面的评论中回复@gnzlrm,如果我没有记错(这是两年多以前的话),我们从未隔离出此问题的原因,但是我们确实发现当我们更新到更高版本的CXF时,我们没有不再看到此问题(我相信2.7.13及更高版本可以工作,但我们最终更新为3.1.7)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM