Home « Server software «
Documentation: services/codec.php
Class Codec - Web service encoder and decoder
To implement a client of some web service, you will have:- to implement at least export_request() and import_response()
- to extend the list of accepted protocols in services/codec.php
This script is a reference file of this system.
Voir aussi:
Licence: GNU Lesser General Public License
Auteurs:
- Bernard Paques bernard.paques@bigfoot.com
export_request() - Build a XML request on client side
function export_request($service, $parameters = NULL)
- $service - string name of the remote service
- $parameters = NULL - mixed transmitted parameters, if any
- returns an array of which the first value indicates call success or failure
$result = $codec->export_request($service, $parameters);
if(!$result[0])
echo $result[1]; // print error code
else
... // send xml data from $result[1] to the remote web server
export_response() - Build a XML response on server side
function export_response($values=NULL, $service=NULL)
- $values=NULL - mixed transmitted values, if any
- $service=NULL - string name of the remote service, if any
- returns an array of which the first value indicates call success or failure
$result = $codec->export_response($values, $service);
if(!$result[0])
echo $result[1]; // print error code
else
... // send xml data from $result[1] to the remote web server
import_request() - Parse a XML request on server side
function import_request($data)
- $data - array the received $HTTP_RAW_POST_DATA
- returns array the service called and the related input parameters
import_response() - Parse a XML response on client side
function import_response($data, $headers=NULL, $parameters=NULL)
- $data - string the received HTTP body
- $headers=NULL - string the received HTTP headers
- $parameters=NULL - mixed the submitted parameters
- returns an array of which the first value indicates call success or failure
initialize() - Load one XML codec handler
function initialize($variant)
- $variant - string the variant to handle
- returns a Codec instance, or NULL if the variant is unknown