public function __call($method, $param)
 {
     if (PhpWsdl::$Debugging) {
         PhpWsdl::Debug('Proxy call method ' . $method . ': ' . print_r($param, true));
     }
     PhpWsdl::$ProxyServer->CreateWsdl();
     $m = PhpWsdl::$ProxyServer->GetMethod($method);
     if (is_null($m)) {
         throw new SoapFault('MissingMethod', 'Method "' . $method . '" not found');
     }
     // Try to fix the missing parameters issue if the SoapServer is not running in WSDL mode
     if (!PhpWsdl::$UseProxyWsdl) {
         $pLen = sizeof($m->Param);
         $temp = sizeof($param);
         if ($pLen != $temp) {
             PhpWsdl::Debug('Wrong parameter count (' . $temp . '/' . $pLen . ')');
             $req = new DOMDocument();
             if ($req->loadXml(file_get_contents('php://input'))) {
                 $x = new DOMXPath($req);
                 $temp = $param;
                 $param = array();
                 $pos = 0;
                 // Current index in the received parameter array
                 $i = -1;
                 while (++$i < $pLen) {
                     $p = $m->Param[$i];
                     if ($x->query("/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='" . $m->Name . "']/*[local-name()='" . $p->Name . "']")->length > 0) {
                         PhpWsdl::Debug('Parameter "' . $p->Name . '" was received');
                         $param[] = $temp[$pos];
                         $pos++;
                     } else {
                         PhpWsdl::Debug('Parameter "' . $p->Name . '" was missing');
                         $param[] = null;
                     }
                 }
             } else {
                 PhpWsdl::Debug('Could not parse SOAP request XML');
             }
         }
     }
     // Prepare the method call
     $call = $m->IsGlobal ? $method : array(is_null($m->Class) ? PhpWsdl::$ProxyObject : $m->Class, $method);
     // Call the target method
     PhpWsdl::Debug('Call the target method');
     $res = sizeof($param) < 1 ? call_user_func($call) : call_user_func_array($call, $param);
     // Return the encoded response
     $type = is_null($m->Return) ? null : $m->Return->Name;
     return PhpWsdl::$EncodeProxyReturn && !is_null($type) ? PhpWsdl::DoEncoding($type, $res, false, PhpWsdl::$ProxyServer) : $res;
 }
 /**
  * Do a SOAP request
  * 
  * @param string $method The method name
  * @param array $param The method parameters
  * @param array $options The call options (default: array)
  * @param array $requestHeaders The request headers (default: array)
  * @return mixed The server response
  */
 public function DoRequest($method, $param, $options = array(), $requestHeaders = array())
 {
     PhpWsdl::Debug('Sending request ' . $method);
     $options = array_merge($this->Options, $options);
     $requestHeaders = array_merge($this->RequestHeaders, $requestHeaders);
     $client = $this->GetClient();
     if ($this->EncodeParameters) {
         $server = $this->CreateServerFromWsdl();
         $m = $server->GetMethod($method);
         if (!is_null($m)) {
             PhpWsdl::Debug('Encode parameters');
             $temp = array();
             $i = -1;
             $len = sizeof($param);
             while (++$i < $len) {
                 $temp[] = PhpWsdl::DoEncoding($m->Param[$i]->Type, $param[$i], true, $server);
             }
             $param = $temp;
         } else {
             PhpWsdl::Debug('Can not encode parameters because the method was not found');
         }
     }
     $res = $client->__soapCall($method, $param, $options, $requestHeaders);
     if (is_soap_fault($res)) {
         PhpWsdl::Debug('SOAP error #' . $res->faultcode . ': ' . $res->faultstring);
     }
     if ($this->Debugging) {
         PhpWsdl::Debug('Parameters: ' . print_r($param, true));
         PhpWsdl::Debug('Options: ' . print_r($options, true));
         PhpWsdl::Debug('Headers: ' . print_r($requestHeaders, true));
         PhpWsdl::Debug('Result: ' . print_r($res, true));
         PhpWsdl::Debug('Request: ' . $client->__getLastRequest());
         PhpWsdl::Debug('Request headers: ' . $client->__getLastRequestHeaders());
         PhpWsdl::Debug('Response: ' . $client->__getLastResponse());
         PhpWsdl::Debug('Response headers: ' . $client->__getLastResponseHeaders());
     }
     return $res;
 }