在Wamp服务器(本地)中,我的代码可以正常工作,但在我的Centos 6上的Web服务器中,脚本不起作用。为什么?我已经阅读了很多答案,但没有找到解决方案。
无法从“https://example.com/WEBService/SearchService.svc/wsdl?wsdl”加载:无法加载外部实体“https://example.com/WEBService/SearchService.svc/wsdl?wsdl”
private $_wsdl_uri = 'https://example.com/WEBService/SearchService.svc/wsdl?wsdl';
private static $_soap_client = false;
private static $_inited = false;
public function init(&$errors)
{
if(!self::$_inited)
{
try
{
if (self::$_soap_client = @new SoapClient($this->_wsdl_uri, array('soap_version' => SOAP_1_1)))
self::$_inited = true;
}
catch (Exception $e)
{
$errors[] = 'Error here '.$e->getMessage();
return false;
}
}
return self::$_inited;
}
php -m | grep -i soap
皂
安装openssl。
答案 0 :(得分:2)
在我的网络服务器上安装了php 5.6。在Wamp服务器(本地)php 5.3。
我通过传递上下文流来禁用SSL认证:
"stream_context" => stream_context_create(
array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
)
)
)
所以它有效。
private $_wsdl_uri = 'https://example.com/WEBService/SearchService.svc/wsdl?wsdl';
private static $_soap_client = false;
private static $_inited = false;
public function init(&$errors)
{
if(!self::$_inited)
{
try
{
if (self::$_soap_client = @new SoapClient($this->_wsdl_uri, array('soap_version' => SOAP_1_1, "stream_context" => stream_context_create(
array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
)
)
)
)
))
self::$_inited = true;
}
catch (Exception $e)
{
$errors[] = 'Error here '.$e->getMessage();
return false;
}
}
return self::$_inited;
}