2011-02-10 5 views
4

이 문제로 하루 종일 나를 죽였습니다. 비누 클라이언트, 기본 HTTP 인증을 사용하여 HTTPS를 통해 함수를 호출하는 방법

나는 웹 서비스에 연결하는 SoapUI를 사용하는 경우

는 모든 오류없이 완벽하게 작동합니다 .. // *이 .asmx WSDL, 기본 HTTP 인증을 :

나는 클라이언트 웹 서비스 HTTPS를 무엇이든지 .. (내가 PHP를 사용하고 내가 관리

내가 PHP로 전환하면 문제는 ...에 연결하고, 내가 PHP를위한 soapclient 확장을 사용하여 서버에서 기능 목록을 얻을 수 있습니다 5.3.0).

나는 다음과 같은 오류 얻을 PHP의 soapclient 확장을 사용하여 함수를 호출 할 때 (내가 호출 결과의 인 print_r을 수행 할 때)

Fatal error: Uncaught SoapFault exception: [HTTP] Error Fetching http headers in C:\www\xpto_Atestes\soapclient.php:26 Stack trace: #0 [internal function]: >SoapClient->__doRequest('***...', 'http://****...', 1, 0) #1 >C:\www\xpto_Atestes\soapclient.php(26): SoapClient->__soapCall('login', Array) #2 {main} >thrown in C:\www\xpto_Atestes\soapclient.php on line 26

더 명확한 오류 :

을 다음 헤더와

[faultstring] => Error Fetching http headers
[faultcode] => HTTP

가 전송되는 :

POST /*.asmx HTTP/1.1 Host: *.pt Connection: Keep-Alive User-Agent: >PHP-SOAP/5.3.0 Content-Type: text/xml; charset=utf-8 SOAPAction: "http://**/Login" >Content-Length: 264 Authorization: Basic AUTHSECRETPASS

내가 이런 식으로 호출하고 있습니다 :

Error

HTTP Error: socket read of headers timed out

Request

POST /**.asmx HTTP/1.0 Host: *.pt User-Agent: NuSOAP/0.9.5 (1.123) Content-Type: text/xml; charset=ISO-8859-1 SOAPAction: "http://****/Login" Authorization: Basic AUTHSECRETPASS Content-Length: 481

NUMBERPASSWORD

Response

내가 전화 해요 :

$soapParams = array('login' => 'HTTP_LOGIN',
'password' => 'HTTP_PASS',
'authentication' => SOAP_AUTHENTICATION_BASIC,
'trace' => 1,
'exceptions' => 0
);
$client = new SoapClient("https://****.asmx?WSDL", $soapParams); echo "Connected
"; $params = array('account' => '', 'msisdn'=>'NUMBER', 'password'=>'PASSWORD'); $result = $client->__soapCall("login", $params);

동안은 인터넷 검색을하고 문제가 될 수 있는지 알아 내려고 후, 나는 ... 내 불행에 또한 오류가 준 nusoap로 전환 같은 :

: nusoap와

$client = new nusoap_client("https://**.asmx?WSDL", true);
$client->setCredentials('HTTPUSER','HTTPPASS','basic');
$params = array( 'account' => '', 'msisdn'=>'NUMBER', 'password'=>'PASSWORD' );
$result = $client->call('Login', $params);

나는 또한 통화를 할 수 컬 확장을 사용 가능하게하려고 나는 내가 '돈 문제없이 SoapUI에서 호출 할 수 있다면 아무것도는 웹 서비스에 이상이 없다고 100 % 확신

HTTP Error: cURL ERROR: 56: Failure when receiving data from the peer url: http://*********.asmx
content_type:
http_code: 0
header_size: 0
request_size: 750
filetime: -1
ssl_verify_result: 0
redirect_count: 0
total_time: 21.015
namelookup_time: 0
connect_time: 0
pretransfer_time: 0
size_upload: 462
size_download: 0
speed_download: 0
speed_upload: 21
download_content_length: -1
upload_content_length: -1
starttransfer_time: 0
redirect_time: 0

:

하지만 그런 행운, 그것은 오류를주는 유지 PHP에서 호출 할 수없는 이유를 확인하십시오.

I 집회 ... 더 내가 .. 내가 모든 노력을 생각 할 수있는 것을 모르는

