You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by shantanu chawla <sh...@gmail.com> on 2005/05/07 00:41:24 UTC

Unable to retrieve complex type in .net client

On my course of learning of  webservices on Axis. I created a complex
type Person containing age and name attributes.
I tried to create another complextype PersonsContainer which contains
a Person array and count. My wsdl has two functions getPerson()
returning Person and getPersons() returning PersonsContainer.

I uses wsdl2java to generate the server and client java codes. and I
deploy the service on Axis  1.2RC3. The java client works fine with
the service but when I try to access the service with .net client I am
able to receive the person with getPerson() but I am unable to get
PersonsContainer using getPersons(). When looking at the soap
responses. It seems the getPersons() is getting getPerson() function
kinda weird.

My wsdl is :

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="PersonTest"
targetNamespace="http://shantanu.org/PersonTest/"
xmlns:tns="http://shantanu.org/PersonTest/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
  <wsdl:types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://shantanu.org/PersonTest/">
      <xsd:element name="NewOperationResponse" type="xsd:string"/>
      <xsd:element name="NewOperationRequest" type="xsd:string"/>
      <xsd:complexType name="Person">
      	<xsd:sequence>
      		<xsd:element name="name" type="xsd:string"></xsd:element>
      		<xsd:element name="age" type="xsd:int"></xsd:element>
      	</xsd:sequence>
      </xsd:complexType>

      <xsd:element name="getPersonResponse" type="tns:Person"></xsd:element>
      <xsd:element name="getPersonRequest" type="xsd:string"></xsd:element>
      <xsd:complexType name="PersonsContainer">
      	<xsd:sequence>
      		<xsd:element name="count" type="xsd:int"></xsd:element>
      		<xsd:element name="persons" type="tns:Person" minOccurs="0"
maxOccurs="unbounded" nillable="true"></xsd:element>
      	</xsd:sequence>
      </xsd:complexType>

      <xsd:element name="getPersonsResponse"
      	type="tns:PersonsContainer">
      </xsd:element>
      <xsd:element name="getPersonsRequest" type="xsd:string"></xsd:element>
        </xsd:schema>
  </wsdl:types>
  <wsdl:message name="NewOperationResponse">
    <wsdl:part name="NewOperationResponse" element="tns:NewOperationResponse"/>
  </wsdl:message>
  <wsdl:message name="NewOperationRequest">
    <wsdl:part name="NewOperationRequest" element="tns:NewOperationRequest"/>
  </wsdl:message>
  <wsdl:message name="getPersonResponse">
  	<wsdl:part name="getPersonResponse"
  		element="tns:getPersonResponse">
  	</wsdl:part>
  </wsdl:message>
  <wsdl:message name="getPersonRequest">
  </wsdl:message>
  <wsdl:message name="getPersonsResponse">
  	<wsdl:part name="getPersonsResponse"
  		element="tns:getPersonsResponse">
  	</wsdl:part>
  </wsdl:message>
  <wsdl:message name="getPersonsRequest">
  </wsdl:message>
  <wsdl:portType name="PersonTest">
    <wsdl:operation name="NewOperation">
      <wsdl:input message="tns:NewOperationRequest"/>
      <wsdl:output message="tns:NewOperationResponse"/>
    </wsdl:operation>
    <wsdl:operation name="getPerson">
    	<wsdl:input message="tns:getPersonRequest"></wsdl:input>
    	<wsdl:output message="tns:getPersonResponse"></wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getPersons">
    	<wsdl:input message="tns:getPersonsRequest"></wsdl:input>
    	<wsdl:output message="tns:getPersonsResponse"></wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="PersonTestSOAP" type="tns:PersonTest">
    <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="NewOperation">
      <soap:operation soapAction="http://shantanu.org/PersonTest/NewOperation"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getPerson">
    	<soap:operation
