2014-10-07 6 views
0

정말로 도움을 주시면 감사하겠습니다. 나는이 문제에 아무데도 못 가고있다. 나는 SoapClient을 확장하려고 할 때헤더없이 PHP curl 요청을 보내고 있습니다.

코드 이제

$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(); 

내가 다시 비누 호출하고 위의 코드 출력에서 ​​적절한 데이터를 얻을

...

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 

을하고있다 여기 시작하려면 재시도 및 시간 초과를 추가하려면

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(); 

나는 모두 오류가 발생하며 다른 정보는 전혀 없습니다. 그래서 나는이 같은 결과로 SoapClient ... 모두를 확장하는 두 개의 제 3의 라이브러리 시도했다 :

https://github.com/ideaconnect/idct-soap-client/blob/master/src/client.php

https://gist.github.com/RobThree/2490351

내 현재 코드는 다음과 같다 :

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); 
} 

그리고 옵션 배열에서 헤더 선언을 가져와 시도했습니다.

curl_setopt($curl, CURLOPT_HTTPHEADER, $header); 

curl_setopt_array() .... no luck 이후.

아이디어가 있으십니까? 나는 무슨 일이 벌어지고 있는지 전혀 모른다.

답변

0

curl을 사용하면 parent :: __ doRequest를 사용하지 않으므로 soapClient가 요청을 추적 할 수 없습니다.

SoapClient가 요청 시간 제한을 설정할 수 없다고 생각하기 때문에 코드를 사용하면 말려 진 느낌이납니다. 맞지 않습니다.

http://php.net/manual/en/soapclient.soapclient.php

The connection_timeout option defines a timeout in seconds for the connection to the SOAP service. This option does not define a timeout for services with slow responses. To limit the time to wait for calls to finish the default_socket_timeout setting is available.

관련 문제