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

Re: [soaplite] returning dynamically created arrays

Expand Messages
  • David Houlding
    Paul, I successfully verified that the approach you outlined below works. Thanks! Dave ... _________________________________________________________________
    Message 1 of 4 , Mar 27, 2002
    • 0 Attachment
      Paul,
      I successfully verified that the approach you outlined below works.
      Thanks!
      Dave

      >From: Paul Kulchenko <paulclinger@...>
      >To: davidhoulding <david_houlding@...>, soaplite@yahoogroups.com
      >Subject: Re: [soaplite] returning dynamically created arrays
      >Date: Wed, 27 Mar 2002 07:41:01 -0800 (PST)
      >
      >Hi, David!
      >
      >--- davidhoulding <david_houlding@...> wrote:
      > > Server #1 (incorrectly) returns:
      > > numGroupIds = 0
      > > groupIds =
      >
      > > push @groupIds, ( "1" );
      > > push @groupIds, ( "2" );
      > > push @groupIds, ( "3" );
      > > return ( @groupIds );
      >This code is the same as "return (1,2,3)" which does not create an
      >array on client side. It just returns three elements.
      >
      > > While Server #2 (correctly) returns:
      > > numGroupIds = 3
      > > groupIds = 123
      >
      > > my @groupIds = [ "1", "2", "3" ];
      > > return ( @groupIds );
      >this code runs as 'return [1,2,3]', which indeed returns an array
      >(arrayref to be precise) with three elements.
      >
      >Server #1 should be accessed on client side as:
      >
      >@groupIds = $soap_response->paramsall;
      ># three different return parameters
      >
      >whereas Server #2 should be accessed as you did:
      >
      >@groupIds = @{$soap_response->result};
      ># one return parameter (array) with three subelements
      >
      >Best wishes, Paul.
      >
      > >
      > > Shouldn't these be the same? I need to create an array dynamically
      > > on
      > > the server side but can't see how to do this.
      > > Thanks,
      > > Dave
      > >
      > > Server #1
      > >
      > > #! /usr/bin/perl
      > >
      > > use SOAP::Transport::HTTP;
      > >
      > > SOAP::Transport::HTTP::CGI
      > > -> dispatch_to( 'MyService' )
      > > -> handle;
      > >
      > > package MyService;
      > >
      > > sub getGroupIds {
      > > my @groupIds;
      > > push @groupIds, ( "1" );
      > > push @groupIds, ( "2" );
      > > push @groupIds, ( "3" );
      > > return ( @groupIds );
      > > }
      > >
      > > Server #2
      > >
      > > #! /usr/bin/perl
      > >
      > > use SOAP::Transport::HTTP;
      > >
      > > SOAP::Transport::HTTP::CGI
      > > -> dispatch_to( 'MyService' )
      > > -> handle;
      > >
      > > package MyService;
      > >
      > > sub getGroupIds {
      > > my @groupIds = [ "1", "2", "3" ];
      > > return ( @groupIds );
      > > }
      > >
      > > Client
      > >
      > > #!perl -w
      > >
      > > use SOAP::Lite;
      > >
      > > my $soap_response = SOAP::Lite
      > > -> uri
      > > ('http://www.myserver.com/MyService')
      > >
      > >
      > > -> proxy('http://www.myserver.com/cgi-
      > > bin/MyService/MyService.pl')
      > > -> getGroupIds();
      > >
      > > if( $soap_response->fault ) {
      > > print join ', ', $soap_response->faultcode, $soap_response-
      > > >faultstring;
      > > }
      > >
      > > my @groupIds = @{ $soap_response->result };
      > > my $numGroupIds = @groupIds;
      > >
      > > print "numGroupIds = " . $numGroupIds . "\n";
      > > print "groupIds = ";
      > > print @groupIds;
      > > print "\n";
      > >
      > >
      > >
      > > ------------------------ Yahoo! Groups Sponsor
      > >
      > > To unsubscribe from this group, send an email to:
      > > soaplite-unsubscribe@yahoogroups.com
      > >
      > >
      > >
      > > Your use of Yahoo! Groups is subject to
      > > http://docs.yahoo.com/info/terms/
      > >
      > >
      >
      >
      >__________________________________________________
      >Do You Yahoo!?
      >Yahoo! Movies - coverage of the 74th Academy Awards�
      >http://movies.yahoo.com/
      >
      >
      >To unsubscribe from this group, send an email to:
      >soaplite-unsubscribe@yahoogroups.com
      >
      >
      >
      >Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      >
      >
      >




      _________________________________________________________________
      Join the world�s largest e-mail service with MSN Hotmail.
      http://www.hotmail.com
    • Paul Kulchenko
      Hi, David! ... Forgot to tell. As far as I remember I added a little bit of sugar to the - result() syntax. - result() in list context works as ... as
      Message 2 of 4 , Mar 27, 2002
      • 0 Attachment
        Hi, David!

        --- David Houlding <david_houlding@...> wrote:
        > I successfully verified that the approach you outlined below works.
        Forgot to tell. As far as I remember I added a little bit of sugar to
        the ->result() syntax. ->result() in list context works as
        ->paramsall(), so you may rewrite this code:

        > >@groupIds = $soap_response->paramsall;

        as

        @groupIds = $soap_response->result;

        and it should give you all parameters, whereas

        $result = $soap_response->result;

        will give you only the first one.

        Best wishes, Paul.

        __________________________________________________
        Do You Yahoo!?
        Yahoo! Movies - coverage of the 74th Academy Awards�
        http://movies.yahoo.com/
      Your message has been successfully submitted and would be delivered to recipients shortly.