场景:通过SSL从我的本地主机到外部服务器的SOAP请求。
PHP版本:5.6.3
首次尝试:
$options = array (
'encoding' => 'UTF-8',
'stream_context' => stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
)
)
),
);
$client = new SoapClient('https://www.???.es/index.php/api/soap?wsdl', $options);
错误:SOAP-ERROR:解析WSDL
建议的解决方案由tobik发现here(请求先前下载的WDSL文件)
第二个尝试:
$filename = 'test.wsdl';
$uri = dirname(__FILE__) . DIRECTORY_SEPARATOR .$filename;
$options = array (
'encoding' => 'UTF-8',
'location' => 'https://www.???.es',
'uri' => $uri,
'stream_context' => stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
'cache_wsdl' => WSDL_CACHE_NONE,
)
)
),
);
$client = new SoapClient(null, $options);
错误: 未捕获的SoapFault异常:[客户端]看起来我们在......中没有XML文档。
答案 0 :(得分:0)
最后解决了添加
openssl.cafile=/etc/ssl/certs/ca-bundle.crt
到php.ini