标签:php ssl web-services soap soap-client
我必须开发一个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文件,该文件包含我的私钥与证书并置,如我所读: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,anotherSoapClient是扩展PHP soapClient类的类:PHP soapClient send custom XML
解决方法:
对于调试建议,您的SOAP请求必须扩展SoapClient类.
class SoapClientDebug extends SoapClient
{
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
// Add code to inspect/dissect/debug/adjust the XML given in $request here
// Uncomment the following line, if you actually want to do the request
// return parent::__doRequest($request, $location, $action, $version, $one_way);
}
}
然后在您的请求中使用它:
$client = new SoapClientDebug("x.wsdl");
$response = $client->__soapCall($function);
echo $client->__getLastRequest();
希望它有助于调试您的代码!
标签:php,ssl,web-services,soap,soap-client 来源: https://codeday.me/bug/20191010/1885726.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。