편집 : 난 그냥 .. PHP, 젠드에서이 시간 동안 다른 비누 클래스를 시도

결과는 다음과 같습니다.

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://**.asmx?WSDL' : failed to load external entity "https://*.asmx?WSDL" in C:\www\xpto_Atestes\Zend\Soap\Client\Common.php:51 Stack trace:
#0 C:\www\xpto_Atestes\Zend\Soap\Client\Common.php(51): SoapClient->SoapClient('https://**...', Array)
#1 C:\www****_Atestes\Zend\Soap\Client.php(1032): Zend_Soap_Client_Common->__construct(Array, 'https://**...', Array)
#2 C:\www****_Atestes\Zend\Soap\Client.php(1188): Zend_Soap_Client->_initSoapClientObject()
#3 C:\www***_Atestes\Zend\Soap\Client.php(1112): Zend_Soap_Client->getSoapClient() #4 [internal function]: Zend_Soap_Client->__call('Login', Array)
#5 C:\www****_Atestes\zend.php(28): Zend_Soap_Client->Login(Array)
#6 {main} thrown in

+0

안녕하세요 티오 내가 정확히 같은 문제 (성공없이 젠드와 NuSoap로 시도), 가 관리 했 한 는 작동 얻으려면? 감사합니다. Yv. –

+0

@yjusot .. 글쎄, 웹 서비스의 WSDL 인 NuSoap을 사용하여 문제를 해결할 수있었습니다. 다양한 필드에 접두사가 필요했고 NuSoap은 이들을 넣지 않았습니다. 그래서 NuSoap에서 코드를 변경하여 접두사를 필드에 넣지 만 $ client-> send 메서드를 사용하는 것이 좋습니다.이 메서드에서는 매개 변수로 요청 XML을 전달합니다. 이렇게하면 아무 것도 변경할 필요가 없습니다. 예를 들어 뭔가가 필요하다면 .. – Tio

+0

해결 방법/솔루션에 대해 좀 더 자세히 설명해 주시겠습니까? 즉 접두어는 무엇입니까? –

답변

2

누구나 내가 그 문제를 어떻게 해결했는지 알고 싶을 뿐이니까.내가 접두사를 언급 할 때, 나는 ns123 부분에 말하는 겁니다

<?xml version="1.0" encoding="utf-8" ?> 
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> 
    <SOAP-ENV:Body> 
     <ns123:IsTokenValid xmlns:ns123="http://www.xxxxxxx.com"> 
      <ns123:token xsi:type="xsd:string">'.$this->loginToken.'</ns123:token> 
     </ns123:IsTokenValid> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

:

문제는 다음의 웹 서비스 중 하나에 대한 요청 XML이 형식으로해야했다. 문제는 라이브러리가 서버에 보낼 올바른 XML을 생성 한 것이 아니라 접두어를 절대 두지 않으므로 요청이 전혀 작동하지 않는다는 것입니다.

$nsValue = rand(1000, 9000); 
$requestXml = '<?xml version="1.0" encoding="utf-8" ?> 
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> 
<SOAP-ENV:Body> 
<ns'.$nsValue.':IsTokenValid xmlns:ns'.$nsValue.'="http://www.xxxxxxx.com"> 
<ns'.$nsValue.':token xsi:type="xsd:string">'.$this->loginToken.'</ns'.$nsValue.':token> 
</ns'.$nsValue.':IsTokenValid> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope>'; 
$result = WebService::CallWebService($this->endPoint, 'http://www.xxxxxxx.com/IsTokenValid', $requestXml, $this->httpUser, $this->httpPass); 
:

내가 먼저 마녀는 다음 코드 결과는 NuSoap 클래스로 직접 이동하여, 그것을 해결 한 클래스의 코드를 변경,하지만 난 NuSoap 내 자신의 요청 XML을 만들 수 발견 ,

$client = new nusoap_client($webServiceLink, false); 
$result = $client->send($request, $soapAction, '', self::$timeout, self::$responseTimeout); 

이안과 다른 사람이 분명하다 희망 :

WebService에는 :: CallWebService는이 같은 무언가를 (그리고 오류 처리 등의 설정 HTTP 인증이) NuSoap 클래스에 대한 래퍼입니다.