ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilBMFClient Class Reference
+ Inheritance diagram for ilBMFClient:
+ Collaboration diagram for ilBMFClient:

Public Member Functions

 ilBMFClient ($endpoint, $wsdl=false, $portName=false, $proxy_params=array())
 Constructor.
 _reset ()
 setEncoding ($encoding)
 Sets the character encoding.
 addHeader (&$soap_value)
 Adds a header to the envelope.
call ($method, &$params, $namespace=false, $soapAction=false)
 Calls a method on the SOAP endpoint.
 setOpt ($category, $option, $value=null)
 Sets an option to use with the transport layers.
 _call ($method, $params, &$return_value)
 Call method supporting the overload extension.
__getlastrequest ()
__getlastresponse ()
 __use ($use)
 __style ($style)
 __trace ($level)
__generate ($method, &$params, $namespace=false, $soapAction=false)
__parse (&$response, $encoding, &$attachments)
__decodeResponse (&$response, $shift=true)
 __get_wire ()

Data Fields

 $_endpoint = ''
 $_portName = ''
 $__endpointType = ''
 $xml
 $wire
 $__last_request = null
 $__last_response = null
 $__options = array('trace'=>0)
 $_encoding = SOAP_DEFAULT_ENCODING
 $headersOut = null
 $headersIn = null
 $__proxy_params = array()
 $_soap_transport = null

Detailed Description

Definition at line 81 of file class.ilBMFClient.php.

Member Function Documentation

& ilBMFClient::__decodeResponse ( $response,
  $shift = true 
)

Definition at line 669 of file class.ilBMFClient.php.

References PEAR\isError().

Referenced by __parse().

