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

XMLRPC::Lite and checking for a returned array

Expand Messages
  • magnus1er
    Hello, A very basic question but I can t find an answer (on the web at least). I m learning XMLRPC::Lite but I can t find a way to access a returned array from
    Message 1 of 4 , Dec 4, 2001
      Hello,

      A very basic question but I can't find an answer (on the web at
      least).

      I'm learning XMLRPC::Lite but I can't find a way to access a returned
      array
      from the server.

      For example the following is returned by the xmlrpc server:

      <?xml version="1.0"
      encoding="UTF-8"?><methodResponse><params><param><value><string>
      Salut mon gros
      </string></value></param><param><value><string>Ceci est un test
      </string></value></param><param><value><string>Mais il manque des
      points
      </string></value></param><param><value><string>........
      </string></value></param><param><value><string>ok
      </string></value></param><param><value><string>.......
      </string></value></param><param><value><string>M
      </string></value></param></params></methodResponse>

      Here's the client script:

      #!/usr/bin/perl -w

      use XMLRPC::Lite;

      my $res = XMLRPC::Lite
      -> proxy('http://192.168.0.3:7777')
      -> call('Util.test', "/home/emm/xmlrpctest")
      -> result;

      I tried
      my @res = $res->paramsin
      following the soaplite intro at soaplite.com with no avail, I get an
      error:
      ==>Can't locate object method "paramsin" via package "Salut mon gros

      TIA

      -Emmanuel
    • Paul Kulchenko
      Hi, Emmanuel! ... From my understanding XML-RPC spec [1] allows you to return only one value, so when you do return (1,2,3); client side will have access only
      Message 2 of 4 , Dec 5, 2001
        Hi, Emmanuel!

        > I'm learning XMLRPC::Lite but I can't find a way to access a
        > returned array from the server.
        From my understanding XML-RPC spec [1] allows you to return only one
        value, so when you do

        return (1,2,3);

        client side will have access only to value '1'.

        If you need to return an array, you can do

        return [1,2,3];

        and on client side you'll get array ref;

        $res = ...->result;
        print @$res;

        Hope it helps. Let me know if you think my understanding of XML-RPC
        spec is wrong.

        Best wishes, Paul.

        [1] http://xml-rpc.com/spec

        --- magnus1er <magnus1er@...> wrote:
        > Hello,
        >
        > A very basic question but I can't find an answer (on the web at
        > least).
        >
        > I'm learning XMLRPC::Lite but I can't find a way to access a
        > returned
        > array
        > from the server.
        >
        > For example the following is returned by the xmlrpc server:
        >
        > <?xml version="1.0"
        > encoding="UTF-8"?><methodResponse><params><param><value><string>
        > Salut mon gros
        > </string></value></param><param><value><string>Ceci est un test
        > </string></value></param><param><value><string>Mais il manque des
        > points
        > </string></value></param><param><value><string>........
        > </string></value></param><param><value><string>ok
        > </string></value></param><param><value><string>.......
        > </string></value></param><param><value><string>M
        > </string></value></param></params></methodResponse>
        >
        > Here's the client script:
        >
        > #!/usr/bin/perl -w
        >
        > use XMLRPC::Lite;
        >
        > my $res = XMLRPC::Lite
        > -> proxy('http://192.168.0.3:7777')
        > -> call('Util.test', "/home/emm/xmlrpctest")
        > -> result;
        >
        > I tried
        > my @res = $res->paramsin
        > following the soaplite intro at soaplite.com with no avail, I get
        > an
        > error:
        > ==>Can't locate object method "paramsin" via package "Salut mon
        > gros
        >
        > TIA
        >
        > -Emmanuel
        >
        >
        >
        >
        > ------------------------ 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!?
        Buy the perfect holiday gifts at Yahoo! Shopping.
        http://shopping.yahoo.com
      • Paul Kulchenko
        Hi, Emmanuel! In addition to that, you still can access array if you want to (just use paramsall method instead of result ): my @res = XMLRPC::Lite -
        Message 3 of 4 , Dec 5, 2001
          Hi, Emmanuel!

          In addition to that, you still can access array if you want to (just
          use 'paramsall' method instead of 'result'):

          my @res = XMLRPC::Lite
          -> proxy('http://192.168.0.3:7777')
          -> call('Util.test', "/home/emm/xmlrpctest")
          -> paramsall;

          Keep in mind though that if my understanding correct, other
          implementations may not have access to more than one parameter.

          Best wishes, Paul.

          --- Paul Kulchenko <paulclinger@...> wrote:
          > Hi, Emmanuel!
          >
          > > I'm learning XMLRPC::Lite but I can't find a way to access a
          > > returned array from the server.
          > From my understanding XML-RPC spec [1] allows you to return only
          > one
          > value, so when you do
          >
          > return (1,2,3);
          >
          > client side will have access only to value '1'.
          >
          > If you need to return an array, you can do
          >
          > return [1,2,3];
          >
          > and on client side you'll get array ref;
          >
          > $res = ...->result;
          > print @$res;
          >
          > Hope it helps. Let me know if you think my understanding of XML-RPC
          > spec is wrong.
          >
          > Best wishes, Paul.
          >
          > [1] http://xml-rpc.com/spec
          >
          > --- magnus1er <magnus1er@...> wrote:
          > > Hello,
          > >
          > > A very basic question but I can't find an answer (on the web at
          > > least).
          > >
          > > I'm learning XMLRPC::Lite but I can't find a way to access a
          > > returned
          > > array
          > > from the server.
          > >
          > > For example the following is returned by the xmlrpc server:
          > >
          > > <?xml version="1.0"
          > > encoding="UTF-8"?><methodResponse><params><param><value><string>
          > > Salut mon gros
          > > </string></value></param><param><value><string>Ceci est un test
          > > </string></value></param><param><value><string>Mais il manque des
          >
          > > points
          > > </string></value></param><param><value><string>........
          > > </string></value></param><param><value><string>ok
          > > </string></value></param><param><value><string>.......
          > > </string></value></param><param><value><string>M
          > > </string></value></param></params></methodResponse>
          > >
          > > Here's the client script:
          > >
          > > #!/usr/bin/perl -w
          > >
          > > use XMLRPC::Lite;
          > >
          > > my $res = XMLRPC::Lite
          > > -> proxy('http://192.168.0.3:7777')
          > > -> call('Util.test', "/home/emm/xmlrpctest")
          > > -> result;
          > >
          > > I tried
          > > my @res = $res->paramsin
          > > following the soaplite intro at soaplite.com with no avail, I get
          > > an
          > > error:
          > > ==>Can't locate object method "paramsin" via package "Salut mon
          > > gros
          > >
          > > TIA
          > >
          > > -Emmanuel
          > >
          > >
          > >
          > >
          > > ------------------------ 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!?
          > Buy the perfect holiday gifts at Yahoo! Shopping.
          > http://shopping.yahoo.com
          >
          > ------------------------ 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!?
          Buy the perfect holiday gifts at Yahoo! Shopping.
          http://shopping.yahoo.com
        • emmanueldecarie
          Thanks Paul for the reply. I m not sure if you saw my previous messages, but anyway, it worked in both case and you are right about the xml-rpc spec.
          Message 4 of 4 , Dec 6, 2001
            Thanks Paul for the reply.

            I'm not sure if you saw my previous messages, but anyway, it worked
            in both
            case and you are right about the xml-rpc spec.

            SOAP::Lite is really a cool module!

            Cheers
            -Emmanuel
          Your message has been successfully submitted and would be delivered to recipients shortly.