php - SOAP 身份验证问题

标签 php authentication soap afas-online

我在尝试连接到的 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/

相关文章:

java - 由于 TLS 不兼容,SOAP Web 服务不接受请求

php - 使用 PHP 变量将多个参数传递给 AJAX JQuery

php - 如何在 yii 中创建自定义自动完成文本字段

mongodb - 与 Mongos 连接时 system.profile 集合中缺少用户字段

java - JAAS登录模块中的用户主体-额外的属性是单独的主体还是Bean属性?

java - SOAP 中的 UDDI 示例

java - 如何使用ajax、json中返回的数组

php - 如何在 Wordpress Elementor 脚本完全加载后运行我的脚本?

session - 如何在没有 session 但在 AJAX 中使用 token 的情况下进行身份验证

c# - 使用 WCF 在客户端中获取签名的 SOAP 消息