I have a WSDL-first web service that is using CXF 2.7.6, using Wrapped-style.
The getState web service interface method returns an int value. 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'. I say usually because the ClassCastException does not occur
every time I make the web service call. I also intermittently get a similar
ClassCastException on calls to other methods in the web service interface.
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 excerpts:<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:<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;
--
View this message in context:
http://cxf.547215.n5.nabble.com/ClassCastException-on-assignment-of-return-type-from-web-service-call-tp5757737.html
Sent from the cxf-user mailing list archive at Nabble.com.