- This topic has 1 reply, 2 voices, and was last updated 16 years, 9 months ago by Riyad Kalla.
-
AuthorPosts
-
martintaliMemberI am trying to build a client to a third party web service and am running into problems with inherited complex types in separate namespaces. I have isolated a problem to a following.
Suppose you have WSDL that defines a operation F in namespace X that takes as an argument abstract type A. If in a same namespace you define a inherited type B and call F(B) the encoded SOAP request correctly encodes operation ‘f’ with complex type B. If however you define a complex type ‘C’ in separate namespace Y with import of , and call F(C) the resulting SOAP encoding will drop C from the final encoding or encode A instead.
I cannot change the web service definition in a server side though I can download and tweak the WSDL. Is there any workaround that would allow me to generate correct encoding for F(C)?
Here is a sample WSDL:
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="test" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="test" xmlns:wsx="test-xsd" xmlns:wsx2="test2-xsd" targetNamespace="test"> <wsdl:types> <xsd:schema targetNamespace="test-xsd"> <xsd:complexType name="Record" abstract="true" /> <xsd:element name="record" type="wsx:Record" /> <xsd:element name="realRecord1" type="wsx:RealRecord1" /> <xsd:complexType name="RealRecord1"> <xsd:complexContent> <xsd:extension base="wsx:Record"> <xsd:sequence> <xsd:element name="f1" type="xsd:string" /> <xsd:element name="f2" type="xsd:string" /> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> <xsd:element name="Operation"> <xsd:complexType> <xsd:sequence> <xsd:element name="in" type="wsx:Record" /> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="OperationResponse"> <xsd:complexType> <xsd:sequence> <xsd:element name="out" type="xsd:string" /> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> <xsd:schema targetNamespace="test2-xsd"> <xsd:import namespace="test-xsd"/> <xsd:element name="realRecord2" type="wsx2:RealRecord2" /> <xsd:complexType name="RealRecord2"> <xsd:complexContent> <xsd:extension base="wsx:Record"> <xsd:sequence> <xsd:element name="f3" type="xsd:string" /> <xsd:element name="f4" type="xsd:string" /> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> </xsd:schema> </wsdl:types> <wsdl:message name="OperationRequest"> <wsdl:part element="wsx:Operation" name="parameters" /> </wsdl:message> <wsdl:message name="OperationResponse"> <wsdl:part element="wsx:OperationResponse" name="parameters" /> </wsdl:message> <wsdl:portType name="test_v1"> <wsdl:operation name="Operation"> <wsdl:input message="tns:OperationRequest" /> <wsdl:output message="tns:OperationResponse" /> </wsdl:operation> </wsdl:portType> <wsdl:binding name="testSOAP" type="tns:test_v1"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="Operation"> <soap:operation soapAction="http://www.example.org/test/Operation" /> <wsdl:input> <soap:body use="literal" /> </wsdl:input> <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="test_v1"> <wsdl:port binding="tns:testSOAP" name="testSOAP"> <soap:address location="http://localhost:8080/ims/services/test" /> </wsdl:port> </wsdl:service> </wsdl:definitions>
Here is a snippet of java code:
test_v1Client client = new test_v1Client(); //create a default service endpoint test_v1 service = client.gettestSOAP(); // This works fine test_xsd.ObjectFactory of1 = new test_xsd.ObjectFactory(); test_xsd.RealRecord1 in1 = of1.createRealRecord1(); in1.setF1("test1"); in1.setF2("test2"); try { service.operation(in1); } catch (Exception e ) {} // This does not work test2_xsd.ObjectFactory of2 = new test2_xsd.ObjectFactory(); test2_xsd.RealRecord2 in2 = of2.createRealRecord2(); in2.setF3("test1"); in2.setF4("test2"); try { service.operation(in2); } catch (Exception e ) {}
Here is the correct request, where abstract and derived types are in same namespace:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <ns1:Operation xmlns:ns1="test"> <ns3:in xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="test" xmlns:ns2="test-xsd" xsi:type="ns2:RealRecord1"> <f1>test1</f1> <f2>test2</f2> </ns3:in> </ns1:Operation> </soap:Body> </soap:Envelope>
Here is the second incorrect request, where abstract and derived types are in different namespaces:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <ns1:Operation xmlns:ns1="test"> <ns3:in xmlns:ns3="test" xmlns:ns2="test-xsd" /> </ns1:Operation> </soap:Body> </soap:Envelope>
Intallation details:
*** Date:
Thursday, January 31, 2008 1:44:18 PM PST** System properties:
OS=WindowsXP
OS version=5.1
Java version=1.5.0_11*** MyEclipse details:
MyEclipse Enterprise Workbench
Version: 5.5.1 GA
Build id: 20070521-5.5.1-GA*** Eclipse details:
MyEclipse Enterprise WorkbenchVersion: 5.5.1 GA
Build id: 20070521-5.5.1-GAEclipse Platform
Version: 3.2.2.r322_v20070119-RQghndJN8IM0MsK
Build id: M20070212-1330Eclipse RCP
Version: 3.2.2.r322_v20070104-8pcviKVqd8J7C1U
Build id: M20070212-1330Eclipse Java Development Tools
Version: 3.2.2.r322_v20070104-R4CR0Znkvtfjv9-
Build id: M20070212-1330Eclipse Plug-in Development Environment
Version: 3.2.1.r321_v20060823-6vYLLdQ3Nk8DrFG
Build id: M20070212-1330Eclipse Project SDK
Version: 3.2.2.r322_v20070104-dCGKm0Ln38lm-8s
Build id: M20070212-1330Eclipse Graphical Editing Framework
Version: 3.2.2.v20070208
Build id: 20070208-1315Eclipse startup command=-os
win32
-ws
win32
-arch
x86
-launcher
C:\Program Files\MyEclipse 5.5.1 GA\eclipse\eclipse.exe
-name
Eclipse
-showsplash
600
-exitdata
f9c_78
-vm
C:\Program Files\MyEclipse 5.5.1
Riyad KallaMemberI’m sorry to say, but I have no idea.
-
AuthorPosts