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

5042Re: [soaplite] How can you determine the name and type of rpc variables on the server side?

Expand Messages
  • Duncan Cameron
    Dec 9, 2005
      At 2005-12-08, 23:34:30 you wrote:

      >I have spent alot of time and effort reading documentation, looking at
      >source code, googling and scanning the list archives but have not been
      >able to discover the answer.
      >While it is clear how to establish names and types for your function
      >parameters on the client side for interoperability with other soap
      >apis, I have not been able to discover how to extract that information
      >back from the request on the server side.
      >For example, lets say I wanted to submit a job which could have any
      >number of optional parameters.
      >I could do something like:
      >my @attrs = ();
      >push @attrs, SOAP::Data->type('string')->name('user')->value('scott');
      >push @attrs, SOAP::Data->type('int')->name('cpus')->value(12);
      >I can see with a trace that the names and types are making it to the
      ><?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
      >The question is -- now how can I extract the names from the variables
      >programmatically on the server side without resorting to parsing the
      >body xml myself (i.e. the scottmo value has the name user and the type
      >string, etc.)?
      >I realize there would be ways to encode the name, values into strings,
      >or use perl data structures like hashes, etc, but I believe the way I
      >am attempting to use this would be the most direct way to use the SOAP
      >protocol and would enable a non-perl server to respond to a perl
      >client request in a straighforward manner.
      >Thank you for any help you can give me on this,
      >Scott Jackson
      See the section ACCESSING HEADERS AND ENVELOPE ON SERVER SIDE in the docs for how to get hold of the SOAP envelope.
      You can then use the SOAP::SOM methods to navigate through the child elements of the jobSubmit element and pick out the name, type and value.

      Something like this might be what you need

      my $j = $som->match('/Envelope/Body/[1]');

      for (my $i = 1; my $e = $j->dataof("[$i]"); $i++) {
      print $e->name , ' ', $e->type, ' ', $e->value, "\n";

    • Show all 3 messages in this topic