function send($request) { if (!$this->UseSSL || !in_array("curl", get_loaded_extensions())) { if ($this->Timeout != 0) { $fp = fsockopen($this->Server, $this->Port, $this->errorNumber, $this->errorString, $this->Timeout); } else { $fp = fsockopen($this->Server, $this->Port, $this->errorNumber, $this->errorString); } if ($fp == 0) { $this->ErrorString = '<b>Error:</b> eZSOAPClient::send() : Unable to open connection to ' . $this->Server . '.'; return 0; } $payload = $request->payload(); $authentification = ""; if ($this->login() != "") { $authentification = "Authorization: Basic " . base64_encode($this->login() . ":" . $this->password()) . "\r\n"; } $HTTPRequest = "POST " . $this->Path . " HTTP/1.0\r\n" . "User-Agent: eZ soap client\r\n" . "Host: " . $this->Server . ":" . $this->Port . "\r\n" . $authentification . "Content-Type: text/xml\r\n" . "SOAPAction: \"" . $request->ns() . '/' . $request->name() . "\"\r\n" . "Content-Length: " . strlen($payload) . "\r\n\r\n" . $payload; if (!fputs($fp, $HTTPRequest, strlen($HTTPRequest))) { $this->ErrorString = "<b>Error:</b> could not send the SOAP request. Could not write to the socket."; $response = 0; return $response; } $rawResponse = ""; // fetch the SOAP response while ($data = fread($fp, 32768)) { $rawResponse .= $data; } // close the socket fclose($fp); } else { if ($request instanceof eZSOAPRequest) { $URL = "https://" . $this->Server . ":" . $this->Port . $this->Path; $ch = curl_init($URL); if ($this->Timeout != 0) { curl_setopt($ch, CURLOPT_TIMEOUT, $this->Timeout); } $payload = $request->payload(); if ($ch != 0) { $HTTPCall = "POST " . $this->Path . " HTTP/1.0\r\n" . "User-Agent: eZ soap client\r\n" . "Host: " . $this->Server . ":" . $this->Port . "\r\n" . "Content-Type: text/xml\r\n" . "SOAPAction: \"" . $request->ns() . '/' . $request->name() . "\"\r\n" . "Content-Length: " . strlen($payload) . "\r\n"; if ($this->login() != '') { $HTTPCall .= "Authorization: Basic " . base64_encode($this->login() . ":" . $this->Password()) . "\r\n"; } $HTTPCall .= "\r\n" . $payload; curl_setopt($ch, CURLOPT_URL, $URL); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $HTTPCall); // Don't use CURLOPT_CUSTOMREQUEST without making sure your server supports the custom request method first. unset($rawResponse); if ($ch != 0) { $rawResponse = curl_exec($ch); } if (!$rawResponse) { $this->ErrorString = "<b>Error:</b> could not send the XML-SOAP with SSL call. Could not write to the socket."; $response = 0; return $response; } } curl_close($ch); } } $response = new eZSOAPResponse(); $response->decodeStream($request, $rawResponse); return $response; }