This is due to different interpretations of the "unwrapping" rules.
CXF has generally taken a relatively strict interpretation which doesn't allow
element references when unwrapping operations. Thus, it wouldn't consider
your wsdl as unwrappable and you would need to pass an "Echo" object into the
"invoke" method, not a String. For the command line, there is an
"allowElementReferences" flag to wsdl2java to allow it, but there isn't
anything on the dynamic clients to allow it at this point.
I've just added a flag to the Dynamic client to be able to turn this on there
as well. This will be available in 2.4.1.
Dan
On Friday, June 03, 2011 5:29:56 PM Frank Lawlor wrote:
> client.invoke throws error: Type 'xs:string' is not validly derived from
> the type definition, 'echo', of element 'ns3:echo'.
>
>
>
> This is due to badly formed XML generated by CXF.
>
>
>
> The test code is a simple echo and the XML is derived by CXF using the
> WSDL.
>
> It works for a simple Java web service, but fails for a .NET one.
>
>
>
> The client code is basically:
>
>
>
> JaxWsDynamicClientFactory dcf =
> JaxWsDynamicClientFactory.newInstance();
>
> // build security header - only for .NET service
>
> Client client = dcf.createClient(-URL to the WSDL-);
>
> Object[] results = client.invoke("echo", "Hellooooo");
>
>
>
>
>
> The GOOD generated XML for the Java web service looks like:
>
>
>
> <SOAP-ENV:Body>
>
> <ns3:echo xmlns:ns2="http://com/netspend/ws/ski/types/"
> xmlns:ns3="http://neo3.netspend.com/">
>
> <arg0>Hellooooo</arg0>
>
> </ns3:echo>
>
> </SOAP-ENV:Body>
>
>
>
> The BAD xml for the .NET service is:
>
>
>
> <soap:Body>
>
> <ns3:echo xmlns:ns3="http://com/netspend/ws/ski/"
>
> xmlns:ns2="http://com/netspend/ws/ski/types/"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:type="xs:string">Hellooooo
>
> </ns3:echo>
>
> </soap:Body>
>
>
>
> You can see 1) that the end of the operation element (echo) and the
> argument element are squished together into one
>
> and 2) the string type element has an inappropriate "xs:" prefix in the
> quoted string.
>
>
>
> The CORRECT xml for the .NET service (from other clients) is:
>
>
>
> <soap:Body>
>
> <ns3:echo xmlns:ns3="http://com/netspend/ws/ski/"
> xmlns:ns2="http://com/netspend/ws/ski/types/">
>
> <ns2:echoText>Hellooooo</ns2:echoText>
>
> </ns3:echo>
>
> </soap:Body>
>
>
>
>
>
> The bad XML looks like it is using (see .NET WSDL below)
>
> <xs:element name="echoText" type="xs:string" />
>
> but is grabbing the type rather than the name.
>
>
>
>
>
> The (simplified) WSDL for the Java web service is:
>
>
>
> <definitions name="CardBeanService"
>
> targetNamespace="http://neo3.netspend.com/"
> xmlns="http://schemas.xmlsoap.org/wsdl/"
>
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:tns="http://neo3.netspend.com/"
>
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>
> <types>
>
> <xs:schema
> targetNamespace="http://neo3.netspend.com/"
>
> version="1.0"
> xmlns:tns="http://neo3.netspend.com/"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> ... nothing about echo ...
>
> </xs:schema>
>
> </types>
>
> <message name="Card_echoResponse">
>
> <part name="return" type="xsd:string" />
>
> </message>
>
> <message name="Card_echo">
>
> <part name="arg0" type="xsd:string" />
>
> </message>
>
> <portType name="Card">
>
> <operation name="echo"
> parameterOrder="arg0">
>
> <input
> message="tns:Card_echo" />
>
> <output
> message="tns:Card_echoResponse" />
>
> </operation>
>
> </portType>
>
> <binding name="CardBinding" type="tns:Card">
>
> <soap:binding style="rpc"
>
>
> transport="http://schemas.xmlsoap.org/soap/http" />
>
> <operation name="echo">
>
> <soap:operation
> soapAction="" />
>
> <input>
>
>
> <soap:body namespace="http://neo3.netspend.com/" use="literal" />
>
> </input>
>
> <output>
>
>
> <soap:body namespace="http://neo3.netspend.com/" use="literal" />
>
> </output>
>
> </operation>
>
> </binding>
>
> </definitions>
>
>
>
>
>
> The (simplified) WSDL for the .NET web service is:
>
>
>
> <?xml version="1.0" encoding="UTF-8" ?>
>
> <wsdl:definitions name="SkiWebService"
>
> targetNamespace="http://com/netspend/ws/ski/"
> xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
>
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:tns="http://com/netspend/ws/ski/"
>
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>
> <wsdl:types>
>
> <xs:schema
> attributeFormDefault="unqualified"
>
>
> elementFormDefault="unqualified"
> targetNamespace="http://com/netspend/ws/ski/types/"
>
>
> xmlns="http://com/netspend/ws/ski/types/"
> xmlns:ns1="http://com/netspend/ws/ski/"
>
>
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <xs:import
> namespace="http://com/netspend/ws/ski/" />
>
> <xs:element
> name="echoText" type="xs:string" />
>
> </xs:schema>
>
> <xs:schema
> attributeFormDefault="unqualified"
>
>
> elementFormDefault="unqualified"
> targetNamespace="http://com/netspend/ws/ski/"
>
>
> xmlns:ns1="http://com/netspend/ws/ski/types/"
> xmlns:tns="http://com/netspend/ws/ski/"
>
>
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <xs:import
> namespace="http://com/netspend/ws/ski/types/" />
>
> <xs:element name="echo"
> type="tns:echo" />
>
> <xs:element
> name="echoResponse" type="tns:echoResponse" />
>
> <xs:complexType
> name="echo">
>
>
> <xs:sequence>
>
>
> <xs:element minOccurs="0" ref="ns1:echoText" />
>
>
> </xs:sequence>
>
> </xs:complexType>
>
> <xs:complexType
> name="echoResponse">
>
>
> <xs:sequence>
>
>
> <xs:element minOccurs="0" name="return" type="xs:string" />
>
>
> </xs:sequence>
>
> </xs:complexType>
>
> <wsdl:message name="echo">
>
> <wsdl:part element="tns:echo"
> name="parameters" />
>
> </wsdl:message>
>
> <wsdl:message name="echoResponse">
>
> <wsdl:part element="tns:echoResponse"
> name="parameters" />
>
> </wsdl:message>
>
> <wsdl:portType name="SkiWebServicePortType">
>
> <wsdl:operation name="echo">
>
> <wsdl:input
> message="tns:echo" name="echo" />
>
> <wsdl:output
> message="tns:echoResponse" name="echoResponse" />
>
> <wsdl:fault
> message="tns:NetspendFault" name="NetspendFault" />
>
> </wsdl:operation>
>
> </wsdl:portType>
>
> <wsdl:binding name="SkiWebServiceSoapBinding"
> type="tns:SkiWebServicePortType">
>
> <wsdl:operation name="echo">
>
> <soap:operation
> soapAction="" style="document" />
>
> <wsdl:input name="echo">
>
>
> <soap:body use="literal" />
>
> </wsdl:input>
>
> <wsdl:output
> name="echoResponse">
>
>
> <soap:body use="literal" />
>
> </wsdl:output>
>
> <wsdl:fault
> name="NetspendFault">
>
>
> <soap:fault name="NetspendFault" use="literal" />
>
> </wsdl:fault>
>
> </wsdl:operation>
>
> </wsdl:binding>
>
> </wsdl:definitions>
>
>
>
>
>
>
>
>
>
> Frank Lawlor
>
>
>
> Confidentiality Notice! This electronic transmission and any attached
> documents or other writings are confidential and are for the sole use of
> the intended recipient(s) identified above. This message may contain
> information that is privileged, confidential or otherwise protected from
> disclosure under applicable law. If the receiver of this information is
> not the intended recipient, or the employee, or agent responsible for
> delivering the information to the intended recipient, you are hereby
> notified that any use, reading, dissemination, distribution, copying or
> storage of this information is strictly prohibited. If you have received
> this information in error, please notify the sender by return email and
> delete the electronic transmission, including all attachments from your
> system.
--
Daniel Kulp
[email protected]
http://dankulp.com/blog
Talend - http://www.talend.com