XML-RPC requests are generally sent as HTTP POST requests and hence must have well formed HTTP POST headers. The actual remote call and parameters, in XML format, follows the header as the body of the HTTP request.
POST /RPCexample HTTP/1.0 User-Agent: PHP5 XML-RPC Client (Mac OS X) Host: w3mentor.com Content-Type: text/xml Content-length: 181 <?xml version="1.0"?> <methodCall> <methodName>code.getDetails</methodName> <params> <param> <value><int>101</int></value> </param> </params> </methodCall>
The POST line in the header and the Host line indicates that the XML-RPC call is to a web service that is located at w3mentor.com/RPCexample. The name of the remote method is code.getDetails and is the present in the message body. The methods code.getDetails gets an integer parameter of 101
The root element in an XML-RPC call is methodCall. It has one required child element, methodName, which specifies the name of the call to be requested. There can only be one methodCall per request. If parameters are passed to the call, they are encapsulated in the params element. There can be multiple parameters in a method call. Named parameters are not supported by XML-RPC calls.
Invalid parameter passing:
<param name="myInt"> <value><int>42</int></value> </param>
When more than one parameter is passed, the correct parameter order is needed to be maintained as defined by the remote function.
Multiple parameters:
<params> <param><value><int>42</int></value></param> <param><value><int>13</int></value></param> <param><value><int>32</int></value></param> </params>
Each parameter is enclosed by a param element. Within each param, the actual parameter is wrapped up by a value element. Within this value element are the actual parameter values and data types.