You have a lot of information in this mail. I think I could not follow it all.

If I understood correctly then you took a wsdl from a .Net service, called it 
with a dynamic client and the xml it produced was wrong.
That can have many reasons. In general if you want good interoperability you 
should go wsdl first. This means you create a wsdl, make sure it is correct and 
then generate
Java and .net code from it. A good wa to check the wsdl is to check if it 
conforms to the WS-I basic profile.

Could you post the complete WSDL for the .Net service? I would like to test it 
myself. Have you also tried generating code in java instead of using the 
dynamic client?

Christian



-----Ursprüngliche Nachricht-----
Von: Frank Lawlor [mailto:[email protected]] 
Gesendet: Freitag, 3. Juni 2011 23:30
An: [email protected]
Betreff: CXF Bad XML

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.

Reply via email to