zeltus | 23 Mar 2012 13:11
Picon
Favicon

perl RPC::XML (blackperl)

I am fairly new to XML-RPC stuff and I think I might be approaching it from an "unusual" angle! :-). Anyway, I
have an API Server that expects to see input along the lines of

<?xml version="1.0"?>
<methodCall>
  <methodName>Gateway.SendMessage</methodName>
  <params>
    <param>
      <value>
        <struct>
	  <member>
	    <name>Service</name>
	    <value><int>0</int></value>
	  </member>
	  <member>
	    <name>Password</name>
	    <value>aPassword</value>
	  </member>
	  <member>
	    <name>Text</name>
	    <value>A demonstration short message</value>
	  </member>
	  <member>
	    <name>DeliveryTime</name>
	    <value><dateTime.iso8601>20050421T09:32:00</dateTime.iso8601></value>
	  </member>
	</struct>
      </value>
    </param>
  </params>
(Continue reading)

Bryan Henderson | 23 Mar 2012 16:29

Re: perl RPC::XML (blackperl)

>Am I really coming at this backwards?

I don't know if it's you, but somebody is coming at this backwards.  You don't
specfify an XML-RPC API with an XML document and have users reverse engineer
it.  The API in question should be documented something like this:

  Method name: "Gateway.SendMessage"
  One parameter, of type structure.  Members:

    Service: type integer, meaning: ... example: 0
    Password: type string, meaning: ... example: "aPassword"
    Text: type string, meaning: ... example: "A demonstration short message"
    DeliveryTime: type datetime, meaning: ... example: April 21, 2005 ...

Anyway, the way you specify RPC parameters is to add each as an argument to
your $client->send_request().  You need one parameter, so your
$client->send_request will have two arguments.  That one parameter is a
structure, which is represented in XML::RPC by a XML::RPC::struct.  The
constructor for XML::RPC::struct (see perldoc XML:RPC) takes a Perl hash
reference as its argument.  Since a Perl hash and an XML-RPC structure are
virtually identical data structures, it's easy to see the correspondence, with
the one complication that the hash values are references to XML::RPC data
objects, not the normal Perl data structures.  The Perl hash you start with is
thus something like

  ('Service'  => new RPC::XML::int(0),
   'Password' => new RPC::XML::string('aPassword'),
   'Text'     => new RPC::XML::string('A demonstration short message'),
   ...)

(Continue reading)

Bill Parker | 23 Mar 2012 17:03
Picon
Favicon

Re: perl RPC::XML (blackperl)

On 23 March 2012 15:29, Bryan Henderson <bryanh <at> giraffe-data.com> wrote:

> **
>
>
> >Am I really coming at this backwards?
>
> I don't know if it's you, but somebody is coming at this backwards. You
> don't
> specfify an XML-RPC API with an XML document and have users reverse
> engineer
> it. The API in question should be documented something like this:
>
> Method name: "Gateway.SendMessage"
> One parameter, of type structure. Members:
>
> Service: type integer, meaning: ... example: 0
> Password: type string, meaning: ... example: "aPassword"
> Text: type string, meaning: ... example: "A demonstration short message"
> DeliveryTime: type datetime, meaning: ... example: April 21, 2005 ...
>
> I don't fancy my chances of surviving telling our oh so sociable
developers this! :-} But thank you so much for explaining this to me...
what you are saying makes much more sense than what they try and brush me
off with.

>
> Anyway, the way you specify RPC parameters is to add each as an argument to
> your $client->send_request(). You need one parameter, so your
> $client->send_request will have two arguments. That one parameter is a
(Continue reading)


Gmane