我在调用soap函数时遇到问题。我收到错误"无法连接到主机"。我使用的是"wamp服务器"、"php版本5.3.13"answers"apache版本2.2.22"。
我有.p12格式的客户端证书,wsdl文件在本地系统中可用,并且我已经使用soapUI-m-snapshot测试了soap调用。它很好用!但当我尝试使用php"SoapClient"时,却得到了"无法连接到主机"。我正在使用以下肥皂选项
$soapclient_options = array();
$soapclient_options['cache_wsdl'] = 'WSDL_CACHE_NONE';
$soapclient_options['local_cert'] = $certificatePath;
$soapclient_options['passphrase'] = $api_certificate_passphrase;
$soapclient_options['trace'] = true;
$soapclient_options['connection_timeout'] = 15;
$soapclient_options['ssl_method'] = 'SOAP_SSL_METHOD_SSLv3';
$soapclient_options['location'] = 'api location';
$client = new SoapClient($wsdl_path, $soapclient_options);
$client->__setLocation($soapclient_options['location']);
我是不是做错了什么?请有人推荐我,并提前表示感谢。
PHP Soap客户端只接受pem证书。您可以使用隐藏您的证书
openssl pkcs12 -in in.p12 -out out.pem -nodes -clcerts
使其与PHP 5.6版本协同工作所需的额外代码。
$soapclient_options['stream_context'] = stream_context_create(
array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
)
)
);