soapAction="http://localhost:9090/axis/services/PersonTestSOAP/getPerson"/>
    	<wsdl:input>
    		<soap:body use="literal"/>
    	</wsdl:input>
    	<wsdl:output>
    		<soap:body use="literal"/>
    	</wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getPersons">
    	<soap:operation
soapAction="http://localhost:9090/axis/services/PersonTestSOAP/getPersons"/>
    	<wsdl:input>
    		<soap:body use="literal"/>
    	</wsdl:input>
    	<wsdl:output>
    		<soap:body use="literal"/>
    	</wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="PersonTest">
    <wsdl:port name="PersonTestSOAP" binding="tns:PersonTestSOAP">
      <soap:address
location="http://localhost:9090/axis/services/PersonTestSOAP"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

The soap messages exchanged in the .net client with axis webservices is:

for getPerson():

POST /axis/services/PersonTestSOAP HTTP/1.1

VsDebuggerCausalityData: AAA

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client
Protocol 1.1.4322.573)

Content-Type: text/xml; charset=utf-8

SOAPAction: "http://localhost:9090/axis/services/PersonTestSOAP/getPerson"

Content-Length: 236

Expect: 100-continue

Connection: Keep-Alive

Host: 127.0.0.1:9050

<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body
/></soap:Envelope>

Reply:

HTTP/1.1 100 Continue

HTTP/1.1 200 OK

Content-Type: text/xml;charset=utf-8

Transfer-Encoding: chunked

Date: Fri, 06 May 2005 22:08:16 GMT

Server: Apache-Coyote/1.1

19c

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><getPersonResponse
xmlns="http://shantanu.org/PersonTest/"><name xmlns="">Shantanu
Chawla</name><age
xmlns="">27</age></getPersonResponse></soapenv:Body></soapenv:Envelope>

0


for getPersons():

POST /axis/services/PersonTestSOAP HTTP/1.1

VsDebuggerCausalityData: AwAAAA

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client
Protocol 1.1.4322.573)

Content-Type: text/xml; charset=utf-8

SOAPAction: "http://localhost:9090/axis/services/PersonTestSOAP/getPersons"

Content-Length: 236

Expect: 100-continue

Connection: Keep-Alive

Host: 127.0.0.1:9050

<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body
/></soap:Envelope>
Reply:

HTTP/1.1 100 Continue

HTTP/1.1 200 OK

Content-Type: text/xml;charset=utf-8

Transfer-Encoding: chunked

Date: Fri, 06 May 2005 22:09:32 GMT

Server: Apache-Coyote/1.1

19c

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><getPersonResponse
xmlns="http://shantanu.org/PersonTest/"><name xmlns="">Shantanu
Chawla</name><age
xmlns="">27</age></getPersonResponse></soapenv:Body></soapenv:Envelope>

0

As you can see the getPersons() function reply is getPerson() reply.

Can someone provide any insight into it. I have tried it so many time
that I have run out of ideas.

Thanks 

Shantanu
-- 
Graduate Student 
Department of Computer Science,
San Diego State University

Re: Unable to retrieve complex type in .net client

Posted by shantanu chawla <sh...@gmail.com>.
On 5/6/05, Anne Thomas Manes <at...@gmail.com> wrote:
> The problem is caused by the fact that you don't provide unique
> signatures to differentiate the two methods, therefore .NET sends the
> same message (an empty <soap:Body/>) for both methods, and Axis always
> invokes the first method. (I'm unclear why it works with the Axis
> client, because it also should send identical messages.)

what you mean by  I dont provide unique signatures to differentiate
the two methods. getPerson() and getPersons() are different methods
with different in the method name. they are not the overloaded
methods.

-- 
Graduate Student 
Department of Computer Science,
San Diego State University

Re: Unable to retrieve complex type in .net client

