25 require_once dirname(__FILE__).
'/class.ilBMFValue.php';
26 require_once dirname(__FILE__).
'/class.ilBMFBase.php';
27 require_once dirname(__FILE__).
'/class.ilBMFTransport.php';
28 require_once dirname(__FILE__).
'/class.ilBMFWSDL.php';
29 require_once dirname(__FILE__).
'/class.ilBMFFault.php';
30 require_once dirname(__FILE__).
'/class.ilBMFParser.php';
38 if (!class_exists(
'ilBMFClient_Overload')) {
39 if (substr(phpversion(), 0, 1) == 5) {
41 function __call($method, $args)
44 $this->_call($method, $args, $return);
49 if (!function_exists(
'clone')) {
50 eval(
'function clone($t) { return $t; }');
53 class ilBMFClient_Overload extends ilBMFBase {
54 function __call($method, $args, &$return)
56 return $this->_call($method, $args, $return);
179 $proxy_params = array())
181 parent::ilBMFBase(
'Client');
183 $this->_endpoint = $endpoint;
184 $this->_portName = $portName;
185 $this->__proxy_params = $proxy_params;
191 : strtolower(substr($endpoint, -4)) ==
'wsdl';
195 $this->__endpointType =
'wsdl';
197 $this->_wsdl =&
new ilBMFWSDL($this->_endpoint,
198 $this->__proxy_params);
199 if ($this->_wsdl->fault) {
200 $this->_raiseSoapFault($this->_wsdl->fault);
209 $this->__last_request = null;
210 $this->__last_response = null;
211 $this->headersIn = null;
212 $this->headersOut = null;
228 if (in_array($encoding, $this->_encodings)) {
229 $this->_encoding = $encoding;
232 return $this->_raiseSoapFault(
'Invalid Encoding');
248 if (is_a($soap_value,
'ilBMFHeader')) {
249 $this->headersOut[] =& $soap_value;
250 } elseif (is_array($soap_value)) {
252 $this->headersOut[] =&
new ilBMFHeader($soap_value[0],
258 $this->_raiseSoapFault(
'Invalid parameter provided to addHeader(). Must be an array or a SOAP_Header.');
292 $this->headersIn = null;
293 $this->__last_request = null;
294 $this->__last_response = null;
300 $fault =& $this->_raiseSoapFault($soap_data);
309 if (!$this->_soap_transport ||
310 $this->_endpoint != $this->_soap_transport->url) {
314 $this->_soap_transport = null;
315 $fault =& $this->_raiseSoapFault($fault);
322 $transport_options = array_merge_recursive($this->__proxy_params,
324 $this->xml = $this->_soap_transport->send($soap_data, $transport_options);
327 if ($this->__options[
'trace'] > 0) {
328 $this->__last_request =& $this->_soap_transport->outgoing_payload;
329 $this->__last_response =& $this->_soap_transport->incoming_payload;
332 if ($this->_soap_transport->fault) {
333 $fault =& $this->_raiseSoapFault($this->xml);
337 $this->__attachments =& $this->_soap_transport->attachments;
338 $this->__result_encoding = $this->_soap_transport->result_encoding;
340 if (isset($this->__options[
'result']) &&
341 $this->__options[
'result'] !=
'parse') {
345 $result = &$this->
__parse($this->xml, $this->__result_encoding, $this->__attachments);
368 function setOpt($category, $option, $value = null)
370 if (!is_null($value)) {
371 if (!isset($this->__options[$category])) {
372 $this->__options[$category] = array();
374 $this->__options[$category][$option] = $value;
376 $this->__options[$category] = $option;
399 function _call($method, $params, &$return_value)
405 $this->_wsdl->matchMethod($method);
408 $return_value =& $this->
call($method, $params);
427 $this->__options[
'use'] = $use;
432 $this->__options[
'style'] = $style;
437 $this->__options[
'trace'] = $level;
444 $this->__options[
'input']=
'parse';
445 $this->__options[
'result']=
'parse';
446 $this->__options[
'parameters'] =
false;
448 if ($params && gettype($params) !=
'array') {
449 $params = array($params);
454 $this->__options[strtolower($optname)] = $opt;
456 if (isset($this->__options[
'namespace'])) {
464 $this->__options[
'soapaction'] = $soapAction;
468 if ($this->__endpointType ==
'wsdl') {
469 $this->_setSchemaVersion($this->_wsdl->xsd);
472 if (!$this->_portName) {
473 $this->_portName = $this->_wsdl->getPortName($method);
476 $fault =& $this->_raiseSoapFault($this->_portName);
481 $this->_endpoint = $this->_wsdl->getEndpoint($this->_portName);
483 $fault =& $this->_raiseSoapFault($this->_endpoint);
488 $opData = $this->_wsdl->getOperationData($this->_portName, $method);
491 $fault =& $this->_raiseSoapFault($opData);
495 $this->__options[
'style'] = $opData[
'style'];
496 $this->__options[
'use'] = $opData[
'input'][
'use'];
497 $this->__options[
'soapaction'] = $opData[
'soapAction'];
500 if ($this->__options[
'input'] ==
'parse') {
501 $this->__options[
'parameters'] = $opData[
'parameters'];
503 if (isset($opData[
'input'][
'parts']) &&
504 count($opData[
'input'][
'parts'])) {
506 foreach ($opData[
'input'][
'parts'] as $name => $part) {
510 if (isset($part[
'element'])) {
511 $xmlns = $this->_wsdl->namespaces[$part[
'namespace']];
512 $part = $this->_wsdl->elements[$part[
'namespace']][$part[
'type']];
513 $name = $part[
'name'];
515 if (isset($params[$name]) ||
516 $this->_wsdl->getDataHandler($name, $part[
'namespace'])) {
517 $nparams[$name] =& $params[$name];
521 $fault =& $this->_raiseSoapFault(
"The named parameter $name is not in the call parameters.");
524 if (gettype($nparams[$name]) !=
'object' ||
525 !is_a($nparams[$name],
'ilBMFValue')) {
528 $qname =&
new QName($part[
'type']);
530 $type_namespace = $this->_wsdl->namespaces[$qname->ns];
531 } elseif (isset($part[
'namespace'])) {
532 $type_namespace = $this->_wsdl->namespaces[$part[
'namespace']];
534 $type_namespace = null;
536 $qname->namespace = $type_namespace;
537 $type = $qname->name;
540 $pqname =
'{' . $xmlns .
'}' . $name;
559 $this->_section5 = (!isset($this->__options[
'use']) ||
560 $this->__options[
'use'] !=
'literal');
562 if (!isset($this->__options[
'style']) ||
563 $this->__options[
'style'] ==
'rpc') {
564 $this->__options[
'style'] =
'rpc';
565 $this->docparams =
true;
567 $methodValue =&
new ilBMFValue($mqname->fqn(),
'Struct', $params);
568 $soap_msg = $this->_makeEnvelope($methodValue,
576 $params =&
new ilBMFValue($mqname->fqn(),
'Struct', $mynull);
577 } elseif ($this->__options[
'input'] ==
'parse') {
578 if (is_array($params)) {
580 $keys = array_keys($params);
581 foreach ($keys as $k) {
582 if (gettype($params[$k]) !=
'object') {
587 $nparams[] =& $params[$k];
592 if ($this->__options[
'parameters']) {
599 $soap_msg = $this->_makeEnvelope($params,
604 unset($this->headersOut);
607 $fault =& $this->_raiseSoapFault($soap_msg);
614 if (count($this->__attachments)) {
615 if ((isset($this->__options[
'attachments']) &&
616 $this->__options[
'attachments'] ==
'Mime') ||
617 isset($this->__options[
'Mime'])) {
618 $soap_msg =& $this->_makeMimeMessage($soap_msg,
622 $soap_msg =& $this->_makeDIMEMessage($soap_msg,
624 $this->__options[
'headers'][
'Content-Type'] =
'application/dime';
627 $fault =& $this->_raiseSoapFault($soap_msg);
633 if (is_array($soap_msg)) {
634 $soap_data =& $soap_msg[
'body'];
635 if (count($soap_msg[
'headers'])) {
636 if (isset($this->__options[
'headers'])) {
637 $this->__options[
'headers'] = array_merge($this->__options[
'headers'], $soap_msg[
'headers']);
639 $this->__options[
'headers'] = $soap_msg[
'headers'];
643 $soap_data =& $soap_msg;
649 function &
__parse(&$response, $encoding, &$attachments)
652 $response =&
new ilBMFParser($response, $encoding, $attachments);
653 if ($response->fault) {
654 $fault =& $this->_raiseSoapFault($response->fault);
659 $return =& $response->getResponse();
660 $headers =& $response->getHeaders();
678 $fault =& $this->_raiseSoapFault($response);
680 } elseif (!is_a($response,
'ilbmfvalue')) {
681 $fault =& $this->_raiseSoapFault(
"Didn't get ilBMFValue object back from client");
686 $returnArray =& $this->_decode($response);
690 $fault =& $this->_raiseSoapFault($returnArray);
694 if (is_object($returnArray) &&
695 strcasecmp(get_class($returnArray),
'stdClass') == 0) {
696 $returnArray = get_object_vars($returnArray);
698 if (is_array($returnArray)) {
699 if (isset($returnArray[
'faultcode']) ||
700 isset($returnArray[
'SOAP-ENV:faultcode'])) {
701 $faultcode = $faultstring = $faultdetail = $faultactor =
'';
702 foreach ($returnArray as $k => $v) {
703 if (stristr($k,
'faultcode')) $faultcode = $v;
704 if (stristr($k,
'faultstring')) $faultstring = $v;
705 if (stristr($k,
'detail')) $faultdetail = $v;
706 if (stristr($k,
'faultactor')) $faultactor = $v;
708 $fault =& $this->_raiseSoapFault($faultstring, $faultdetail, $faultactor, $faultcode);
712 if ($shift && count($returnArray) == 1) {
713 $decoded = array_shift($returnArray);
723 if ($this->__options[
'trace'] > 0 &&
724 ($this->__last_request || $this->__last_response)) {
725 return "OUTGOING:\n\n" .
726 $this->__last_request .
728 preg_replace(
"/></",
">\r\n<", $this->__last_response);