我必须开发一个 SOAP 客户端,供应商向我发送了以下规格:
- 将通过IP使用HTTPS进行传输,并打包为XML文档,以适应不同的XML方案定义。
- 通讯是同步的,第三方需要等待响应。
- 每个请求和响应都将被签名。
我正在使用 PHP 中的soapClient 类,一切正常,除了当我尝试使用我的私钥与服务器建立通信时:
Code: WSDL | Message: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://remoteserver/CustomerManagementService?wsdl' : failed to load external entity "https://remoteserver/CustomerManagementService?wsdl
然后我尝试创建一个 .pem 文件,它包含与我的证书连接的私钥,正如我读到的:如何在 PHP 中发送带有 SSL 证书的 SOAP 请求? https://stackoverflow.com/questions/11676392/how-to-send-soap-request-with-ssl-certificate-in-php
但它仍然返回一个错误:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://remoteserver:80/CustomerManager/proxy/CustomerManagementService?WSDL%2FGWTCommonResources%2Fwsdl%2FGWTCommonMessages' : failed to load external entity "http://remoteserver:80/CustomerManager/proxy/CustomerManagementService?WSDL%2FGWTCommonResources%2Fwsdl%2FGWTCommonMessages
我想知道是否有某种方法可以准确获取 PHP 的soapClient 类发送的原始数据。我必须在哪里设置供应商的证书。
我已经尝试过“$client->__getLastRequest()”,但我得到的是 NULL。这是我的代码:
$client = new anotherSoapClient($service, array(
'local_cert' => $pem,
'style' => SOAP_RPC,
'use' => SOAP_ENCODED,
'soap_version' => SOAP_1_2,
'authentication'=> SOAP_AUTHENTICATION_DIGEST,
'ssl' => array(
'ciphers'=> "SHA1",
'verify_peer' => false,
'allow_self_signed' => true
),
'https' => array(
'curl_verify_ssl_peer' => false,
'curl_verify_ssl_host' => false
),
'cache_wsdl' => WSDL_CACHE_NONE,
'cache_ttl' => 86400,
'trace' => true,
'exceptions' => true,
));
// Test connection
echo BR.'Functions: <pre>';var_dump($client->__getFunctions());echo '</pre>';
$XMLrequest = $client->prepareRequest($email);
$response = $client->__anotherRequest('getCustomerInfo', $XMLrequest);
echo "REQUEST:\n" . $client->__getLastRequest() . "\n";
顺便说一句,我在本地计算机上使用 PHP 5.4.9,服务器有 PHP 5.3.10,另一个 SoapClient 是扩展 PHP SoapClient 类的类:PHP SoapClient 发送自定义 XML https://stackoverflow.com/questions/19009554/php-soapclient-send-custom-xml