ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
Client.php
Go to the documentation of this file.
1 <?php
2 
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
4 
5 // LICENSE AGREEMENT. If folded, press za here to unfold and read license {{{
6 
40 // }}}
41 
42 // dependencies {{{
43 require_once 'XML/RPC2/Exception.php';
44 require_once 'XML/RPC2/Client.php';
45 require_once 'XML/RPC2/Util/HTTPRequest.php';
46 //}}}
47 
59 {
60 
61  // {{{ constructor
62 
72  public function __construct($uri, $options = array())
73  {
74  parent::__construct($uri, $options);
75  }
76 
77  // }}}
78  // {{{ remoteCall()
79 
89  public function remoteCall___($methodName, $parameters)
90  {
91  $tmp = xmlrpc_encode_request($this->prefix . $methodName, $parameters, array('encoding' => $this->encoding));
92  if ($this->uglyStructHack) {
93  // ugly hack because of http://bugs.php.net/bug.php?id=21949
94  // see XML_RPC2_Backend_Xmlrpcext_Value::createFromNative() from more infos
95  $request = preg_replace('~<name>xml_rpc2_ugly_struct_hack_(.*)</name>~', '<name>\1</name>', $tmp);
96  } else {
97  $request = $tmp;
98  }
99  $uri = $this->uri;
100  $options = array(
101  'encoding' => $this->encoding,
102  'proxy' => $this->proxy,
103  'sslverify' => $this->sslverify
104  );
105  $httpRequest = new XML_RPC2_Util_HTTPRequest($uri, $options);
106  $httpRequest->setPostData($request);
107  $httpRequest->sendRequest();
108  $body = $httpRequest->getBody();
109  if ($this->debug) {
110  $this->displayDebugInformations___($request, $body);
111  }
112  $result = xmlrpc_decode($body, $this->encoding);
113  /* Commented due to change in behaviour from xmlrpc_decode. It does not return faults now
114  if ($result === false || is_null($result)) {
115  if ($this->debug) {
116  print "XML_RPC2_Exception : unable to decode response !";
117  }
118  throw new XML_RPC2_Exception('Unable to decode response');
119  }
120  */
121  if (xmlrpc_is_fault($result)) {
122  if ($this->debug) {
123  print "XML_RPC2_FaultException(${result['faultString']}, ${result['faultCode']})";
124  }
125  throw new XML_RPC2_FaultException($result['faultString'], $result['faultCode']);
126  }
127  if ($this->debug) {
128  $this->displayDebugInformations2___($result);
129  }
130  return $result;
131  }
132 
133  // }}}
134 
135 }
136 
137 ?>