ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
XML_RPC2_Backend_Php_Response Class Reference
+ Collaboration diagram for XML_RPC2_Backend_Php_Response:

Static Public Member Functions

static encode ($param, $encoding='iso-8859-1')
 Encode a normal XML-RPC response, containing the provided value. More...
 
static encodeFault ($code, $message, $encoding='iso-8859-1')
 Encode a fault XML-RPC response, containing the provided code and message. More...
 
static decode (SimpleXMLElement $xml)
 Parse a response and either return the native PHP result. More...
 

Detailed Description

Definition at line 61 of file Response.php.

Member Function Documentation

◆ decode()

static XML_RPC2_Backend_Php_Response::decode ( SimpleXMLElement  $xml)
static

Parse a response and either return the native PHP result.

This method receives an XML-RPC response document, in SimpleXML format, decodes it and returns the payload value.

Parameters
SimpleXmlElement$xmlThe Transport XML
Returns
mixed The response payload
See also
http://www.xmlrpc.com/spec
Exceptions
XML_RPC2_FaultExceptionSignals the decoded response was an XML-RPC fault
XML_RPC2_DecodeExceptionSignals an ill formed payload response section

Definition at line 125 of file Response.php.

126 {
127 $faultNode = $xml->xpath('/methodResponse/fault');
128 if (count($faultNode) == 1) {
130 }
131 $paramValueNode = $xml->xpath('/methodResponse/params/param/value');
132 if (count($paramValueNode) == 1) {
133 return XML_RPC2_Backend_Php_Value::createFromDecode($paramValueNode[0])->getNativeValue();
134 }
135 throw new XML_RPC2_DecodeException('Unable to decode xml-rpc response. No fault nor params/param elements found');
136 }
static createFromDecode($simpleXML)
Decode an encoded value and build the applicable XML_RPC2_Value subclass.
Definition: Value.php:215
static createFromDecode($xml)
Create a XML_RPC2_FaultException by decoding the corresponding xml string.
Definition: Exception.php:258

References XML_RPC2_Backend_Php_Value\createFromDecode(), and XML_RPC2_FaultException\createFromDecode().

Referenced by XML_RPC2_Backend_Php_Client\remoteCall___().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ encode()

static XML_RPC2_Backend_Php_Response::encode (   $param,
  $encoding = 'iso-8859-1' 
)
static

Encode a normal XML-RPC response, containing the provided value.

You may supply a php-native value, or an XML_RPC2_Backend_Php_Value instance, to be returned. Usually providing a native value is more convenient. However, for some types, XML_RPC2_Backend_Php_Value::createFromNative can't properly choose the xml-rpc type. In these cases, constructing an XML_RPC2_Backend_Php_Value and using it as param here is the only way to return the desired type.

See also
http://www.xmlrpc.com/spec
XML_RPC2_Backend_Php_Value::createFromNative
Parameters
mixed$paramThe result value which the response will envelop
string$encodingencoding
Returns
string The XML payload

Definition at line 80 of file Response.php.

81 {
82 if (!$param instanceof XML_RPC2_Backend_Php_Value) {
84 }
85 $result = '<?xml version="1.0" encoding="' . $encoding . '"?>';
86 $result .= '<methodResponse><params><param><value>' . $param->encode() . '</value></param></params></methodResponse>';
87 return $result;
88 }
$result
static createFromNative($nativeValue, $explicitType=null)
Choose a XML_RPC2_Value subclass appropriate for the given value and create it.
Definition: Value.php:123

References $result, and XML_RPC2_Backend_Php_Value\createFromNative().

Referenced by XML_RPC2_Backend_Php_Server\getResponse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ encodeFault()

static XML_RPC2_Backend_Php_Response::encodeFault (   $code,
  $message,
  $encoding = 'iso-8859-1' 
)
static

Encode a fault XML-RPC response, containing the provided code and message.

See also
http://www.xmlrpc.com/spec
Parameters
int$codeResponse code
string$messageResponse message
string$encodingencoding
Returns
string The XML payload

Definition at line 102 of file Response.php.

103 {
104 $value = new XML_RPC2_Backend_Php_Value_Struct(array('faultCode' => (int) $code, 'faultString' => (string) $message));
105 $result = '<?xml version="1.0" encoding="' . $encoding . '"?>';
106 $result .= '<methodResponse><fault><value>' . $value->encode() . '</value></fault></methodResponse>';
107 return $result;
108 }
$code
Definition: example_050.php:99

References $code, and $result.

Referenced by XML_RPC2_Backend_Php_Server\getResponse(), and XML_RPC2_Backend_Xmlrpcext_Server\getResponse().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: