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

2412Accessing array elements from return value--XMLRPC::Lite

Expand Messages
  • Devin Venable
    Feb 24, 2003
    • 0 Attachment
      Accessing array elements from return value--XMLRPC::Lite

      I can't seem to access the elements of an array returned from an XMLRPC call.

      The client:

      use XMLRPC::Lite +trace;

      $s = XMLRPC::Lite
        -> proxy('http://devlinux/cgi-bin/test.cgi')
        -> call('Demo.getFile');
       
      @l = $s->result;

      foreach $line (@l)
      {
           print $line;
      }

      The server method:

      sub getFile
      {
              open (FD, "test.file") || die;
              @l = <FD>;
              close(FD);
              return @l;
      }

      The content of the test file is being returned as XML, as you can see in the TRACE output:

      <?xml version="1.0" encoding="UTF-8"?>
      <methodResponse>
              <params>
                      <param>
                              <value>
                                      <string>This is a test file.
      </string>
                              </value>
                      </param>
                      <param>
                              <value>
                                      <string>It's a dummy, dummy.
      </string>
                              </value>
                      </param>
                      <param>
                              <value>
                                      <string>I will test the reading of a file in perl
      </string>
                              </value>
                      </param>
                      <param>
                              <value>
                                      <string>and the process of returing it as an
      </string>
                              </value>
                      </param>
                      <param>
                              <value>
                                      <string>XML::RPC return value.
      </string>
                              </value>
                      </param>
                      <param>
                              <value>
                                      <string>Someday, I'll return a cisco router
      </string>
                              </value>
                      </param>
                      <param>
                              <value>
                                      <string>configuration instead of this bunk data.
      </string>
                              </value>
                      </param>
                      <param>
                              <value>
                                      <string>blah blah blah
      </string>
                              </value>
                      </param>
                      <param>
                              <value>
                                      <string/>
                              </value>
                      </param>
              </params>
      </methodResponse>

      My client only prints the first line of the file ("This is a test file").
      I tried scalar(@l) to get the number of elements in the array, and it returned a count of one.

      I don't use Perl often, so I apologize if this is an uniformed user issue.  I would have thought that
      $s->result would contain all of the elements of the array.  Can you tell me how it should be done?

      Thanks,
      D. Venable