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

PHP WSDL SOAP问题:服务器无法处理请求。;身份验证失败,php,web-services,soap,wsdl,Php,Web Services,Soap,Wsdl,解决了我的问题后,我现在有一个后续问题。当我试图从中检索数据时,我得到以下错误 服务器无法处理请求。-->身份验证失败 我猜是的 这是一个证书问题 请参见下面的证书。pem结构为 Bag Attributes -----BEGIN CERTIFICATE----- MIICvTCCAiagA...vcNAQEEBhMCTlox ..... ..... -----END CERTIFICATE----- Bag Attributes -----BEGIN PRIVATE KEY-----

解决了我的问题后,我现在有一个后续问题。当我试图从中检索数据时,我得到以下错误

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

我猜是的

  • 这是一个证书问题
  • 请参见下面的
    证书。pem
    结构为

    Bag Attributes
    -----BEGIN CERTIFICATE-----
    MIICvTCCAiagA...vcNAQEEBhMCTlox
    .....
    .....
    -----END CERTIFICATE-----
    Bag Attributes
    -----BEGIN PRIVATE KEY-----     
    ....
    MIICvTCCAiagA...vcNAQEEBhMCTlox
    -----END PRIVATE KEY-----
    
  • 我需要设置,但设置什么?没有此类用户身份验证凭据。我还有一张证书在
    .PFX
    中,该证书已更改为.pem
  • 这是主要代码

    $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($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>
    
    
    http://schemas.xmlsoap.org/ws/2004/03/addressing/fault
    uuid:2db7b411-cabd-4716-aaaf-b5fac22efd21
    uuid:b4f10b7f-972c-4dbd-9ab2-a76a55d0322c
    http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous
    2014-11-26T10:48:56Z
    2014-11-26T10:53:56Z
    soap:服务器
    服务器无法处理请求。--身份验证失败。
    
    请建议我在代码中的正确修复。在这里你可以看到


    LocalSoapClient类中有什么?似乎需要添加带有身份验证的WS-Security SOAP头(取决于webservice提供程序、usernametoken、binarysecuritytoken…等等)。本地证书仅用于HTTPS客户端证书身份验证。没有用户名令牌etc凭据。根本不需要(AFAIK)问题更新:添加了pastebin链接
    <?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>