Posted by Anne Thomas Manes <at...@gmail.com>.
The problem is caused by the fact that you don't provide unique
signatures to differentiate the two methods, therefore .NET sends the
same message (an empty <soap:Body/>) for both methods, and Axis always
invokes the first method. (I'm unclear why it works with the Axis
client, because it also should send identical messages.)

I've take the liberty of fixing your WSDL so that it supports the
"wrapped" style, which should fix your problem. I didn't fix your
first method, only the getPerson and getPersons methods.

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="PersonTest"
targetNamespace="http://shantanu.org/PersonTest/"
xmlns:tns="http://shantanu.org/PersonTest/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
 <wsdl:types>
   <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://shantanu.org/PersonTest/">
     <xsd:element name="NewOperationResponse" type="xsd:string"/>
     <xsd:element name="NewOperationRequest" type="xsd:string"/>

     <!-- ATM: request wrapper elements created/modified to provide unique 
          signatures for getPerson and getPersons operations. 
          Both wrapper elements are defined to be type tns:Void -->

     <xsd:element name="getPerson" type="tns:Void"/>
     <xsd:element name="getPersons" type="tns:Void"/>

     <!-- ATM: response wrapper elements (unchanged) -->

     <xsd:element name="getPersonResponse" type="tns:Person"/>
     <xsd:element name="getPersonsResponse" type="tns:PersonsContainer"/>

     <!-- ATM: types used by request and response wrapper elements -->

     <xsd:complexType name="Person">
       <xsd:sequence>
               <xsd:element name="name" type="xsd:string"></xsd:element>
               <xsd:element name="age" type="xsd:int"></xsd:element>
       </xsd:sequence>
     </xsd:complexType>

     <xsd:complexType name="PersonsContainer">
       <xsd:sequence>
          <xsd:element name="count" type="xsd:int"></xsd:element>
            <!-- ATM: changed name from "persons" to "person" 
            (assuming you want each person element to be named "person") 
            and removed nillable="true" (better to return empty
element than nil element) -->
          <xsd:element name="person" type="tns:Person" minOccurs="0"
            maxOccurs="unbounded"></xsd:element>
       </xsd:sequence>
     </xsd:complexType>

     <!-- ATM added Void type to be used as input to getPerson and
getPersons operations -->
     <xsd:complexType name="Void">
       <xsd:sequence/>
     </xsd:complexType>

   </xsd:schema>
 </wsdl:types>

      <!-- ATM: changed names of message parts to "parameters" to
follow "wrapped" convention -->

 <wsdl:message name="NewOperationResponse">
   <wsdl:part name="parameters" element="tns:NewOperationResponse"/>
 </wsdl:message>
 <wsdl:message name="NewOperationRequest">
   <wsdl:part name="parameters" element="tns:NewOperationRequest"/>
 </wsdl:message>

 <wsdl:message name="getPersonResponse">
       <wsdl:part name="parameters" element="tns:getPersonResponse"/>
 </wsdl:message>
 <wsdl:message name="getPersonRequest">
       <wsdl:part name="parameters" element="tns:getPerson"/>
 </wsdl:message>

 <wsdl:message name="getPersonsResponse">
       <wsdl:part name="parameters" element="tns:getPersonsResponse"/>
 </wsdl:message>
 <wsdl:message name="getPersonsRequest">
       <wsdl:part name="parameters" element="tns:getPersons"/>
 </wsdl:message>

 <wsdl:portType name="PersonTest">
   <wsdl:operation name="NewOperation">
     <wsdl:input message="tns:NewOperationRequest"/>
     <wsdl:output message="tns:NewOperationResponse"/>
   </wsdl:operation>
   <wsdl:operation name="getPerson">
       <wsdl:input message="tns:getPersonRequest"></wsdl:input>
       <wsdl:output message="tns:getPersonResponse"></wsdl:output>
   </wsdl:operation>
   <wsdl:operation name="getPersons">
       <wsdl:input message="tns:getPersonsRequest"></wsdl:input>
       <wsdl:output message="tns:getPersonsResponse"></wsdl:output>
   </wsdl:operation>
 </wsdl:portType>
 <wsdl:binding name="PersonTestSOAP" type="tns:PersonTest">
   <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
   <wsdl:operation name="NewOperation">
     <soap:operation soapAction="http://shantanu.org/PersonTest/NewOperation"/>
     <wsdl:input>
       <soap:body use="literal"/>
     </wsdl:input>
     <wsdl:output>
       <soap:body use="literal"/>
     </wsdl:output>
   </wsdl:operation>
   <wsdl:operation name="getPerson">
       <soap:operation
