问题
Having solved my previous problem with SOAP, I now have a follow-up question. When I try to retrieve data from WSDL service link I got below error
Server was unable to process request. ---> Authentication Failed
and my guess are
- This is an issue with certificate
Please see below is the certificate.pem
structure is
Bag Attributes
-----BEGIN CERTIFICATE-----
MIICvTCCAiagA...vcNAQEEBhMCTlox
.....
.....
-----END CERTIFICATE-----
Bag Attributes
-----BEGIN PRIVATE KEY-----
....
MIICvTCCAiagA...vcNAQEEBhMCTlox
-----END PRIVATE KEY-----
- I need to set SoapHeader::SoapHeader But what to set? there is no such user authentication credentials. I have is one more certificate is in
.PFX
which was changed into .pem
and here is the main code
$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); returns with multiple attributes in headers
<?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. ---> Authentication Failed.</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
Please suggest me the right fixes in the code. Here you can see the
complete code snippet
来源:https://stackoverflow.com/questions/27147950/php-wsdl-soap-issue-server-was-unable-to-process-request-authentication-faile