You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by Hernan Silberman <hs...@pdi.com> on 2005/04/08 20:10:23 UTC

Serialization problem...

Hi everyone, I'm new to Axis and am trying to write a simple Axis cpp client.  
I've been able to write a client for a service that returns a single xsd:string 
instance, but I'm having trouble extending the example to have it return a 
"list" of strings.  In the WSDL for the service, this list is defined as the 
following comlexType:

<xsd:complexType name="levelList">
  <xsd:sequence>
   <xsd:element name="myLevels" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
  </xsd:sequence>
</xsd:complexType>

I'm building my cpp client stubs using the java code generator, WSDL2Ws.  It 
builds a nice set of cpp code which I can build and test with a client program:

int main()
{
    try {
      LevelsService* theService =
        new LevelsService("http://localhost:8080/nile/services/LevelsService");
      levelList* theLevelList = theService->getFxLevelsForShot("PROD","sq","scene");
      if( NULL==theLevelList )
      {
          cout << "theLevelList is null." << endl;
          return 1;
      }
    } catch(AxisException& e) {
//omitted
}

The problem I'm having is that theLevelList returned by the 
Axis-generated LevelsService stub is always Null.  I've written a client for 
this service in Java and Perl and they're properly deserializing the two 
hardcoded strings that the server currently responds with.

I'm using Axis 1.5 alpha.

Here's the SOAP request message that the cpp client sends:

<?xml version='1.0' encoding='utf-8' ?>
   <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <SOAP-ENV:Body>
         <ns1:getFxLevelsForShot xmlns:ns1="http://www.dreamworks.com/LevelService.wsdl">
            <projectShortName xsi:type="xsd:string">MAD</projectShortName>
            <ShotName xsi:type="xsd:string">sq100</ShotName>
            <SequenceName xsi:type="xsd:string">s1</SequenceName>
         </ns1:getFxLevelsForShot>
      </SOAP-ENV:Body>
   </SOAP-ENV:Envelope>

The server responds with this SOAP response, which looks right to me:

<?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>
         <ns1:getFxLevelsForShotResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.dreamworks.com/LevelService.wsdl">
            <theFxLevels href="#id0"/>
         </ns1:getFxLevelsForShotResponse>
         <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:levelList" 
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:ns2="http://www.dreamworks.com/LevelService.xsd">
            <myLevels xsi:type="xsd:string">Level 1</myLevels>
            <myLevels xsi:type="xsd:string">Level 2</myLevels>
         </multiRef>
      </soapenv:Body>
   </soapenv:Envelope>

Please let me know if you see my error.  I'm guessing it might be something 
nonstandard I'm doing in the WSDL, so here it is for good measure:

<?xml version="1.0"?>
<definitions
    name="LevelsService"
    targetNamespace="http://www.dreamworks.com/LevelService.wsdl"
    xmlns:tns="http://www.dreamworks.com/LevelService.wsdl"
    xmlns:typens="http://www.dreamworks.com/LevelService.xsd"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <!-- type defs -->
  <types>
      <xsd:schema targetNamespace="http://www.dreamworks.com/LevelService.xsd"
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema">

      <xsd:complexType name="levelList">
        <xsd:sequence>
            <xsd:element name="myLevels" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
      </xsd:complexType>
    </xsd:schema>
  </types>
  <!-- message declns -->
  <message name="getFxLevelsForShotRequest">
    <part name="projectShortName" type="xsd:string"/>
    <part name="SequenceName" type="xsd:string"/>
    <part name="ShotName" type="xsd:string"/>
  </message>

  <message name="getFxLevelsForShotResponse">
    <part name="theFxLevels" type="typens:levelList"/>
  </message>

  <!-- port type declns -->
  <portType name="LevelsService">
    <operation name="getFxLevelsForShot">
      <input message="tns:getFxLevelsForShotRequest"/>
      <output message="tns:getFxLevelsForShotResponse"/>
    </operation>
  </portType>

  <!-- binding declns -->
  <binding name="LevelsXMLServiceSOAPBinding" type="tns:LevelsService">
    <soap:binding style="rpc"
                  transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="getFxLevelsForShot">
      <soap:operation soapAction=""/>
      <input>
        <soap:body use="encoded"
                   namespace="http://www.dreamworks.com/LevelService.wsdl"
                   encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </input>
      <output>
        <soap:body use="encoded"
                   namespace="http://www.dreamworks.com/LevelService.wsdl"
                   encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
      </output>
    </operation>
  </binding>

  <!-- service decln -->
  <service name="LevelsXMLService">
    <port name="LevelsService" binding="tns:LevelsXMLServiceSOAPBinding">
      <soap:address location="http://localhost:8080/nile/services/LevelsService"/>
    </port>
  </service>

</definitions>

thanks for your help.
Hernan


Re: Serialization problem...

Posted by Hernan Silberman <hs...@pdi.com>.
Update:

I found a solution to this problem.  I used a soap array type instead of the 
schema I was using before.  The C++ code generated off of this new WSDL document 
is more compact because there's no custom type required, and works great.  Sorry 
for the list traffic.  For completeness, here's the new test program and WSDL:

int main()
{
    try {
      LevelsService* theService =
        new LevelsService("http://localhost:8080/nile/services/LevelsService");
      xsd__string_Array theLevelList = theService->getFxLevelsForShot("MAD","sq100","s1");
// etc

<?xml version="1.0"?>
                                                                                                                                                             
<definitions
    name="LevelsService"
    targetNamespace="http://www.dreamworks.com/LevelService.wsdl"
    xmlns:tns="http://www.dreamworks.com/LevelService.wsdl"
    xmlns:typens="http://www.dreamworks.com/LevelService.xsd"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
                                                                                                                                                             
  <!-- type defs -->
  <types>
    <xsd:schema targetNamespace="http://www.dreamworks.com/LevelService.xsd"
                xmlns:tns="http://www.dreamworks.com/LevelService.xsd"
                xmlns="http://www.w3.org/2001/XMLSchema">
      <complexType name="ArrayOfString">
        <complexContent>
          <restriction base="soapenc:Array">
            <attribute ref="soapenc:arrayType" wsdl:arrayType="string[]"/>
          </restriction>
        </complexContent>
      </complexType>
    </xsd:schema>
  </types>
                                                                                                                                                             
  <!-- message declns -->
  <message name="getFxLevelsForShotRequest">
    <part name="projectShortName" type="xsd:string"/>
    <part name="SequenceName" type="xsd:string"/>
    <part name="ShotName" type="xsd:string"/>
  </message>
                                                                                                                                                             
  <message name="getFxLevelsForShotResponse">
    <part name="theFxLevels"
          xmlns:ns1="http://www.dreamworks.com/LevelService.xsd"
          type="ns1:ArrayOfString"/>
  </message>
... the rest is unchanged.

thanks...
Hernan





On Fri, 8 Apr 2005, Hernan Silberman wrote:

> 
> Hi everyone, I'm new to Axis and am trying to write a simple Axis cpp client.  
> I've been able to write a client for a service that returns a single xsd:string 
> instance, but I'm having trouble extending the example to have it return a 
> "list" of strings.  In the WSDL for the service, this list is defined as the 
> following comlexType:
> 
> <xsd:complexType name="levelList">
>   <xsd:sequence>
>    <xsd:element name="myLevels" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
>   </xsd:sequence>
> </xsd:complexType>
> 
> I'm building my cpp client stubs using the java code generator, WSDL2Ws.  It 
> builds a nice set of cpp code which I can build and test with a client program:
> 
> int main()
> {
>     try {
>       LevelsService* theService =
>         new LevelsService("http://localhost:8080/nile/services/LevelsService");
>       levelList* theLevelList = theService->getFxLevelsForShot("PROD","sq","scene");
>       if( NULL==theLevelList )
>       {
>           cout << "theLevelList is null." << endl;
>           return 1;
>       }
>     } catch(AxisException& e) {
> //omitted
> }
> 
> The problem I'm having is that theLevelList returned by the 
> Axis-generated LevelsService stub is always Null.  I've written a client for 
> this service in Java and Perl and they're properly deserializing the two 
> hardcoded strings that the server currently responds with.
> 
> I'm using Axis 1.5 alpha.
> 
> Here's the SOAP request message that the cpp client sends:
> 
> <?xml version='1.0' encoding='utf-8' ?>
>    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>       <SOAP-ENV:Body>
>          <ns1:getFxLevelsForShot xmlns:ns1="http://www.dreamworks.com/LevelService.wsdl">
>             <projectShortName xsi:type="xsd:string">MAD</projectShortName>
>             <ShotName xsi:type="xsd:string">sq100</ShotName>
>             <SequenceName xsi:type="xsd:string">s1</SequenceName>
>          </ns1:getFxLevelsForShot>
>       </SOAP-ENV:Body>
>    </SOAP-ENV:Envelope>
> 
> The server responds with this SOAP response, which looks right to me:
> 
> <?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>
>          <ns1:getFxLevelsForShotResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.dreamworks.com/LevelService.wsdl">
>             <theFxLevels href="#id0"/>
>          </ns1:getFxLevelsForShotResponse>
>          <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:levelList" 
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
> xmlns:ns2="http://www.dreamworks.com/LevelService.xsd">
>             <myLevels xsi:type="xsd:string">Level 1</myLevels>
>             <myLevels xsi:type="xsd:string">Level 2</myLevels>
>          </multiRef>
>       </soapenv:Body>
>    </soapenv:Envelope>
> 
> Please let me know if you see my error.  I'm guessing it might be something 
> nonstandard I'm doing in the WSDL, so here it is for good measure:
> 
> <?xml version="1.0"?>
> <definitions
>     name="LevelsService"
>     targetNamespace="http://www.dreamworks.com/LevelService.wsdl"
>     xmlns:tns="http://www.dreamworks.com/LevelService.wsdl"
>     xmlns:typens="http://www.dreamworks.com/LevelService.xsd"
>     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>     xmlns="http://schemas.xmlsoap.org/wsdl/"
>     xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> 
>   <!-- type defs -->
>   <types>
>       <xsd:schema targetNamespace="http://www.dreamworks.com/LevelService.xsd"
>                   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> 
>       <xsd:complexType name="levelList">
>         <xsd:sequence>
>             <xsd:element name="myLevels" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
>         </xsd:sequence>
>       </xsd:complexType>
>     </xsd:schema>
>   </types>
>   <!-- message declns -->
>   <message name="getFxLevelsForShotRequest">
>     <part name="projectShortName" type="xsd:string"/>
>     <part name="SequenceName" type="xsd:string"/>
>     <part name="ShotName" type="xsd:string"/>
>   </message>
> 
>   <message name="getFxLevelsForShotResponse">
>     <part name="theFxLevels" type="typens:levelList"/>
>   </message>
> 
>   <!-- port type declns -->
>   <portType name="LevelsService">
>     <operation name="getFxLevelsForShot">
>       <input message="tns:getFxLevelsForShotRequest"/>
>       <output message="tns:getFxLevelsForShotResponse"/>
>     </operation>
>   </portType>
> 
>   <!-- binding declns -->
>   <binding name="LevelsXMLServiceSOAPBinding" type="tns:LevelsService">
>     <soap:binding style="rpc"
>                   transport="http://schemas.xmlsoap.org/soap/http"/>
>     <operation name="getFxLevelsForShot">
>       <soap:operation soapAction=""/>
>       <input>
>         <soap:body use="encoded"
>                    namespace="http://www.dreamworks.com/LevelService.wsdl"
>                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
>       </input>
>       <output>
>         <soap:body use="encoded"
>                    namespace="http://www.dreamworks.com/LevelService.wsdl"
>                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
>       </output>
>     </operation>
>   </binding>
> 
>   <!-- service decln -->
>   <service name="LevelsXMLService">
>     <port name="LevelsService" binding="tns:LevelsXMLServiceSOAPBinding">
>       <soap:address location="http://localhost:8080/nile/services/LevelsService"/>
>     </port>
>   </service>
> 
> </definitions>
> 
> thanks for your help.
> Hernan
> 

-- 
Hernan Silberman
PDI/Dreamworks
ext.29162 / 650-562-9162 / cell 415-810-5809
text pager: page-hsilberm@anim.dreamworks.com