【问题标题】:SOAP-ERROR: Parsing WSDL: Couldn't load from 'website 'failed to load external entitySOAP-ERROR:解析 WSDL:无法从“网站”加载,无法加载外部实体
【发布时间】:2016-05-05 11:26:39
【问题描述】:

在 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 肥皂

肥皂

openssl 已安装。

【问题讨论】:

  • 您可以从运行脚本的同一个地方 ping 主机名吗?您可以在浏览器中加载 wsdl 吗?您可以从命令行使用 wget 加载 wsdl 吗? libxml 安装了吗?
  • 1.我可以。 2.我的centos没有GUI,所以没有浏览器。 3. 它只适用于密钥“--no-check-certificate”。 4. 是的。

标签: php soap centos


【解决方案1】:

在我的网络服务器中安装了 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;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多