PHP WSDL SOAP问题:服务器无法处理请求。身份验证失败

时间:2014-11-26 11:26:04

标签: php web-services soap wsdl

解决了我的previous problem with SOAP后,我现在有了一个后续问题。当我尝试从WSDL service link检索数据时,我收到了以下错误

  

服务器无法处理请求。 --->身份验证失败

我的猜测是

  1. 这是证书
  2. 的问题

    请参阅下面的 certificate.pem 结构

    Bag Attributes
    -----BEGIN CERTIFICATE-----
    MIICvTCCAiagA...vcNAQEEBhMCTlox
    .....
    .....
    -----END CERTIFICATE-----
    Bag Attributes
    -----BEGIN PRIVATE KEY-----     
    ....
    MIICvTCCAiagA...vcNAQEEBhMCTlox
    -----END PRIVATE KEY-----
    
    1. 我需要设置SoapHeader::SoapHeader但是要设置什么?没有此类用户身份验证凭据。我有.PFX中的另一个证书已更改为.pem
    2. 这是主要代码

      $wsdl = "https://<webservice>/Informationservice.WSDL";
      $cert = getcwd().DS."certificate.pem";
      $passphrase = "Wireline";
      $uri = "https:///<webservice>/InformationService.asmx";
      $namespace = "http://schemas.xmlsoap.org/soap/envelope/";
      
      $x = new SoapClient($wsdl, [
                                      'local_cert' => $cert,
                                      'passphrase' => $passphrase,
                                      'allow_self_signed' => true,
                                      'cache_wsdl' => WSDL_CACHE_NONE,
                                      'location' => $uri,
                                      'uri' => $namespace,
                                      'exceptions' => false,
                                      'trace' => true,
                                      'soap_version' => SOAP_1_1,
                                      'keep_alive' => true,
                                      'connection_timeout'=>2000,
                                      'encoding'=> 'UTF-8'
                                  ]);
      
      $req = '<?xml version="1.0" encoding="utf-8"?>
          <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
            <soap:Body>
              <addressVerificationRequest xmlns="urn:DCNZ.MSP.Wireline.Wholesale.Common">
                <addressVerification>
                ....
                </addressVerification>
              </addressVerificationRequest>
            </soap:Body>
      </soap:Envelope>';
      
      $params = ['addressVerificationRequest' => (object)$req];
      $x->__soapCall('AddressVerification',[$params]);
      
      
      $responseHeaders = $client->__getLastResponseHeaders();
      $response = $client->__getLastResponse();
      

      的var_dump($ responseHeaders响应);

      'HTTP/1.1 500 Internal Server Error
      Date: Wed, 26 Nov 2014 10:54:33 GMT
      Server: Microsoft-IIS/6.0
      X-Powered-By: ASP.NET
      X-AspNet-Version: 2.0.50727
      Cache-Control: private
      Content-Type: text/xml; charset=utf-8
      Content-Length: 1203
      

      var_dump($ response); 在标题中返回多个属性

      <?xml version="1.0" encoding="utf-8"?>
          <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
              <soap:Header>
                  <wsa:Action>http://schemas.xmlsoap.org/ws/2004/03/addressing/fault</wsa:Action>
                  <wsa:MessageID>uuid:2db7b411-cabd-4716-aaaf-b5fac22efd21</wsa:MessageID>
                  <wsa:RelatesTo>uuid:b4f10b7f-972c-4dbd-9ab2-a76a55d0322c</wsa:RelatesTo>
                  <wsa:To>http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</wsa:To>
                  <wsse:Security>
                      <wsu:Timestamp wsu:Id="Timestamp-80353dc4-8a40-479e-9244-c7708df88ca8">
                          <wsu:Created>2014-11-26T10:48:56Z</wsu:Created>
                          <wsu:Expires>2014-11-26T10:53:56Z</wsu:Expires>
                      </wsu:Timestamp>
                  </wsse:Security>
              </soap:Header>
              <soap:Body>
                  <soap:Fault>
                      <faultcode>soap:Server</faultcode>
                      <faultstring>Server was unable to process request. ---&gt; Authentication Failed.</faultstring>
                      <detail />
                  </soap:Fault>
      
              </soap:Body>
      
      </soap:Envelope>
      

      请在代码中建议我正确的修复程序。

      在这里可以看到
        
          

      complete code snippet

        

0 个答案:

没有答案