【发布时间】:2014-02-13 09:55:18
【问题描述】:
我尝试连接的 SOAP 服务器存在身份验证问题。
我需要使用这个地址来检索 wsdl 信息
https://profitweb.afasonline.nl/profitservices/updateconnector.asmx?wsdl
当我在浏览器中输入此地址时,系统会询问用户名和密码。填写我的用户名和密码,就会显示 WSLD XML。
所以,我正在使用这种和平的 PHP 代码
$wsdl = "https://profitweb.afasonline.nl/profitservices/updateconnector.asmx?wsdl";
$url = "https://profitweb.afasonline.nl/profitservices/updateconnector.asmx";
$login = 'username';
$password = 'password';
$client = new SoapClient( $wsdl, array('login' => $login, 'password' => $password));
然后我收到以下错误:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://profitweb.afasonline.nl/profitservices/updateconnector.asmx?wsdl' : failed to load external entity "https://profitweb.afasonline.nl/profitservices/updateconnector.asmx?wsdl" in C:\xampp\htdocs\test.nl\soap.php:8 Stack trace: #0 C:\xampp\htdocs\test.nl\soap.php(8): SoapClient->SoapClient('https://profitw...', Array) #1 {main} thrown in C:\xampp\htdocs\test.nl\soap.php on line 8
这看起来不像是身份验证错误。但是,如果我手动下载 wsdl 文件,将其保存在本地,然后使用该文件创建 new SoapClient,则在初始化 SoapClient 时不会出现任何错误。
但是如果我再做一个请求
$client->__doRequest($request, $url, 'Execute', '1');
我收到了这个 __getLastResponseHeaders
HTTP/1.1 401 Unauthorized ( The server requires authorization to fulfill the request. Access to the Web server is denied. Contact the server administrator. ) WWW-Authenticate: Negotiate WWW-Authenticate: Kerberos WWW-Authenticate: NTLM Connection: Keep-Alive Pragma: no-cache Cache-Control: no-cache Content-Type: text/html Content-Length: 3184
所以这让我觉得我遇到了身份验证问题!已经阅读了很多关于这个问题的帖子,但找不到正确的答案!
编辑 将此添加到选项中
'trace' => 1, 'exceptions' => 0
确实给我一个身份验证错误。
Warning: SoapClient::SoapClient(https://profitweb.afasonline.nl/profitservices/updateconnector.asmx?wsdl): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized ( The server requires authorization to fulfill the request. Access to the Web server is denied. Cont in C:\xampp\htdocs\test.nl\soap.php on line 9
【问题讨论】:
-
尝试将链接作为 http 而不是 https
-
@MDroid,使用该链接时出现同样的错误!
-
遇到了同样的问题...
标签: php authentication soap afas-online