A signature is an array of types. The first of these types is the return type of the method, the rest are parameters. Because multiple signatures ie. Signatures themselves are restricted to the top level parameters expected by a method.
If no signature is defined for the method, a non-array value is returned. In Python this means that the type of the returned value will be something other than list. It returns a documentation string describing the use of that method. If no such string is available, an empty string is returned. The documentation string may contain HTML markup.
This class may be initialized from bytes data which may include NULs. The primary access to the content of a Binary object is provided by an attribute:. The binary data encapsulated by the Binary instance. The data is provided as a bytes object.
The encoded data will have newlines every 76 characters as per RFC section 6. Fault objects have the following attributes:.
The server code:. It has the following attributes:. The MultiCall object provides a way to encapsulate multiple calls to a remote server into a single request 1.
Create an object used to boxcar method calls. Calls can be made to the result object, but they will immediately return None , and only store the call name and parameters in the MultiCall object. Calling the object itself causes all stored calls to be transmitted as a single system. The result of this call is a generator ; iterating over this generator yields the individual results. If methodresponse is true, only a single value can be returned, meaning that params must be of length 1.
This is in stark contrast to most RPC systems, where the standards documents often run into the thousands of pages and require considerable software support in order to be used.
This means that, whatever your programming language of choice, you can surely find an XML-RPC library for it; and once you have the library, connection to QueueMetrics is straightforward. Information is divided into blocks, i. This means that you can build software that sits on top of QueueMetrics and uses its result as a starting point for further elaboration, e.
As you can see, it only takes four lines of Python code to connect to QueueMetrics and get all the results back! Although the server and client classes can guess how to convert between Perl and XML-RPC data types, these objects provide a way to remove the guesswork. Both clients and servers translate Perl values to XML elements as follows:. Although it may seem clumsy to use objects instead of simple scalars, they have a purpose: they formalize the encoding, and in doing so ensure that your code plays well with others.
If you are a Perl developer, you are used to working in an extremely flexible environment in which there is little worry about which data type applies to a particular variable. Actually, this detail depends on how the value is used. When you include a scalar value either as a literal or with a scalar variable in the argument list of an XML-RPC call, a Frontier::Client object tries to interpret it as a numeric value -- first as an integer, then as a floating-point number -- before simply treating it as a string.
Create a string in ISO format, specifying a particular date and time. Because this is a very simple format, you may find it practical to create the string yourself. Thus, the call:. The strategy for handling string-encoded binary parameters closely parallels that for date-time parameters. XML-RPC binary parameters are passed as strings encoded in the base64 content-transfer-encoding scheme. Creating a binary argument involves two steps:. Create a base64 string that represents the binary data.
Then wrap the base64 string in a Base64 object. But first, it performs a very valuable job: it checks that the scalar value to be wrapped in an Integer object really is an integer.
Invoke the int method in an eval block to deal with the error case:. At the time of writing, only the int , double , and boolean methods perform data validation. Each argument type described in the preceding sections is an individual value: a single number, a single string, or a single block of binary data. This call:. Frontier::RPC can encode nested hashes and arrays, just as you would in any other Perl script.
Both clients and servers translate XML elements to Perl values as follows:. Certain data types can be translated to either a Perl object or a scalar value. The client code might be:.
For example:. The resulting values are embedded within the array or hash that represents the overall response. There are a couple of methods for getting to the real data. If the reference is to a Perl array or hash, use the standard Perl arrow operator:.
The value method always returns a Perl scalar. The value extracted from a Frontier::RPCInteger object is an integer; the value extracted from a Boolean object is either or 1; the value extracted from a Base64 object is a block of binary data encoded as a Base64 string; and so on.
When you have an object in hand, you may need to be able to find out what kind of object it is. For example, the documentation may say that the response to a GetExpirationDate method should be an ISO object, the response to an Expired method should be a Boolean object, and a SetSize method should take a string argument and an integer argument.
Or maybe you want to implement a method that accepts an argument of any data type. The standard Perl tool for determining the type of a data item is the built-in ref function. This object represents a connection to that server. The call method:. Converts each user-specified argument from Perl format scalar or object to XML format. The only Perl module you need to import explicitly is the one that defines the Frontier::Client package:. This line specifies that the fictional host www.
In specifying the host, keep these points in mind:. You may need to include a port number in the URL. Some hosts run a regular web server on one port port 80 is the industry standard and an XML-RPC server on another port:. If you need to switch back and forth among several such servers, just create several clients. In addition to the required URL argument, the Client object-constructor method supports some optional arguments:.
You may need to use this option if your host is behind an Internet firewall. The string is inserted into the XML document header. For example, the following option:. Be careful with this option.
0コメント