dongnong7524
2016-05-05 11:26 阅读 138

SOAP-ERROR:解析WSDL:无法从“网站”加载无法加载外部实体

In Wamp server (locally) my code works, but in my web server on Centos 6 the script doesn't work. Why? I have read lot's of answers, but didn't find the solution.

Couldn't load from 'https://example.com/WEBService/SearchService.svc/wsdl?wsdl': failed to load external entity "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

soap

openssl installed.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • download1323 download1323 2016-05-10 15:16

    In my webserver is installed php 5.6. In Wamp server (locally) php 5.3.

    I disabled SSL certification, by passing context stream:

    "stream_context" => stream_context_create(
        array(
            'ssl' => array(
                'verify_peer'       => false,
                'verify_peer_name'  => false,
            )
        )
    )
    

    So it works.

      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;
    }
    
    点赞 评论 复制链接分享

相关推荐