2

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.

  • Can you ping the hostname from the same place you run the scripts? Can you load the wsdl in your browser? Can you load the wsdl using wget from the command line? Is libxml installed? – Kris Peeling May 05 '16 at 21:30
  • 1. Yes I can. 2. My centos is without GUI, so there is not browser. 3. It works only with key "--no-check-certificate’". 4. Yes it is. – Никита Чайковский May 08 '16 at 05:14

1 Answers1

1

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;
}