Loading ...
Sorry, an error occurred while loading the content.

Re: [soaplite] receiving complex types perl S::L

Expand Messages
  • Vinit Samel
    Hi Please find below the XML Request and Response. I think its something with the way the int array is deserialized - its taking int type as a key and hence
    Message 1 of 3 , Sep 18, 2005
    • 0 Attachment
      Hi

      Please find below the XML Request and Response. I
      think its something with the way the int array is
      deserialized - its taking 'int' type as a key and
      hence only the last key:value pair is returned.
      But I cant figure out where exactly I need to
      manipulate the code in the SOAP:: Deserializer . both
      decode_object and decode_value seem to work as
      expected returning int values and type for the whole
      int array.

      Let me know of what u think.
      Thanks,
      Vinit
      -----------


      <?xml version="1.0"
      encoding="UTF-8"?><SOAP-ENV:Envelope
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="h
      ttp://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><GetX
      xmlns="http://www.xxxx.com/xxxx/xxxx"/></SOAP-ENV:Body></SOAP-ENV:Envelope>


      <?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/XMLS
      chema"><soap:Body><GetXResponse
      xmlns="http://www.xxxx.com/xxxx/xxxx"><GetXResult><arr><int>0</int
      ><int>1</int><int>2</int><int>3</int><int>4</int><int>5</int><int>6</int><int>7</int><int>8</int><int>9</int></arr></GetXResult></GetXResponse></soap:Body></soap:Envelope>

      $VAR1 = {
      'arr' => {
      'int' => '9'
      }
      }

      --- Ted Zeng <zeng@...> wrote:

      > Someone probably will be able to help you.
      > But if you can attach the xml returned, it will be
      > easier
      > For people to help.
      >
      > Ted zeng
      >
      >
      >
      > On 9/16/05 4:07 PM, "vinit samel"
      > <vinitns@...> wrote:
      >
      > > Hello
      > >
      > > I have a Perl Client communicating with a .NET
      > > Webservice via Soap::Lite. I am having trouble
      > > receiving complex types from the service. Please
      > see
      > > the code-snippet
      > >
      > > .NET WebService
      > > [WebMethod]
      > > public X GetX()
      > > {
      > > return new X();
      > > }
      > > public class X
      > > {
      > > public int[] arr;
      > >
      > > public X()
      > > {
      > > arr = new int[10];
      > > for (int i = 0; i < arr.Length; ++i)
      > > arr[i] = i;
      > > }
      > > }
      > >
      > > Perl Client
      > > $name = "GetX";
      > > $params = {};
      > > $xpath = "";
      > > @ret = $test->ExecSoapMethod($name, $params,
      > $xpath);
      > > print Dumper($ret[1]), "\n";
      > >
      > > The o/p I get is:
      > > $VAR1 = {
      > > 'arr' => {
      > > 'int' => '9'
      > > },
      > > };
      > >
      > > As you can see only the last integer of the array
      > is
      > > returned and not the complete array. I checked the
      > > deserializer and I believe its returning all the
      > > integers. However when it forms the array it only
      > > shows the last integer which is also reflected in
      > the
      > > Xpath. I am new to Perl and S::L and your help is
      > > highly appreciated.
      > >
      > > Thankx,
      > > Vinit
      > >
      > >
      > >
      > >
      > >
      >
      ______________________________________________________
      > > Yahoo! for Good
      > > Donate to the Hurricane Katrina relief effort.
      > > http://store.yahoo.com/redcross-donate3/
      > >
      > >
      > >
      > > ------------------------ Yahoo! Groups Sponsor
      > >
      > >
      > > Yahoo! Groups Links
      > >
      > >
      > > soaplite-unsubscribe@yahoogroups.com
      > >
      > >
      > >
      > >
      > >
      >
      >




      __________________________________
      Yahoo! Mail - PC Magazine Editors' Choice 2005
      http://mail.yahoo.com
    • Duncan Cameron
      ... You need to iterate over the SOM object looking at each occurence of int. Something like (untested) for my $int ($som- valueof( //arr/int )) { print $int,
      Message 2 of 3 , Sep 19, 2005
      • 0 Attachment
        On 2005-09-18 at 21:14:05 Vinit Samel wrote:

        >Hi
        >
        >Please find below the XML Request and Response. I
        >think its something with the way the int array is
        >deserialized - its taking 'int' type as a key and
        >hence only the last key:value pair is returned.
        >But I cant figure out where exactly I need to
        >manipulate the code in the SOAP:: Deserializer . both
        >decode_object and decode_value seem to work as
        >expected returning int values and type for the whole
        >int array.
        >
        >Let me know of what u think.
        >Thanks,
        >Vinit
        >-----------
        >
        >
        ><?xml version="1.0"
        >encoding="UTF-8"?><SOAP-ENV:Envelope
        >xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
        >SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        >xmlns:SOAP-ENV="h
        >ttp://schemas.xmlsoap.org/soap/envelope/"
        >xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
        >xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><GetX
        >xmlns="http://www.xxxx.com/xxxx/xxxx"/></SOAP-ENV:Body></SOAP-ENV:Envelope>
        >
        >
        ><?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/XMLS
        >chema"><soap:Body><GetXResponse
        >xmlns="http://www.xxxx.com/xxxx/xxxx"><GetXResult><arr><int>0</int
        >><int>1</int><int>2</int><int>3</int><int>4</int><int>5</int><int>6</int><int>7</int><int>8</int><int>9</int></arr></GetXResult></GetXResponse></soap:Body></soap:Envelope>
        >
        >$VAR1 = {
        > 'arr' => {
        > 'int' => '9'
        > }
        > }

        You need to iterate over the SOM object looking at each occurence of int. Something like (untested)

        for my $int ($som->valueof('//arr/int')) {
        print $int, "\n";
        }

        See the sections of the docs regarding SOM to understand more about what is going on. Also, there are many posts in the list archives to do with this very topic.


        Duncan
      Your message has been successfully submitted and would be delivered to recipients shortly.