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

Accessing complex types in SOAPLite result

Expand Messages
  • wwwslashdotcom
    Hi all, I m rather rusty with Perl and am tasked with figuring out how to process array of arrays in the SOAPLite resulting (object?) from the web services.
    Message 1 of 2 , Jul 16, 2003
    • 0 Attachment
      Hi all,
      I'm rather rusty with Perl and am tasked with figuring out how to
      process array of arrays in the SOAPLite resulting (object?) from the
      web services. Here is the returning SOAP message from the web service
      on the server side:

      <?xml version="1.0" encoding="UTF-8"?>
      <soapenv:Envelope
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
      <soapenv:Body>
      <ns1:getPersonDataResponse
      soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:ns1="myService">
      <ns1:getPersonDataReturn xsi:type="soapenc:Array"
      soapenc:arrayType="ns2:string[][2]"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:ns2="http://www.w3.org/2001/XMLSchema">
      <item soapenc:arrayType="ns2:string[2]">
      <item>dummy</item>
      <item>data</item>
      </item>
      <item soapenc:arrayType="ns2:string[2]">
      <item>here</item>
      <item>example</item>
      </item>
      </ns1:getPersonDataReturn>
      </ns1:getPersonDataResponse>
      </soapenv:Body>
      </soapenv:Envelope>

      What I'm trying to do is actually process that with SOAPLite...more
      specifically, retreive the values such as "dummy", "data", etc. I
      tried the following code:

      $soap_response= SOAP::Lite
      -> uri('myService')
      -> proxy('http://localhost:8082/axis/services/')
      -> getPersonData(SOAP::Data->name(arg0 => \@attributes),
      SOAP::Data->name(arg1 => \@restrictions), SOAP::Data->name(arg2
      =>\@app_name))
      -> result;

      @multidim= $soap_response;
      @row1= @{@multidim[0]};
      @row2= @{@multidim[1]};

      for ($i= 0; $i < 2; $i++)
      {
      print ($row1[$i] + " ");
      }

      for ($j= 0; $j < 2; $j++)
      {
      print ($row2[$j] + " ");
      }

      but it doesn't work as the command line response was really weird:

      Scalar value @multidim[0] better written as $multidim[0] at
      scriptor.pl line 15.

      Scalar value @multidim[1] better written as $multidim[1] at
      scriptor.pl line 16.

      >>Use of uninitialized value in array dereference at scriptor.pl line
      16.
      >>Argument " " isn't numeric in addition (+) at scriptor.pl line 20.
      >>Argument " " isn't numeric in addition (+) at scriptor.pl line 25.
      >>Use of uninitialized value in addition (+) at scriptor.pl line 25.
      >>Use of uninitialized value in addition (+) at scriptor.pl line 23.
      >>345731043454841600

      Any ideas?

      Thanks!
    • Eric Amick
      ... $soap_response is probably an array reference, so this should be @multidim = @$soap_response; ... As the warnings said, use $multidim[0] and $multidim[1]
      Message 2 of 2 , Jul 17, 2003
      • 0 Attachment
        > Hi all,
        > I'm rather rusty with Perl and am tasked with figuring out how
        > to
        > process array of arrays in the SOAPLite resulting (object?) from
        > the
        > web services. Here is the returning SOAP message from the web
        > service
        > on the server side:
        >
        > <?xml version="1.0" encoding="UTF-8"?>
        > <soapenv:Envelope
        > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
        > xmlns:xsd="http://www.w3.org/1999/XMLSchema"
        > xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
        > <soapenv:Body>
        > <ns1:getPersonDataResponse
        > soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        > xmlns:ns1="myService">
        > <ns1:getPersonDataReturn xsi:type="soapenc:Array"
        > soapenc:arrayType="ns2:string[][2]"
        > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        > xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
        > xmlns:ns2="http://www.w3.org/2001/XMLSchema">
        > <item soapenc:arrayType="ns2:string[2]">
        > <item>dummy</item>
        > <item>data</item>
        > </item>
        > <item soapenc:arrayType="ns2:string[2]">
        > <item>here</item>
        > <item>example</item>
        > </item>
        > </ns1:getPersonDataReturn>
        > </ns1:getPersonDataResponse>
        > </soapenv:Body>
        > </soapenv:Envelope>
        >
        > What I'm trying to do is actually process that with
        > SOAPLite...more
        > specifically, retreive the values such as "dummy", "data", etc. I
        > tried the following code:
        >
        > $soap_response= SOAP::Lite
        > -> uri('myService')
        > -> proxy('http://localhost:8082/axis/services/')
        > -> getPersonData(SOAP::Data->name(arg0 => \@attributes),
        > SOAP::Data->name(arg1 => \@restrictions), SOAP::Data->name(arg2
        > =>\@app_name))
        > -> result;
        >
        > @multidim= $soap_response;

        $soap_response is probably an array reference, so this should be

        @multidim = @$soap_response;

        > @row1= @{@multidim[0]};
        > @row2= @{@multidim[1]};

        As the warnings said, use $multidim[0] and $multidim[1] instead. See
        if that works any better. Data::Dumper would be very useful in
        determining just what kind of value $soap_response represents.


        Eric Amick
        Columbia, MD
      Your message has been successfully submitted and would be delivered to recipients shortly.