PYTHON xmlrpc_encode_request

is this article helpful?
Python replacement for PHP's xmlrpc_encode_request [ edit | history ]
Help on function dumps in module xmlrpclib:

dumps(params, methodname=None, methodresponse=None, encoding=None, allow_none=0)
data -> marshalled data

Convert an argument tuple or a Fault instance to an XML-RPC
request (or response, if the methodresponse option is used).

In addition to the data object, the following options can be given
as keyword arguments:

methodname: the method name for a methodCall packet

methodresponse: true to create a methodResponse packet.
If this option is used with a tuple, the tuple must be
a singleton (i.e. it can contain only one element).

encoding: the packet encoding (default is UTF-8)

All 8-bit strings in the data structure are assumed to use the
packet encoding. Unicode strings are automatically converted,
where necessary.

import xmlrpclib

parameter = ( [1,2,3], {"1":2, "3":4} ) # a tuple
xml = xmlrpclib.dumps(parameter, 'some_method')
print xml

But for the love of your (future) girlfried/boyfriend just use the xmlrpclib interface. (Which does everything for you.)

PHP xmlrpc_encode_request

PHP original manual for xmlrpc_encode_request [ show | ]


(PHP 4 >= 4.1.0, PHP 5)

xmlrpc_encode_requestGenerates XML for a method request


string xmlrpc_encode_request ( string $method , mixed $params [, array $output_options ] )

This function is EXPERIMENTAL. The behaviour of this function, its name, and surrounding documentation may change without notice in a future release of PHP. This function should be used at your own risk.



Name of the method to call.


Method parameters compatible with method signature.


Array specifying output options may contain (default values are emphasised):

  • output_type: php, xml

  • verbosity: no_white_space, newlines_only, pretty

  • escaping: cdata, non-ascii, non-print, markup (may be a string with one value or an array with multiple values)

  • version: simple, xmlrpc, soap 1.1, auto

  • encoding: iso-8859-1, other character set supported by iconv

Return Values

Returns a string containing the XML representation of the request.


Example #1 XMLRPC client functions example

xmlrpc_encode_request("method", array(123));
$context stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml",
'content' => $request
$file file_get_contents(""false$context);
$response xmlrpc_decode($file);
if (
xmlrpc_is_fault($response)) {
trigger_error("xmlrpc: $response[faultString] ($response[faultCode])");
} else {

See Also