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

Handling LoLs (List of Lists, Structs, Objects, or something else)

Expand Messages
  • frankcroth2002
    Hello, I have a problem putting the result of a soap client return into a list. Somehow I always end up with just one entry. Does anyone know what to do to get
    Message 1 of 4 , Aug 4, 2005
    • 0 Attachment
      Hello,

      I have a problem putting the result of a soap client return into a
      list. Somehow I always end up with just one entry. Does anyone know
      what to do to get everything back?

      here is the script and the output:

      #!perl -w

      #use SOAP::Lite;
      use SOAP::Lite +trace => 'debug';

      my $NS="http://www.marimba.com/depmgr/schema/soap/";
      my $soap = SOAP::Lite
      -> uri($NS)
      -> proxy('http://marimbaet.csintra.net:8889/soap/', timeout =>
      10);

      my $result = $soap->CommandLine(SOAP::Data->name(Argument => '-
      login'),
      SOAP::Data->name('Argument' => 'admin:xxxx'),
      SOAP::Data->name('Argument'
      => '-show'),
      SOAP::Data->name('Argument'
      => 'fsktd'),
      SOAP::Data->name('Argument'
      => '/')
      );


      unless ($result->fault) {
      print $result->result;
      @listings = @{$result->result};
      foreach (@listings) {
      print "$_\n";
      }
      } else {
      print $result->faultcode, " ", $result->faultstring, "\n";

      #print join ', ',
      # $result->faultcode,
      # $result->faultstring,
      # $result->faultdetail;
      }

      output:
      --------------------------------------------------------
      SOAP::Transport::HTTP::Client::send_receive: POST
      http://marimbaet.csintra.net:8889/soap/
      Accept: text/xml
      Accept: multipart/*
      Content-Length: 741
      Content-Type: text/xml; charset=utf-8
      SOAPAction: "http://www.marimba.com/depmgr/schema/soap/#CommandLine"

      <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-
      ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-
      ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-
      ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-
      ENV:Body><namesp1:CommandLine
      xmlns:namesp1="http://www.marimba.com/depmgr/schema/soap/"><Argument
      xsi:type="xsd:string">-login</Argument><Argument
      xsi:type="xsd:string">admin:marimbaDM</Argument><Argument
      xsi:type="xsd:string">-show</Argument><Argument
      xsi:type="xsd:string">fsktd</Argument><Argument
      xsi:type="xsd:string">/</Argument></namesp1:CommandLine></SOAP-
      ENV:Body></SOAP-ENV:Envelope>
      SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
      Connection: Keep-Alive
      Date: Thu, 04 Aug 2005 09:49:59 GMT
      Server: CSF/1.0
      Content-Length: 578
      Content-Type: text/xml
      Client-Date: Thu, 04 Aug 2005 09:49:59 GMT
      Client-Response-Num: 1
      Set-Cookie: id="xxZM2GAoAq2L7P86mPZngQ=="; path=/

      <SOAP-ENV:Envelope xmlns:SOAP-
      ENV="http://schemas.xmlsoap.org/soap/envelope/">
      <SOAP-ENV:Body>
      <DepMgr:CommandLineResponse
      xmlns:DepMgr="http://www.marimba.com/depmgr/schema/soap/">
      <DepMgr:OutputLine xml:space="preserve">
      [F] /</DepMgr:OutputLine>
      <DepMgr:OutputLine xml:space="preserve">
      [F] /FIT/</DepMgr:OutputLine>
      <DepMgr:OutputLine xml:space="preserve">
      [F] /Marimba/</DepMgr:OutputLine>
      <DepMgr:OutputLine xml:space="preserve">
      [F] /RTP_WIN/</DepMgr:OutputLine>
      </DepMgr:CommandLineResponse>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      [F] /
    • Duncan Cameron
      ... Hi Frank You need to navigate throught the SOM object that is returned by your call and pick out the repeating bits. See this previous post for an example
      Message 2 of 4 , Aug 4, 2005
      • 0 Attachment
        At 2005-08-04, 11:03:18 you wrote:

        >Hello,
        >
        >I have a problem putting the result of a soap client return into a
        >list. Somehow I always end up with just one entry. Does anyone know
        >what to do to get everything back?
        >
        >here is the script and the output:
        >
        >#!perl -w
        >
        >#use SOAP::Lite;
        >use SOAP::Lite +trace => 'debug';
        >
        >my $NS="http://www.marimba.com/depmgr/schema/soap/";
        >my $soap = SOAP::Lite
        > -> uri($NS)
        > -> proxy('http://marimbaet.csintra.net:8889/soap/', timeout =>
        >10);
        >
        >my $result = $soap->CommandLine(SOAP::Data->name(Argument => '-
        >login'),
        > SOAP::Data->name('Argument' => 'admin:xxxx'),
        > SOAP::Data->name('Argument'
        >=> '-show'),
        > SOAP::Data->name('Argument'
        >=> 'fsktd'),
        > SOAP::Data->name('Argument'
        >=> '/')
        > );
        >
        >
        >unless ($result->fault) {
        > print $result->result;
        > @listings = @{$result->result};
        > foreach (@listings) {
        > print "$_\n";
        > }
        > } else {
        > print $result->faultcode, " ", $result->faultstring, "\n";
        >
        > #print join ', ',
        > # $result->faultcode,
        > # $result->faultstring,
        > # $result->faultdetail;
        >}
        >
        >output:
        >--------------------------------------------------------
        >SOAP::Transport::HTTP::Client::send_receive: POST
        >http://marimbaet.csintra.net:8889/soap/
        >Accept: text/xml
        >Accept: multipart/*
        >Content-Length: 741
        >Content-Type: text/xml; charset=utf-8
        >SOAPAction: "http://www.marimba.com/depmgr/schema/soap/#CommandLine"
        >
        ><?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
        >xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-
        >ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-
        >ENV="http://schemas.xmlsoap.org/soap/envelope/"
        >xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-
        >ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-
        >ENV:Body><namesp1:CommandLine
        >xmlns:namesp1="http://www.marimba.com/depmgr/schema/soap/"><Argument
        >xsi:type="xsd:string">-login</Argument><Argument
        >xsi:type="xsd:string">admin:marimbaDM</Argument><Argument
        >xsi:type="xsd:string">-show</Argument><Argument
        >xsi:type="xsd:string">fsktd</Argument><Argument
        >xsi:type="xsd:string">/</Argument></namesp1:CommandLine></SOAP-
        >ENV:Body></SOAP-ENV:Envelope>
        >SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
        >Connection: Keep-Alive
        >Date: Thu, 04 Aug 2005 09:49:59 GMT
        >Server: CSF/1.0
        >Content-Length: 578
        >Content-Type: text/xml
        >Client-Date: Thu, 04 Aug 2005 09:49:59 GMT
        >Client-Response-Num: 1
        >Set-Cookie: id="xxZM2GAoAq2L7P86mPZngQ=="; path=/
        >
        ><SOAP-ENV:Envelope xmlns:SOAP-
        >ENV="http://schemas.xmlsoap.org/soap/envelope/">
        > <SOAP-ENV:Body>
        > <DepMgr:CommandLineResponse
        >xmlns:DepMgr="http://www.marimba.com/depmgr/schema/soap/">
        > <DepMgr:OutputLine xml:space="preserve">
        >[F] /</DepMgr:OutputLine>
        > <DepMgr:OutputLine xml:space="preserve">
        >[F] /FIT/</DepMgr:OutputLine>
        > <DepMgr:OutputLine xml:space="preserve">
        >[F] /Marimba/</DepMgr:OutputLine>
        > <DepMgr:OutputLine xml:space="preserve">
        >[F] /RTP_WIN/</DepMgr:OutputLine>
        > </DepMgr:CommandLineResponse>
        > </SOAP-ENV:Body>
        ></SOAP-ENV:Envelope>
        >
        >[F] /
        >
        >
        Hi Frank

        You need to navigate throught the SOM object that is returned by your call and pick out the repeating bits. See this previous post for an example

        http://groups.yahoo.com/group/soaplite/message/3694

        Duncan
      • Frank Roth
        Hi Duncan Thank you for the link to the previous post. I looked at it and I am closer to my problem. The difference is that I don t have a hash, just a array.
        Message 3 of 4 , Aug 4, 2005
        • 0 Attachment
          At 2005-08-04, 11:03:18 you wrote:

          >Hello,
          >
          >I have a problem putting the result of a soap client return into a
          >list. Somehow I always end up with just one entry. Does anyone know
          >what to do to get everything back?
          >
          >here is the script and the output:
          >
          >#!perl -w
          >
          >#use SOAP::Lite;
          >use SOAP::Lite +trace => 'debug';
          >
          >my $NS="http://www.marimba.com/depmgr/schema/soap/";
          >my $soap = SOAP::Lite                                       
          >    -> uri($NS)                                    
          >    -> proxy('http://marimbaet.csintra.net:8889/soap/', timeout =>
          >10);
          >
          >my $result = $soap->CommandLine(SOAP::Data->name(Argument => '-
          >login'),
          >                            SOAP::Data->name('Argument' => 'admin:xxxx'),
          >                                SOAP::Data->name('Argument'
          >=> '-show'),
          >                                SOAP::Data->name('Argument'
          >=> 'fsktd'),
          >                                SOAP::Data->name('Argument'
          >=> '/')
          >                        );

          >
          >unless ($result->fault) {
          >      print $result->result;
          >      @listings = @{$result->result};
          >      foreach (@listings) {  
          >                   print "$_\n";
          >            }
          >  } else {
          >    print $result->faultcode, " ", $result->faultstring, "\n";
          >   
          >    #print join ', ',
          >    #  $result->faultcode,
          >    #  $result->faultstring,
          >    #  $result->faultdetail;
          >}
          >
          >output:
          >--------------------------------------------------------
          >SOAP::Transport::HTTP::Client::send_receive: POST
          >http://marimbaet.csintra.net:8889/soap/
          >Accept: text/xml
          >Accept: multipart/*
          >Content-Length: 741
          >Content-Type: text/xml; charset=utf-8
          >SOAPAction: "http://www.marimba.com/depmgr/schema/soap/#CommandLine"
          >
          ><?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
          >xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-
          >ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-
          >ENV="http://schemas.xmlsoap.org/soap/envelope/"
          >xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-
          >ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-
          >ENV:Body><namesp1:CommandLine
          >xmlns:namesp1="http://www.marimba.com/depmgr/schema/soap/"><Argument
          >xsi:type="xsd:string">-login</Argument><Argument
          >xsi:type="xsd:string">admin:marimbaDM</Argument><Argument
          >xsi:type="xsd:string">-show</Argument><Argument
          >xsi:type="xsd:string">fsktd</Argument><Argument
          >xsi:type="xsd:string">/</Argument></namesp1:CommandLine></SOAP-
          >ENV:Body></SOAP-ENV:Envelope>
          >SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
          >Connection: Keep-Alive
          >Date: Thu, 04 Aug 2005 09:49:59 GMT
          >Server: CSF/1.0
          >Content-Length: 578
          >Content-Type: text/xml
          >Client-Date: Thu, 04 Aug 2005 09:49:59 GMT
          >Client-Response-Num: 1
          >Set-Cookie: id="xxZM2GAoAq2L7P86mPZngQ=="; path=/
          >
          ><SOAP-ENV:Envelope xmlns:SOAP-
          >ENV="http://schemas.xmlsoap.org/soap/envelope/">
          >  <SOAP-ENV:Body>
          >    <DepMgr:CommandLineResponse
          >xmlns:DepMgr="http://www.marimba.com/depmgr/schema/soap/">
          >     <DepMgr:OutputLine xml:space="preserve">
          >[F] /</DepMgr:OutputLine>
          >     <DepMgr:OutputLine xml:space="preserve">   
          >[F] /FIT/</DepMgr:OutputLine>
          >     <DepMgr:OutputLine xml:space="preserve">   
          >[F] /Marimba/</DepMgr:OutputLine>
          >     <DepMgr:OutputLine xml:space="preserve">   
          >[F] /RTP_WIN/</DepMgr:OutputLine>
          >    </DepMgr:CommandLineResponse>
          >  </SOAP-ENV:Body>
          ></SOAP-ENV:Envelope>
          >
          >[F] /
          >
          >
          Hi Frank

          You need to navigate throught the SOM object  that is returned by your call and pick out the repeating bits. See this previous post for an example

          http://groups.yahoo.com/group/soaplite/message/3694

          Duncan




        • Alex Pena
          Might have to add the //CommandLineResponse/* that way you get each element not just the first. Try the example below. #!/usr/bin/perl -w use strict; use
          Message 4 of 4 , Aug 4, 2005
          • 0 Attachment
            Might have to add the "//CommandLineResponse/*" that way you get each
            element not just the first. Try the example below.

            #!/usr/bin/perl -w
            use strict;
            use SOAP::Lite;

            use Data::Dumper;
            $Data::Dumper::Terse = 1;
            $Data::Dumper::Indent = 1;

            my $xml = <<'END';
            <Response>
            <SOAP-ENV:Envelope
            xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
            <SOAP-ENV:Body>
            <DepMgr:CommandLineResponse
            xmlns:DepMgr="http://www.marimba.com/depmgr/schema/soap/">
            <DepMgr:OutputLine xml:space="preserve"> [F] /</DepMgr:OutputLine>
            <DepMgr:OutputLine xml:space="preserve"> [F]
            /FIT/</DepMgr:OutputLine>
            <DepMgr:OutputLine xml:space="preserve"> [F]
            /Marimba/</DepMgr:OutputLine>
            <DepMgr:OutputLine xml:space="preserve"> [F]
            /RTP_WIN/</DepMgr:OutputLine>
            </DepMgr:CommandLineResponse>
            </SOAP-ENV:Body>
            </SOAP-ENV:Envelope>
            </Response>
            END

            my $s = SOAP::Deserializer->new;
            my $som = $s->deserialize($xml); # som is normally returned by your
            SOAP call
            my @resultArray=();

            foreach my $field ($som->valueof('//CommandLineResponse/*')) {
            # print "$field\n";
            push @resultArray,$field;
            }
            print Dumper(@resultArray);

            __END__

            Alex-

            On Aug 4, 2005, at 3:54 PM, Frank Roth wrote:

            > Hi Duncan
            >
            > Thank you for the link to the previous post. I looked at it and I am
            > closer to my problem. The difference is that I don't have a hash, just
            > a array. But somehow I am stuck. What do I have to change to get the
            > array?
            >
            >
            > use strict;
            > use SOAP::Lite;
            >
            > my $xml = <<'END';
            > <Response>
            > <SOAP-ENV:Envelope
            > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
            >   <SOAP-ENV:Body>
            >     <DepMgr:CommandLineResponse
            > xmlns:DepMgr="http://www.marimba.com/depmgr/schema/soap/">
            >      <DepMgr:OutputLine xml:space="preserve"> [F]
            > /</DepMgr:OutputLine>
            >      <DepMgr:OutputLine xml:space="preserve"> [F]
            > /FIT/</DepMgr:OutputLine>
            >      <DepMgr:OutputLine xml:space="preserve"> [F]
            > /Marimba/</DepMgr:OutputLine>
            >      <DepMgr:OutputLine xml:space="preserve"> [F]
            > /RTP_WIN/</DepMgr:OutputLine>
            >     </DepMgr:CommandLineResponse>
            >   </SOAP-ENV:Body>
            > </SOAP-ENV:Envelope>
            > </Response>
            > END
            >
            > my $s = SOAP::Deserializer->new;
            >
            > my $som = $s->deserialize($xml); # som is normally returned by your
            > SOAP call
            >
            > for my $i ($som->valueof('//CommandLineResponse')) {
            >         print map({qq|$_ => "$i->{$_}" |} keys %{$i}), "\n";
            > }
            >
            > returns:
            >
            > OutputLine => " [F] /RTP_WIN/"
            >
            > Regards,
            >
            > Frank
            >
            >
            > On Thursday, August 04, 2005, at 09:49PM, Duncan Cameron
            > <duncan_cameron2002@...> wrote:
            >
            > >
            > ><<Original Attached>>
            >
            > YAHOO! GROUPS LINKS
            >
            > ▪  Visit your group "soaplite" on the web.
            >  
            > ▪  To unsubscribe from this group, send an email to:
            >  soaplite-unsubscribe@yahoogroups.com
            >  
            > ▪  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
            > Service.
            >
            >
            > At 2005-08-04, 11:03:18 you wrote:
            >
            > >Hello,
            > >
            > >I have a problem putting the result of a soap client return into a
            > >list. Somehow I always end up with just one entry. Does anyone know
            > >what to do to get everything back?
            > >
            > >here is the script and the output:
            > >
            > >#!perl -w
            > >
            > >#use SOAP::Lite;
            > >use SOAP::Lite +trace => 'debug';
            > >
            > >my $NS="http://www.marimba.com/depmgr/schema/soap/";
            > >my $soap = SOAP::Lite                                       
            > >    -> uri($NS)                                    
            > >    -> proxy('http://marimbaet.csintra.net:8889/soap/', timeout =>
            > >10);
            > >
            > >my $result = $soap->CommandLine(SOAP::Data->name(Argument => '-
            > >login'),
            > >                            SOAP::Data->name('Argument' =>
            > 'admin:xxxx'),
            > >                                SOAP::Data->name('Argument'
            > >=> '-show'),
            > >                                SOAP::Data->name('Argument'
            > >=> 'fsktd'),
            > >                                SOAP::Data->name('Argument'
            > >=> '/')
            > >                        );
            > > 
            > >
            > >unless ($result->fault) {
            > >      print $result->result;
            > >      @listings = @{$result->result};
            > >      foreach (@listings) {  
            > >                   print "$_\n";
            > >            }
            > >  } else {
            > >    print $result->faultcode, " ", $result->faultstring, "\n";
            > >   
            > >    #print join ', ',
            > >    #  $result->faultcode,
            > >    #  $result->faultstring,
            > >    #  $result->faultdetail;
            > >}
            > >
            > >output:
            > >--------------------------------------------------------
            > >SOAP::Transport::HTTP::Client::send_receive: POST
            > >http://marimbaet.csintra.net:8889/soap/
            > >Accept: text/xml
            > >Accept: multipart/*
            > >Content-Length: 741
            > >Content-Type: text/xml; charset=utf-8
            > >SOAPAction: "http://www.marimba.com/depmgr/schema/soap/#CommandLine"
            > >
            > ><?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
            > >xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-
            > >ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-
            > >ENV="http://schemas.xmlsoap.org/soap/envelope/"
            > >xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-
            > >ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-
            > >ENV:Body><namesp1:CommandLine
            > >xmlns:namesp1="http://www.marimba.com/depmgr/schema/soap/"><Argument
            > >xsi:type="xsd:string">-login</Argument><Argument
            > >xsi:type="xsd:string">admin:marimbaDM</Argument><Argument
            > >xsi:type="xsd:string">-show</Argument><Argument
            > >xsi:type="xsd:string">fsktd</Argument><Argument
            > >xsi:type="xsd:string">/</Argument></namesp1:CommandLine></SOAP-
            > >ENV:Body></SOAP-ENV:Envelope>
            > >SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
            > >Connection: Keep-Alive
            > >Date: Thu, 04 Aug 2005 09:49:59 GMT
            > >Server: CSF/1.0
            > >Content-Length: 578
            > >Content-Type: text/xml
            > >Client-Date: Thu, 04 Aug 2005 09:49:59 GMT
            > >Client-Response-Num: 1
            > >Set-Cookie: id="xxZM2GAoAq2L7P86mPZngQ=="; path=/
            > >
            > ><SOAP-ENV:Envelope xmlns:SOAP-
            > >ENV="http://schemas.xmlsoap.org/soap/envelope/">
            > >  <SOAP-ENV:Body>
            > >    <DepMgr:CommandLineResponse
            > >xmlns:DepMgr="http://www.marimba.com/depmgr/schema/soap/">
            > >     <DepMgr:OutputLine xml:space="preserve">
            > >[F] /</DepMgr:OutputLine>
            > >     <DepMgr:OutputLine xml:space="preserve">   
            > >[F] /FIT/</DepMgr:OutputLine>
            > >     <DepMgr:OutputLine xml:space="preserve">   
            > >[F] /Marimba/</DepMgr:OutputLine>
            > >     <DepMgr:OutputLine xml:space="preserve">   
            > >[F] /RTP_WIN/</DepMgr:OutputLine>
            > >    </DepMgr:CommandLineResponse>
            > >  </SOAP-ENV:Body>
            > ></SOAP-ENV:Envelope>
            > >
            > >[F] /
            > >
            > >
            > Hi Frank
            >
            > You need to navigate throught the SOM object  that is returned by
            > your call and pick out the repeating bits. See this previous post for
            > an example
            >
            > http://groups.yahoo.com/group/soaplite/message/3694
            >
            > Duncan
            >
            >
            >
            >
            >
            Alex Pena
            Search Marketing Monitoring Engineer
            74 N. Pasadena Ave., 3rd floor | Pasadena, CA 91103
            penaa@...
            Direct 626.583.2878 | Fax 626.685.5601
            Yahoo! Search Marketing | searchmarketing.yahoo.com
          Your message has been successfully submitted and would be delivered to recipients shortly.