$client = new SoapClient("/var/www/$schema/$space.wsdl", array('trace' => 1));
try {
$result = $client->$service($request);
}
catch (SoapFault $soapFault) {
//print_r($soapFault);
echo "ERROR: ". $client->__getLastRequestHeaders ();
exit();
}
echo "SUCCESS: ". $client->__getLastRequestHeaders ();
exit();
< /code>
Я получаю соответствующие данные обратно от вызова SOAP и приведенные выше выходы кода: < /p>
SUCCESS: POST /server/ws/r/customer HTTP/1.1
Host: soap.server.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.3.3
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Content-Length: 287
< /code>
Теперь, когда я пытаюсь расширить SoapClient (чтобы добавить повторение и тайм -ауты): < /p>
include_once("/var/www/object/soapTest.php");
$client = new SoapTest("/var/www/$schema/$space.wsdl", array('trace' => 1,'timeout' => $timeout_length,'connecttimeout' => $timeout_length));
try {
$result = $client->$service($request);
}
catch (SoapFault $soapFault) {
//print_r($soapFault);
echo "ERROR: ". $client->__getLastRequestHeaders ();
exit();
}
echo "SUCCESS: ". $client->__getLastRequestHeaders ();
exit();
< /code>
Все, что я получаю, это ошибка: и никакой другой информации вообще. Итак, я попробовал две сторонние библиотеки, чтобы расширить мыльный клиент ... оба с одним и тем же результатом:
https://github.com/ideaconnect/idct-soap-client/blob /master/src/client.php
https://gist.github.com/robthree/2490351
Мой текущий код следующим образом: < /p>
public function __doRequest($request, $location, $action, $version, $one_way = FALSE)
{
if (($this->timeout===0) && ($this->connecttimeout===0))
{
// Call via parent because we require no timeout
$response = parent::__doRequest($request, $location, $action, $version, $one_way);
}
else
{
// Call via Curl and use the timeout
$curl = curl_init($location);
if ($curl === false)
throw new Exception('Curl initialisation failed');
$header = array("Content-Type:text/xml;charset=utf-8","User-Agent:PHP-SOAP/5.3.3","SOAPAction:\"".$action."\"");
$options = array(
CURLOPT_VERBOSE => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $request,
CURLOPT_HEADER => true,
CURLOPT_NOSIGNAL => false
CURLOPT_HTTPHEADER => $header
//CURLOPT_SSL_VERIFYPEER => $this->sslverifypeer
);
//print_r($options);
//exit();
if ($this->timeout>0) {
if (defined('CURLOPT_TIMEOUT_MS')) { //Timeout in MS supported?
$options[CURLOPT_TIMEOUT_MS] = $this->timeout;
} else { //Round(up) to second precision
$options[CURLOPT_TIMEOUT] = ceil($this->timeout/1000);
}
}
if ($this->connecttimeout>0) {
if (defined('CURLOPT_CONNECTTIMEOUT_MS')) { //ConnectTimeout in MS supported?
$options[CURLOPT_CONNECTTIMEOUT_MS] = $this->connecttimeout;
} else { //Round(up) to second precision
$options[CURLOPT_CONNECTTIMEOUT] = ceil($this->connecttimeout/1000);
}
}
if (curl_setopt_array($curl, $options) === false)
throw new Exception('Failed setting CURL options');
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
$response = curl_exec($curl);
if (curl_errno($curl)){
throw new Exception(curl_error($curl));
}
curl_close($curl);
}
// Return?
if (!$one_way)
return ($response);
}
< /code>
И я также попытался вытащить объявление заголовка из массива параметров и сделать это с: < /p>
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
после curl_setopt_array () .... Не повезло.
Как это разрешить?
Чтобы начать, здесь есть рабочий код: < /p> [code]$client = new SoapClient("/var/www/$schema/$space.wsdl", array('trace' => 1)); try { $result = $client->$service($request); } catch (SoapFault $soapFault) { //print_r($soapFault); echo "ERROR: ". $client->__getLastRequestHeaders (); exit(); } echo "SUCCESS: ". $client->__getLastRequestHeaders (); exit(); < /code> Я получаю соответствующие данные обратно от вызова SOAP и приведенные выше выходы кода: < /p> SUCCESS: POST /server/ws/r/customer HTTP/1.1 Host: soap.server.com Connection: Keep-Alive User-Agent: PHP-SOAP/5.3.3 Content-Type: text/xml; charset=utf-8 SOAPAction: "" Content-Length: 287 < /code> Теперь, когда я пытаюсь расширить SoapClient (чтобы добавить повторение и тайм -ауты): < /p> include_once("/var/www/object/soapTest.php"); $client = new SoapTest("/var/www/$schema/$space.wsdl", array('trace' => 1,'timeout' => $timeout_length,'connecttimeout' => $timeout_length)); try { $result = $client->$service($request); } catch (SoapFault $soapFault) { //print_r($soapFault); echo "ERROR: ". $client->__getLastRequestHeaders (); exit(); } echo "SUCCESS: ". $client->__getLastRequestHeaders (); exit(); < /code> Все, что я получаю, это ошибка: и никакой другой информации вообще. Итак, я попробовал две сторонние библиотеки, чтобы расширить мыльный клиент ... оба с одним и тем же результатом: https://github.com/ideaconnect/idct-soap-client/blob /master/src/client.php https://gist.github.com/robthree/2490351 Мой текущий код следующим образом: < /p> public function __doRequest($request, $location, $action, $version, $one_way = FALSE) { if (($this->timeout===0) && ($this->connecttimeout===0)) { // Call via parent because we require no timeout $response = parent::__doRequest($request, $location, $action, $version, $one_way); } else { // Call via Curl and use the timeout $curl = curl_init($location); if ($curl === false) throw new Exception('Curl initialisation failed');
if ($this->timeout>0) { if (defined('CURLOPT_TIMEOUT_MS')) { //Timeout in MS supported? $options[CURLOPT_TIMEOUT_MS] = $this->timeout; } else { //Round(up) to second precision $options[CURLOPT_TIMEOUT] = ceil($this->timeout/1000); } }
if ($this->connecttimeout>0) { if (defined('CURLOPT_CONNECTTIMEOUT_MS')) { //ConnectTimeout in MS supported? $options[CURLOPT_CONNECTTIMEOUT_MS] = $this->connecttimeout; } else { //Round(up) to second precision $options[CURLOPT_CONNECTTIMEOUT] = ceil($this->connecttimeout/1000); } }
if (curl_setopt_array($curl, $options) === false) throw new Exception('Failed setting CURL options');
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
$response = curl_exec($curl); if (curl_errno($curl)){ throw new Exception(curl_error($curl)); } curl_close($curl); }
// Return? if (!$one_way) return ($response); } < /code> И я также попытался вытащить объявление заголовка из массива параметров и сделать это с: < /p> curl_setopt($curl, CURLOPT_HTTPHEADER, $header); [/code] после curl_setopt_array () .... Не повезло. Как это разрешить?