Home arrow PHP arrow Page 3 - Using XML-RPC with PHP

Dissection of a XML-RPC Call - PHP

Do you want your Perl code on one server to call your PHP functions on another? "Impossible!" you say? Not with XML-RPC. XML-RPC is a standard way for any application to make requests and recieve responses from methods written in any language. Interested? I knew you would be.

TABLE OF CONTENTS:
  1. Using XML-RPC with PHP
  2. Compiling PHP with XML-RPC Support
  3. Dissection of a XML-RPC Call
  4. Dissection of a XML-RPC Response
  5. Creating an XML-RPC Server
  6. Creating an XML-RPC Client
  7. Conclusion
By: Lucas Marshall
Rating: starstarstarstarstar / 42
December 20, 2001

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
An XML-RPC call is sent from a client to a server via HTTP POST. This allows XML-RPC applications to work fairly easily behind firewalls, as port 80 is almost always open.

Here's a sample XML-RPC call:

POST xmlrpcexample.php HTTP/1.0 User-Agent: xmlrpc-epi-php/0.2 (PHP) Host: localhost:80 Content-Type: text/xml Content-length: 191 <?xml version='1.0' encoding="iso-8859-1" ?> <methodCall> <methodName>greeting</methodName> <params> <param> <value> <string>Lucas</string> </value> </param> </params> </methodCall>
The first part of the request is simply a standard HTML post request. It's the data sent in the body of the request that interests us.

The <methodCall> tags simply encapsulate the call, with all the parameters enclosed in <params> and each parameter enclosed in <param>.

Parameters are specified enclosed in tags that tell the application what type of parameter they are. In this case, "Lucas" is a string, so it is enclosed in <string>, but there are a lot more parameter types:

<i4> or <int>
four-byte signed integer
10
<boolean>
0 (false) or 1 (true)
1
<string>
ASCII string
Hello, DevShed!
<double>
double-precision signed 
floating point number
-21.2544
<dateTime.iso8601>
date/time
20011219T12:05:26
<base64>
base64-encoded binary
eW91IGNhbid0IHJlYWQgdGhpcyE=


In addition to the basic types, there are also <struct>s and <array>s, <struct>s containing any number of <member>s that consist of <name>s and <value>s (specified in the same manner as <param>s):

<struct> <member> <name>name</name> <value> <string>Lucas Marshall</string> </value> </member> <member> <name>age</name> <value> <i4>20</i4> </value> </member> </struct>
and arrays merely containing any number of <value>s:

<array> <value><i4>10</i4></value> <value><i4>20</i4></value> <value><i4>30</i4></value> </array>


 
 
>>> More PHP Articles          >>> More By Lucas Marshall
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: