【问题标题】:SOAP Authentication issueSOAP 身份验证问题
【发布时间】: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


【解决方案1】:

AFAS 仍然使用 NuSOAP (4.x) 而不是 SOAP (5.x)。我正在使用可以在 Github 上找到的 noiselabs/nusoap-bundle 自己访问 AFAS。

【讨论】:

    【解决方案2】:

    当你在 PHP 中使用 Afasonline Soap API 连接时,基本上你会遇到这些错误

    下面是一个如何连接和请求的例子

    注意:在连接之前,您首先需要了解有关 Afasonline API 的一些概念,因为您知道 Afasonline 使用 Nusoap 和 Windows NTLM 身份验证,因此为了连接,您需要 NTLM 的域名,如果 Afasonline 是“AOL”。您可以通过 Internet 搜索了解有关 NTLM 的更多信息。此外,您还需要以下参数才能连接 environmentId(总是以 OXXXXXXX 开头)、userId、Password、connectorID。

    我将展示一个带有 connectorID (SSS_werkgever_vacatures) 的 Getconnector 示例以获取所有作业,但所有连接器的身份验证方法都相同。

    Click here to see Tutorial in Detail

    <?php
    require_once('lib/nusoap.php');
    
    $wsdl = 'https://profitweb.afasonline.nl/profitservices/getconnector.asmx?wsdl';
    
    $client = new nusoap_client($wsdl, true);
    $client->setCredentials("AOL" . '\\' . "53175.Webbio", "Password!", 'ntlm');
    $client->setUseCurl(true);
    $client->useHTTPPersistentConnection();
    $client->setCurlOption(CURLOPT_USERPWD, '53175.webbio:Password!');
    
    
    $xml_array['environmentId'] = 'O12343AA';
    $xml_array['userId'] = "41258.Webbio";
    $xml_array['password'] = "Password";
    $xml_array['logonAs'] = "";
    $xml_array['connectorId'] = "SSS_werkgever_vacatures";
    $xml_array['filtersXml'] = "";
    
    
    $err = $client->getError();
    if ($err) {
    	echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
    	echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
    	exit();
    }
    
    $result = $client->call('GetData', array('parameters' => $xml_array), '', '', false, true);
    // var_dump($result);
    
    header('Content-Type: application/xml');
    print_r($result["GetDataResult"]);
    
    ?>

    【讨论】:

    • 请更改您的环境密码,因为它已被公开。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多