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

How do I access a return value that is an array?

Expand Messages
  • Larry Helmerich
    I m new to both SOAP::Lite and Perl I have a webservice with two methods. The first method is passed a String and returns a String The seond method is passed a
    Message 1 of 2 , Aug 5, 2004
    • 0 Attachment
      I'm new to both SOAP::Lite and Perl

      I have a webservice with two methods.
      The first method is passed a String and returns a String
      The seond method is passed a String and returns an Array of Strings.

      Here is my program

      #use SOAP::Lite + trace => 'debug';
      use SOAP::Lite;
      my $ipAddr = $ARGV[0];
      my $wsdl = "http://localhost:8080/locate-jaxrpc/loc
      my $service = SOAP::Lite->service($wsdl);
      print $service->getMacByIp($ipAddr), "\n";

      $som = $service->browseByIp($ipAddr);
      print $som->valueof('//browseByIpResponse');

      The first method (getMacByIp) works fine.
      When I run by program I get the following output
      001cdb:87e4aa
      Can't call method "valueof" on unblessed reference at getMacByIp2.pl
      line 9.

      I have tried numerous ways to access the return value of browseByIp.
      I read a number of articles that suggested using SOM to access
      complex data types, but I'm not sure exactly how I should be doing
      this or if there is a better way of doing what I want.

      If I turn tracing on the SOAP message for browseByIp is:
      <?xml version="1.0" encoding="UTF-8"?>
      <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"

      xmlns:ns0="urn:Loc"env:encodingStyle="http://schemas.xmlsoap.org/soap/
      encoding/">
      <env:Body>
      <ns0:browseByIpResponse>
      <result href="#ID1"/>
      </ns0:browseByIpResponse>
      <ns0:ArrayOfstring id="ID1" xsi:type="enc:Array"
      enc:arrayType="xsd:string[8]">
      <item xsi:type="xsd:string">001edb:87e4aa,
      10.255.11.167, OmniStack 8008, 1/3, Wed Aug04 16:51:22 PDT
      2004</item>
      <item xsi:type="xsd:string">001bdb:87c2aa, 10.255.11.254,
      NMS_GATEWAY, 5/24, Wed Aug 04 16:50:50 PDT 2004</item>
      <item xsi:type="xsd:string">001ccb:87c4aa, 10.255.11.175,
      OmniStack 6024, 4/5, Wed Aug04 10:53:20 PDT 2004</item>
      <item xsi:type="xsd:string">001ccb:87e4aa, 10.255.11.168,
      OmniStack 8008, 1/1, Wed Aug 04 10:52:59 PDT 2004</item>
      <item xsi:type="xsd:string">000ccb:87e4aa, 10.255.11.147,
      OmniStack 6024, 1/12, Wed Aug04 06:53:32 PDT 2004</item>
      <item xsi:type="xsd:string">001ccb:87e4aa, 10.255.11.125,
      NMS_125, 1/1, Tue Aug 03 08:23:55 PDT 2004</item>
      <item xsi:type="xsd:string">001ccb:87e4aa, 10.255.11.122,
      Hawk122, 1/1, Sat Jul10 20:37:20 PDT 2004</item>
      <item xsi:type="xsd:string">001ccb:87e4aa, 10.255.11.127,
      Falcon_127, 1/2, Mon May 17 08:33:01 PDT 2004</item>
      </ns0:ArrayOfstring>
      </env:Body>
      </env:Envelope>

      Any help would be appreciated
      Thanks,
      Larry
    • Duncan Cameron
      ... When you use a WSDL the call returns the actual data from the server not a som object. SO your first call is correct, but why does your second call expect
      Message 2 of 2 , Aug 6, 2004
      • 0 Attachment
        At 2004-08-06, 03:03:54 Larry Helmerich <lhelmerich@...> wrote:

        >I'm new to both SOAP::Lite and Perl
        >
        >I have a webservice with two methods.
        >The first method is passed a String and returns a String
        >The seond method is passed a String and returns an Array of Strings.
        >
        >Here is my program
        >
        >#use SOAP::Lite + trace => 'debug';
        >use SOAP::Lite;
        >my $ipAddr = $ARGV[0];
        >my $wsdl = "http://localhost:8080/locate-jaxrpc/loc
        >my $service = SOAP::Lite->service($wsdl);

        >print $service->getMacByIp($ipAddr), "\n";
        >$som = $service->browseByIp($ipAddr);
        >print $som->valueof('//browseByIpResponse');

        When you use a WSDL the call returns the actual data from the server
        not a som object. SO your first call is correct, but why does your
        second call expect a som object?

        what does this produce?
        my $a = $service->browseByIp($ipAddr);
        print @a;

        If you do need to get the som object then I think that you can get it throught the call() method,

        my $a = $service->browseByIp($ipAddr);
        my $som = $service->call(); # returns the som for the previous response

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