我在尝试连接到的 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 文件,将其保存在本地,然后使用该文件创建一个新的 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
最佳答案
AFAS 仍然使用 NuSOAP (4.x) 而不是 SOAP (5.x)。我正在使用可以在 Github 上找到的 noiselabs/nusoap-bundle 来自己访问 AFAS。
关于php - SOAP 身份验证问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21750734/