{
if (!$response) {
$decoded = null;
return $decoded;
}
// Check for valid response.
if (PEAR::isError($response)) {
$fault =& $this->_raiseSoapFault($response);
return $fault;
} elseif (!is_a($response, 'ilbmfvalue')) {
$fault =& $this->_raiseSoapFault("Didn't get ilBMFValue object back from client");
return $fault;
}
// Decode to native php datatype.
$returnArray =& $this->_decode($response);
// Fault?
if (PEAR::isError($returnArray)) {
$fault =& $this->_raiseSoapFault($returnArray);
return $fault;
}
if (is_object($returnArray) &&
strcasecmp(get_class($returnArray), 'stdClass') == 0) {
$returnArray = get_object_vars($returnArray);
}
if (is_array($returnArray)) {
if (isset($returnArray['faultcode']) ||
isset($returnArray['SOAP-ENV:faultcode'])) {
$faultcode = $faultstring = $faultdetail = $faultactor = '';
foreach ($returnArray as $k => $v) {
if (stristr($k, 'faultcode')) $faultcode = $v;
if (stristr($k, 'faultstring')) $faultstring = $v;
if (stristr($k, 'detail')) $faultdetail = $v;
if (stristr($k, 'faultactor')) $faultactor = $v;
}
$fault =& $this->_raiseSoapFault($faultstring, $faultdetail, $faultactor, $faultcode);
return $fault;
}
// Return array of return values.
if ($shift && count($returnArray) == 1) {
$decoded = array_shift($returnArray);
return $decoded;
}
return $returnArray;
}
return $returnArray;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& ilBMFClient::__generate (   $method,
$params,
  $namespace = false,
  $soapAction = false 
)

Definition at line 440 of file class.ilBMFClient.php.

References $namespace, PEAR\isError(), and SOAP_XML_SCHEMA_VERSION.

Referenced by call().

{
$this->fault = null;
$this->__options['input']='parse';
$this->__options['result']='parse';
$this->__options['parameters'] = false;
if ($params && gettype($params) != 'array') {
$params = array($params);
}
if (gettype($namespace) == 'array') {
foreach ($namespace as $optname => $opt) {
$this->__options[strtolower($optname)] = $opt;
}
if (isset($this->__options['namespace'])) {
$namespace = $this->__options['namespace'];
} else {
$namespace = false;
}
} else {
// We'll place $soapAction into our array for usage in the
// transport.
$this->__options['soapaction'] = $soapAction;
$this->__options['namespace'] = $namespace;
}
if ($this->__endpointType == 'wsdl') {
$this->_setSchemaVersion($this->_wsdl->xsd);
// Get port name.
if (!$this->_portName) {
$this->_portName = $this->_wsdl->getPortName($method);
}
if (PEAR::isError($this->_portName)) {
$fault =& $this->_raiseSoapFault($this->_portName);
return $fault;
}
// Get endpoint.
$this->_endpoint = $this->_wsdl->getEndpoint($this->_portName);
if (PEAR::isError($this->_endpoint)) {
$fault =& $this->_raiseSoapFault($this->_endpoint);
return $fault;
}
// Get operation data.
$opData = $this->_wsdl->getOperationData($this->_portName, $method);
if (PEAR::isError($opData)) {
$fault =& $this->_raiseSoapFault($opData);
return $fault;
}
$namespace = $opData['namespace'];
$this->__options['style'] = $opData['style'];
$this->__options['use'] = $opData['input']['use'];
$this->__options['soapaction'] = $opData['soapAction'];
// Set input parameters.
if ($this->__options['input'] == 'parse') {
$this->__options['parameters'] = $opData['parameters'];
$nparams = array();
if (isset($opData['input']['parts']) &&
count($opData['input']['parts'])) {
$i = 0;
foreach ($opData['input']['parts'] as $name => $part) {
$xmlns = '';
$attrs = array();
// Is the name a complex type?
if (isset($part['element'])) {
$xmlns = $this->_wsdl->namespaces[$part['namespace']];
$part = $this->_wsdl->elements[$part['namespace']][$part['type']];
$name = $part['name'];
}
if (isset($params[$name]) ||
$this->_wsdl->getDataHandler($name, $part['namespace'])) {
$nparams[$name] =& $params[$name];
} else {
// We now force an associative array for
// parameters if using WSDL.
$fault =& $this->_raiseSoapFault("The named parameter $name is not in the call parameters.");
return $fault;
}
if (gettype($nparams[$name]) != 'object' ||
!is_a($nparams[$name], 'ilBMFValue')) {
// Type is likely a qname, split it apart, and get
// the type namespace from WSDL.
$qname =& new QName($part['type']);
if ($qname->ns) {
$type_namespace = $this->_wsdl->namespaces[$qname->ns];
} elseif (isset($part['namespace'])) {
$type_namespace = $this->_wsdl->namespaces[$part['namespace']];
} else {
$type_namespace = null;
}
$qname->namespace = $type_namespace;
$type = $qname->name;
$pqname = $name;
if ($xmlns) {
$pqname = '{' . $xmlns . '}' . $name;
}
$nparams[$name] =& new ilBMFValue($pqname,
$qname->fqn(),
$nparams[$name],
$attrs);
} else {
// WSDL fixups to the SOAP value.
}
}
}
$params =& $nparams;
unset($nparams);
}
} else {
$this->_setSchemaVersion(SOAP_XML_SCHEMA_VERSION);
}
// Serialize the message.
$this->_section5 = (!isset($this->__options['use']) ||
$this->__options['use'] != 'literal');
if (!isset($this->__options['style']) ||
$this->__options['style'] == 'rpc') {
$this->__options['style'] = 'rpc';
$this->docparams = true;
$mqname =& new QName($method, $namespace);
$methodValue =& new ilBMFValue($mqname->fqn(), 'Struct', $params);
$soap_msg = $this->_makeEnvelope($methodValue,
$this->headersOut,
$this->_encoding,
$this->__options);
} else {
if (!$params) {
$mqname =& new QName($method, $namespace);
$mynull = null;
$params =& new ilBMFValue($mqname->fqn(), 'Struct', $mynull);
} elseif ($this->__options['input'] == 'parse') {
if (is_array($params)) {
$nparams = array();
$keys = array_keys($params);
foreach ($keys as $k) {
if (gettype($params[$k]) != 'object') {
$nparams[] =& new ilBMFValue($k,
false,
$params[$k]);
} else {
$nparams[] =& $params[$k];
}
}
$params =& $nparams;
}
if ($this->__options['parameters']) {
$mqname =& new QName($method, $namespace);
$params =& new ilBMFValue($mqname->fqn(),
'Struct',
$params);
}
}
$soap_msg = $this->_makeEnvelope($params,
$this->headersOut,
$this->_encoding,
$this->__options);
}
unset($this->headersOut);
if (PEAR::isError($soap_msg)) {
$fault =& $this->_raiseSoapFault($soap_msg);
return $fault;
}
// Handle MIME or DIME encoding.
// TODO: DIME encoding should move to the transport, do it here for
// now and for ease of getting it done.
if (count($this->__attachments)) {
if ((isset($this->__options['attachments']) &&
$this->__options['attachments'] == 'Mime') ||
isset($this->__options['Mime'])) {
$soap_msg =& $this->_makeMimeMessage($soap_msg,
$this->_encoding);
} else {
// default is dime
$soap_msg =& $this->_makeDIMEMessage($soap_msg,
$this->_encoding);
$this->__options['headers']['Content-Type'] = 'application/dime';
}
if (PEAR::isError($soap_msg)) {
$fault =& $this->_raiseSoapFault($soap_msg);
return $fault;
}
}
// Instantiate client.
if (is_array($soap_msg)) {
$soap_data =& $soap_msg['body'];
if (count($soap_msg['headers'])) {
if (isset($this->__options['headers'])) {
$this->__options['headers'] = array_merge($this->__options['headers'], $soap_msg['headers']);
} else {
$this->__options['headers'] = $soap_msg['headers'];
}
}
} else {
$soap_data =& $soap_msg;
}
return $soap_data;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBMFClient::__get_wire ( )

Definition at line 721 of file class.ilBMFClient.php.

Referenced by call().

{
if ($this->__options['trace'] > 0 &&
($this->__last_request || $this->__last_response)) {
return "OUTGOING:\n\n" .
$this->__last_request .
"\n\nINCOMING\n\n" .
preg_replace("/></",">\r\n<", $this->__last_response);
}
return null;
}

+ Here is the caller graph for this function:

& ilBMFClient::__getlastrequest ( )

Definition at line 413 of file class.ilBMFClient.php.

References $__last_request.

{
$request =& $this->__last_request;
return $request;
}
& ilBMFClient::__getlastresponse ( )

Definition at line 419 of file class.ilBMFClient.php.

References $__last_response.

{
$response =& $this->__last_response;
return $response;
}
& ilBMFClient::__parse ( $response,
  $encoding,
$attachments 
)

Definition at line 649 of file class.ilBMFClient.php.

References __decodeResponse().

Referenced by call().

{
// Parse the response.
$response =& new ilBMFParser($response, $encoding, $attachments);
if ($response->fault) {
$fault =& $this->_raiseSoapFault($response->fault);
return $fault;
}
// Return array of parameters.
$return =& $response->getResponse();
$headers =& $response->getHeaders();
if ($headers) {
$this->headersIn =& $this->__decodeResponse($headers, false);
}
$decoded = &$this->__decodeResponse($return);
return $decoded;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBMFClient::__style (   $style)

Definition at line 430 of file class.ilBMFClient.php.

{
$this->__options['style'] = $style;
}
ilBMFClient::__trace (   $level)

Definition at line 435 of file class.ilBMFClient.php.

{
$this->__options['trace'] = $level;
}
ilBMFClient::__use (   $use)

Definition at line 425 of file class.ilBMFClient.php.

{
$this->__options['use'] = $use;
}
ilBMFClient::_call (   $method,
  $params,
$return_value 
)

Call method supporting the overload extension.

If the overload extension is loaded, you can call the client class with a soap method name: $soap = new ilBMFClient(....); $value = $soap->getStockQuote('MSFT');

public

Parameters
string$methodThe method to call.
array$paramsThe method parameters.
string$return_valueWill get the method's return value assigned.
Returns
boolean Always true.

Definition at line 399 of file class.ilBMFClient.php.

References call().

{
// Overloading lowercases the method name, we need to look into the
// wsdl and try to find the correct method name to get the correct
// case for the call.
if ($this->_wsdl) {
$this->_wsdl->matchMethod($method);
}
$return_value =& $this->call($method, $params);
return true;
}

+ Here is the call graph for this function:

ilBMFClient::_reset ( )

Definition at line 205 of file class.ilBMFClient.php.

{
$this->xml = null;
$this->wire = null;
$this->__last_request = null;
$this->__last_response = null;
$this->headersIn = null;
$this->headersOut = null;
}
ilBMFClient::addHeader ( $soap_value)

Adds a header to the envelope.

public

Parameters
SOAP_Header$soap_valueA SOAP_Header or an array with the elements 'name', 'namespace', 'mustunderstand', and 'actor' to send as a header.

Definition at line 245 of file class.ilBMFClient.php.

{
// Add a new header to the message.
if (is_a($soap_value, 'ilBMFHeader')) {
$this->headersOut[] =& $soap_value;
} elseif (is_array($soap_value)) {
// name, value, namespace, mustunderstand, actor
$this->headersOut[] =& new ilBMFHeader($soap_value[0],
null,
$soap_value[1],
$soap_value[2],
$soap_value[3]);;
} else {
$this->_raiseSoapFault('Invalid parameter provided to addHeader(). Must be an array or a SOAP_Header.');
}
}
& ilBMFClient::call (   $method,
$params,
  $namespace = false,
  $soapAction = false 
)

Calls a method on the SOAP endpoint.

The namespace parameter is overloaded to accept an array of options that can contain data necessary for various transports if it is used as an array, it MAY contain a namespace value and a soapaction value. If it is overloaded, the soapaction parameter is ignored and MUST be placed in the options array. This is done to provide backwards compatibility with current clients, but may be removed in the future. The currently supported values are:

  namespace
  soapaction
  timeout (HTTP socket timeout)
  transfer-encoding (SMTP, Content-Transfer-Encoding: header)
  from (SMTP, From: header)
  subject (SMTP, Subject: header)
  headers (SMTP, hash of extra SMTP headers)

public

Parameters
string$methodThe method to call.
array$paramsThe method parameters.
string | array$namespaceNamespace or hash with options.
string$soapAction
Returns
mixed The method result or a ilBMFFault on error.

Definition at line 290 of file class.ilBMFClient.php.

References $_encoding, $_soap_transport, $namespace, $result, $xml, __generate(), __get_wire(), __parse(), ilBMFTransport\getTransport(), and PEAR\isError().

Referenced by _call().

{
$this->headersIn = null;
$this->__last_request = null;
$this->__last_response = null;
$this->wire = null;
$this->xml = null;
$soap_data =& $this->__generate($method, $params, $namespace, $soapAction);
if (PEAR::isError($soap_data)) {
$fault =& $this->_raiseSoapFault($soap_data);
return $fault;
}
// __generate() may have changed the endpoint if the WSDL has more
// than one service, so we need to see if we need to generate a new
// transport to hook to a different URI. Since the transport protocol
// can also change, we need to get an entirely new object. This could
// probably be optimized.
if (!$this->_soap_transport ||
$this->_endpoint != $this->_soap_transport->url) {
$this->_soap_transport =& ilBMFTransport::getTransport($this->_endpoint);
if (PEAR::isError($this->_soap_transport)) {
$this->_soap_transport = null;
$fault =& $this->_raiseSoapFault($fault);
return $fault;
}
}
$this->_soap_transport->encoding = $this->_encoding;
// Send the message.
$transport_options = array_merge_recursive($this->__proxy_params,
$this->__options);
$this->xml = $this->_soap_transport->send($soap_data, $transport_options);
// Save the wire information for debugging.
if ($this->__options['trace'] > 0) {
$this->__last_request =& $this->_soap_transport->outgoing_payload;
$this->__last_response =& $this->_soap_transport->incoming_payload;
$this->wire = $this->__get_wire();
}
if ($this->_soap_transport->fault) {
$fault =& $this->_raiseSoapFault($this->xml);
return $fault;
}
$this->__attachments =& $this->_soap_transport->attachments;
$this->__result_encoding = $this->_soap_transport->result_encoding;
if (isset($this->__options['result']) &&
$this->__options['result'] != 'parse') {
return $this->xml;
}
$result = &$this->__parse($this->xml, $this->__result_encoding, $this->__attachments);
return $result;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBMFClient::ilBMFClient (   $endpoint,
  $wsdl = false,
  $portName = false,
  $proxy_params = array() 
)

Constructor.

public

Parameters
string$endpointAn URL.
boolean$wsdlWhether the endpoint is a WSDL file.
string$portName
array$proxy_paramsOptions for the HTTP_Request class (see HTTP/Request.php)

Definition at line 178 of file class.ilBMFClient.php.

{
parent::ilBMFBase('Client');
$this->_endpoint = $endpoint;
$this->_portName = $portName;
$this->__proxy_params = $proxy_params;
// This hack should perhaps be removed as it might cause unexpected
// behaviour.
$wsdl = $wsdl
? $wsdl
: strtolower(substr($endpoint, -4)) == 'wsdl';
// make values
if ($wsdl) {
$this->__endpointType = 'wsdl';
// instantiate wsdl class
$this->_wsdl =& new ilBMFWSDL($this->_endpoint,
$this->__proxy_params);
if ($this->_wsdl->fault) {
$this->_raiseSoapFault($this->_wsdl->fault);
}
}
}
ilBMFClient::setEncoding (   $encoding)

Sets the character encoding.

Limited to 'UTF-8', 'US_ASCII' and 'ISO-8859-1'.

public

Parameters
stringencoding
Returns
mixed ilBMFFault on error.

Definition at line 226 of file class.ilBMFClient.php.

{
if (in_array($encoding, $this->_encodings)) {
$this->_encoding = $encoding;
return;
}
return $this->_raiseSoapFault('Invalid Encoding');
}
ilBMFClient::setOpt (   $category,
  $option,
  $value = null 
)

Sets an option to use with the transport layers.

For example: $soapclient->setOpt('curl', CURLOPT_VERBOSE, 1) to pass a specific option to curl if using an SSL connection.

public

Parameters
string$categoryCategory to which the option applies or option name.
string$optionAn option name if $category is a category name, an option value if $category is an option name.
string$valueAn option value if $category is a category name.

Definition at line 368 of file class.ilBMFClient.php.

{
if (!is_null($value)) {
if (!isset($this->__options[$category])) {
$this->__options[$category] = array();
}
$this->__options[$category][$option] = $value;
} else {
$this->__options[$category] = $option;
}
}

Field Documentation

ilBMFClient::$__endpointType = ''

Definition at line 112 of file class.ilBMFClient.php.

ilBMFClient::$__last_request = null

Definition at line 127 of file class.ilBMFClient.php.

Referenced by __getlastrequest().

ilBMFClient::$__last_response = null

Definition at line 128 of file class.ilBMFClient.php.

Referenced by __getlastresponse().

ilBMFClient::$__options = array('trace'=>0)

Definition at line 135 of file class.ilBMFClient.php.

ilBMFClient::$__proxy_params = array()

Definition at line 163 of file class.ilBMFClient.php.

ilBMFClient::$_encoding = SOAP_DEFAULT_ENCODING

Definition at line 142 of file class.ilBMFClient.php.

Referenced by call().

ilBMFClient::$_endpoint = ''

Definition at line 98 of file class.ilBMFClient.php.

ilBMFClient::$_portName = ''

Definition at line 105 of file class.ilBMFClient.php.

ilBMFClient::$_soap_transport = null

Definition at line 165 of file class.ilBMFClient.php.

Referenced by call().

ilBMFClient::$headersIn = null

Definition at line 156 of file class.ilBMFClient.php.

ilBMFClient::$headersOut = null

Definition at line 149 of file class.ilBMFClient.php.

ilBMFClient::$wire

Definition at line 126 of file class.ilBMFClient.php.

ilBMFClient::$xml

Definition at line 119 of file class.ilBMFClient.php.

Referenced by call().


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