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/Util/HTTPRequest.php';
45 require_once 'XML/RPC2/Value.php';
46 require_once 'XML/RPC2/Client.php';
47 require_once 'XML/RPC2/Backend/Php/Request.php';
48 require_once 'XML/RPC2/Backend/Php/Response.php';
49 // }}}
50 
65 {
66 
67  // {{{ constructor
68 
78  public function __construct($uri, $options = array())
79  {
80  parent::__construct($uri, $options);
81  }
82 
83  // }}}
84  // {{{ remoteCall___()
85 
95  public function remoteCall___($methodName, $parameters)
96  {
97  $request = new XML_RPC2_Backend_Php_Request($this->prefix . $methodName, $this->encoding);
98  $request->setParameters($parameters);
99  $request = $request->encode();
100  $uri = $this->uri;
101  $options = array(
102  'encoding' => $this->encoding,
103  'proxy' => $this->proxy,
104  'sslverify' => $this->sslverify
105  );
106  $httpRequest = new XML_RPC2_Util_HTTPRequest($uri, $options);
107  $httpRequest->setPostData($request);
108  $httpRequest->sendRequest();
109  $body = $httpRequest->getBody();
110  if ($this->debug) {
111  $this->displayDebugInformations___($request, $body);
112  }
113  try {
114  $result = XML_RPC2_Backend_Php_Response::decode(simplexml_load_string($body));
115  } catch (XML_RPC2_Exception $e) {
116  if ($this->debug) {
117  if (get_class($e)=='XML_RPC2_FaultException') {
118  print "XML_RPC2_FaultException #" . $e->getFaultCode() . " : " . $e->getMessage();
119  } else {
120  print get_class($e) . " : " . $e->getMessage();
121  }
122  }
123  throw $e;
124  }
125  if ($this->debug) {
126  $this->displayDebugInformations2___($result);
127  }
128  return $result;
129  }
130 
131  // }}}
132 
133 }
134 
135 ?>