Skip to main content Help Control Panel

Aubagne HipHop

Tout le Hip Hop d'Aubagne et des alentours

Home «   Server software «  

Documentation: services/xml_rpc_codec.php

Class XML_RPC_Codec extends Codec - Web service encoder and decoder

This script is a reference file of this system.

Voir aussi:

Licence: GNU Lesser General Public License

Auteurs:

decode() - Parse a XML request according to the XML-RPC specification

function decode($data)

This script uses the standard XML parser included in the PHP library. The objective of the decoding functions is to transform the XML tree into stemming PHP arrays.

Following tags are used for cdata conversion

Following tags are processed as leaves of the tree:

Following tags are processed as nodes of the tree

encode() - Encode some PHP value into XML

function encode($parameter, $type='')

This function tries to guess the adequate type to use. Following types are supported:

export_request() - Build a request according to the XML-RPC specification

function export_request($service, $parameters = NULL)

Example:
$service 'search';
$parameter = array( 'search' => $_REQUEST['search']);
$result $codec->export_request($service$parameter);
if(!
$result[0])
    echo 
$result[1]; // print error code
else
    ... 
// send xml data from $result[1] to the remote web server


Resulting xml:
<?xml version="1.0"?>
<methodCall>
<methodName>search</methodName>
<params>
<param><value><struct>
<member><name>search</name><value><string>...</string></value></member>
</struct></value></param>
</params>
</methodCall>


Voir aussi:

export_response() - Build a response according to the XML-RPC specification

function export_response($values=NULL, $service=NULL)

Example to generate a response with a single string:
$value $codec->encode('hello world''string');
$result $codec->export_response($value);


Resulting xml:
<?xml version="1.0"?>
<methodResponse>
<params>
<param><value><string>hello world</string></value></param>
</params>
</methodResponse>


Example to generate an error response:
$values = array('faultCode' => 123'faultString' => 'hello world');
$result $codec->export_response($values);


Resulting xml:
<?xml version="1.0"?>
<methodResponse>
<fault>
<value><struct>
<member><name>faultCode</name><value><int>...</int></value></member>
<member><name>faultString</name><value>...</value></member>
</struct></value>
</fault>
</methodResponse>


Voir aussi:

import_request() - Parse a XML request according to the XML-RPC specification

function import_request($data)

import_response() - Decode a XML response

function import_response($data, $headers=NULL, $parameters=NULL)

parse_tag_open() - Update the stack on opening tags

function parse_tag_open($parser, $tag, $attributes)

Following tags are processed as nodes of the tree

parse_cdata() - Capture cdata for further processing

function parse_cdata($parser, $cdata)

parse_tag_close() - Update the stack on closing tags

function parse_tag_close($parser, $tag)

The value of cdata is converted explicitly on following tags:

The result is updated on following tags:

The stack is updated on following tags:
Tools
Browse the source of this script
Server software