soapAction="http://localhost:9090/axis/services/PersonTestSOAP/getPerson"/>
       <wsdl:input>
               <soap:body use="literal"/>
       </wsdl:input>
       <wsdl:output>
               <soap:body use="literal"/>
       </wsdl:output>
   </wsdl:operation>
   <wsdl:operation name="getPersons">
       <soap:operation
soapAction="http://localhost:9090/axis/services/PersonTestSOAP/getPersons"/>
       <wsdl:input>
               <soap:body use="literal"/>
       </wsdl:input>
       <wsdl:output>
               <soap:body use="literal"/>
       </wsdl:output>
   </wsdl:operation>
 </wsdl:binding>
 <wsdl:service name="PersonTest">
   <wsdl:port name="PersonTestSOAP" binding="tns:PersonTestSOAP">
     <soap:address
location="http://localhost:9090/axis/services/PersonTestSOAP"/>
   </wsdl:port>
 </wsdl:service>
</wsdl:definitions>

Regards,
Anne

On 5/6/05, James Black <jb...@ieee.org> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> shantanu chawla wrote:
> > As you can see the getPersons() function reply is getPerson() reply.
> >
> > Can someone provide any insight into it. I have tried it so many time
> > that I have run out of ideas.
> 
>   One solution, which I haven't used, is to modify the wsdl file by
> hand. If you look at some of the archives you will find references about
> that.
> 
>   What I do is convert my array of beans into an xml file, and pass it
> as a string, and just convert the xml file back into an array of beans
> on the .net side.  C# has a wonderful way to handle xml files.
> 
>   There are known interop issues between java and .net, and I hope that
> at some point it is fixed.
> 
> - --
> Corruptisima republica plurimae leges. [The more corrupt a republic, the
> more laws.]
> Tacitus from Annals III, 116AD
> Blogs: http://jamesruminations.blogspot.com
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.0 (MingW32)
> 
> iD8DBQFCe/S+J/zyYkX46joRAiINAJ9bie/Zvy7eUJoNLECZh8BjWmd1CQCgi1Nm
> dAavAFhIgSM4qqUcM3WmFbE=
> =HO5Z
> -----END PGP SIGNATURE-----
>

Re: Unable to retrieve complex type in .net client

Posted by James Black <jb...@ieee.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

shantanu chawla wrote:
> As you can see the getPersons() function reply is getPerson() reply.
> 
> Can someone provide any insight into it. I have tried it so many time
> that I have run out of ideas.

  One solution, which I haven't used, is to modify the wsdl file by
hand. If you look at some of the archives you will find references about
that.

  What I do is convert my array of beans into an xml file, and pass it
as a string, and just convert the xml file back into an array of beans
on the .net side.  C# has a wonderful way to handle xml files.

  There are known interop issues between java and .net, and I hope that
at some point it is fixed.

- --
Corruptisima republica plurimae leges. [The more corrupt a republic, the
more laws.]
Tacitus from Annals III, 116AD
Blogs: http://jamesruminations.blogspot.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFCe/S+J/zyYkX46joRAiINAJ9bie/Zvy7eUJoNLECZh8BjWmd1CQCgi1Nm
dAavAFhIgSM4qqUcM3WmFbE=
=HO5Z
-----END PGP SIGNATURE-----