Soapclient https request



场景:通过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在这里找到的建议解决方案(使用先前下载的WDSL文件进行请求)

第二atttempt:

$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异常:[Client]看起来像我们在…中没有XML文档

最终解决添加

openssl.cafile=/etc/ssl/certs/ca-bundle.crt
php.ini

相关内容

  • 没有找到相关文章

最新更新