Basic WebService setup failing (wsconsume 4.2.2 vs 5.1.0 - g
jpebe001 Nov 23, 2009 5:32 AMHi there @ JBoss web,
Disclaimer: I do not think the following is a bug (because this is pretty basic functionality) but I cannot see what, for the life of us, we are doing wrong or unconventional.
We are using a basic example and we have the following setups
A: JBoss 5.1.0 with CXF WS Stack 3.2.1
B: JBoss 4.2.2 with CXF WS Stack 3.0.2
For both A and B we have the SAME WSDL file (reproduced for completeness hereunder - note that this is automatically generated through the same server class annotation).
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions name="testApiService" targetNamespace="http://server.ws.ixaris.com" xmlns:ns1="http://schemas.xmlsoap.org/wsdl/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://server.ws.ixaris.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <wsdl:types> <xs:schema elementFormDefault="unqualified" targetNamespace="http://server.ws.ixaris.com" version="1.0" xmlns:tns="http://server.ws.ixaris.com" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="apiCaller" type="tns:apiCaller"/> <xs:element name="apiCallerResponse" type="tns:apiCallerResponse"/> <xs:complexType name="apiCaller"> <xs:sequence> <xs:element form="qualified" minOccurs="0" name="arg0" type="tns:testpayment"/> </xs:sequence> </xs:complexType> <xs:complexType name="testpayment"> <xs:sequence> <xs:element name="paymentId" type="xs:string"/> <xs:element name="userId" type="xs:string"/> <xs:element name="amount" type="xs:double"/> <xs:element name="currency" type="xs:string"/> <xs:element name="date" type="xs:dateTime"/> </xs:sequence> </xs:complexType> <xs:complexType name="apiCallerResponse"> <xs:sequence> <xs:element form="qualified" minOccurs="0" name="testApiCallerResult" type="tns:testpaymentconfirmation"/> </xs:sequence> </xs:complexType> <xs:complexType name="testpaymentconfirmation"> <xs:sequence> <xs:element name="statusCode" type="xs:int"/> <xs:element minOccurs="0" name="statusMessage" type="xs:string"/> <xs:element minOccurs="0" name="paymentObject" type="tns:testpayment"/> </xs:sequence> </xs:complexType> </xs:schema> </wsdl:types> <wsdl:message name="apiCaller"> <wsdl:part element="tns:apiCaller" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="apiCallerResponse"> <wsdl:part element="tns:apiCallerResponse" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:portType name="testApiService"> <wsdl:operation name="apiCaller"> <wsdl:input message="tns:apiCaller" name="apiCaller"> </wsdl:input> <wsdl:output message="tns:apiCallerResponse" name="apiCallerResponse"> </wsdl:output> </wsdl:operation> </wsdl:portType> <wsdl:binding name="testApiServiceSoapBinding" type="tns:testApiService"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="apiCaller"> <soap:operation soapAction="" style="document"/> <wsdl:input name="apiCaller"> <soap:body use="literal"/> </wsdl:input> <wsdl:output name="apiCallerResponse"> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="testApiService"> <wsdl:port binding="tns:testApiServiceSoapBinding" name="testapiport"> <soap:address location="http://127.0.0.1:8080/testapiwebservice/testapiservice"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
Using the wsconsume tool in the JBoss BIN folder, this WSDL file generates different clients for setups A and B (described above). The main and (possibly only) interesting difference in the service interface is the following:
In A: JBoss 5.1.0 with CXF WS Stack 3.2.1: (class finally generated by Apache CXF 2.2.4)
@WebResult(name = "testApiCallerResult", targetNamespace = "") @.. //other annotations identical! public com.ixaris.ws.server.Testpaymentconfirmation apiCaller( @WebParam(name = "arg0", targetNamespace = "http://server.ws.ixaris.com") com.ixaris.ws.server.Testpayment arg0 );
In B: JBoss 4.2.2 with CXF WS Stack 3.0.2: (class finally generated by JAX-WS RI 2.1.1-b03)
@WebResult(name = "testApiCallerResult", targetNamespace = "http://server.ws.ixaris.com") @.. //other annotations identical! public Testpaymentconfirmation apiCaller( @WebParam(name = "arg0", targetNamespace = "http://server.ws.ixaris.com") Testpayment arg0);
As you can see the client generated by the wsconsume tool in setup A does not have a namespace and generates the following exception:
Exception in thread "main" javax.xml.ws.WebServiceException: class com.ixaris.ws.client.endpoints.ApiCallerResponse do not have a property of the name testApiCallerResult at com.sun.xml.internal.ws.client.sei.ResponseBuilder$DocLit.<init>(ResponseBuilder.java:486) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.<init>(SyncMethodHandler.java:171) at com.sun.xml.internal.ws.client.sei.SEIStub.<init>(SEIStub.java:67) at com.sun.xml.internal.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:544) at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:292) at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:274) at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:267) at javax.xml.ws.Service.getPort(Service.java:92) at com.ixaris.ws.client.endpoints.TestApiService_Service.getTestapiport(TestApiService_Service.java:62) at com.ixaris.ws.client.testapiclient.testApiClientProcess(testapiclient.java:31) at com.ixaris.ws.client.testapiclient.main(testapiclient.java:84) Caused by: javax.xml.bind.JAXBException: testApiCallerResult is not a valid property on class com.ixaris.ws.client.endpoints.ApiCallerResponse at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getElementPropertyAccessor(JAXBContextImpl.java:910) at com.sun.xml.internal.ws.client.sei.ResponseBuilder$DocLit.<init>(ResponseBuilder.java:475) ... 10 more
Note that if I add this
targetNamespace = "http://server.ws.ixaris.com"
to the Jboss 5.1.0 and CXF 3.2.1 (setup A) WebResult annotation on the interface, everything works fine.
Note: I am running BOTH war files on JBoss 5.1.0 with CXF stack 3.2.1
Any ideas why this is happening ?
Many Thanks
JP