If you like SEOmastering Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...

 

XML-RPC Request

Started by chinmay.sahoo, 12-14-2015, 02:25:28

Previous topic - Next topic

chinmay.sahooTopic starter

XML-RPC requests function as HTTP POST requests. Therefore, it must have a proper HTTP POST header. The actual remote call and parameters, in XML format, follows the header as the body of the HTTP request.


QuotePOST /RPC2 HTTP/1.0
User-Agent: PHP5 XML-RPC Client (Mac OS X)
Host: betty.userland.com
Content-Type: text/xml
Content-length: 181
<?xml version="1.0"?>
<methodCall>
<methodName>examples.getStateName</methodName>
<params>
<param>
<value><int>42</int></value>
</param>
</params>
</methodCall>

The first line in the header, POST and the Host line tell us that this XML-RPC call is to a web service that sits at betty.userland.com/RPC2. The name of the call to be requested, in this case, examples.getStateName, is the irst useful information in the message body. We pass an integer of 42 as the parameter to xamples.getStateName. Let's take a look at these elements one by one .

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.

A procedure call can require an unlimited number of parameters. XML-RPC calls do not have named parameters. In other words, you do not name your parameter before assigning a value, for example:

Quote// This is wrong.Parameters are not named.
<param name="myInt">
<value><int>42</int></value>
</param>

Instead, for functions requiring more than one parameter, the correct parameter order is defined by the remote function. You will have to check the API's dоcumentation for this information and make sure you order the parameters correctly.

Quote//The correct way to differentiate parameters is in their order as defined by the API
<params>
<param><value><int>42</int></value></param>
<param><value><int>13</int></value></param>
<param><value><int>32</int></value></param>
</params>

In the request, 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.



If you like SEOmastering Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...