0

Im having a problem with SoapClient (PHP 7.0) to parse wsdl.

Im getting this error:

SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://ws.ocasa.com/testecommerce/service.asmx?wsdl' : failed to load external entity "https://ws.ocasa.com/testecommerce/service.asmx?wsdl"

If you put this URL in a browser you can see the SOAP, and also in SoapUI it works OK.

I'm using laravel 5.4, and my code is:

$client = new \SoapClient('https://ws.ocasa.com/testecommerce/service.asmx?wsdl',
        ['soap_version'=>SOAP_1_2]);

I noticed that that website is under SSLv3. In order to figure out what's the problem, I also noticed that I cannot get the content of the WSDL:

        $content = file_get_contents('https://ws.ocasa.com/testecommerce/service.asmx?wsdl');

And I get this error

file_get_contents(): Failed to enable crypto

I don't know if its something in my PHP.ini. But if I change to this other WSDL:

https://id3check.gb.co.uk/gbportalinternational/aspx/id3check_1b.asmx?WSDL

Everything works fine, the parsing and getting the content.

Thank you

Joaquin Colella
  • 142
  • 1
  • 1
  • 11
  • Possible duplicate of [How to get file\_get\_contents() to work with HTTPS?](https://stackoverflow.com/questions/1975461/how-to-get-file-get-contents-to-work-with-https) – Capsule Jun 28 '17 at 00:16
  • Thanks for trying to help!. I edit my post, so that you can see that my problem is not that I cannot get the content of the wsdl, is that my SoapClient doesn't work with that WSDL. In the post you send me, explains how to get the content in a different way, my idea was to give more information about my situation, so as maybe someone can figure out what its happening. Thank you Capsule! :) – Joaquin Colella Jun 28 '17 at 01:21
  • No, your issue is that PHP can't get the content from this server because of SSLv3 (possibly). It has nothing to do with SoapClient. `file_get_contents(): Failed to enable crypto` is crystal clear. Trying something like https://stackoverflow.com/questions/14078182/openssl-file-get-contents-failed-to-enable-crypto and see if that helps – Capsule Jun 28 '17 at 01:29
  • You'll also find more info about how PHP handles SSL certs here: http://php.net/manual/en/migration56.openssl.php – Capsule Jun 28 '17 at 01:31
  • My PHP is 7.0. And I find out, the problem comes from there, that the SSL is TLS 1.0, and in PHP 7.0 doesn't work. – Joaquin Colella Jun 28 '17 at 12:39
  • TLS 1.0 is getting deprecated so it's possible PHP 7 completely dropped support for it. Most big software vendors are dropping support for TLS 1.0 now and the safest option probably is to upgrade the cert or ask the cert owner to do so. – Capsule Jun 28 '17 at 23:41
  • I meant upgrade the SSL layer, not the cert :-) – Capsule Jun 28 '17 at 23:47

1 Answers1

0

So I solved the problem by adding optional parameters SSL:

$wurl = 'https://ws.ocasa.com/testecommerce/service.asmx?wsdl';
$opts = array(
            'ssl' => array('ciphers' => 'RC4-SHA')
        );
$this->soapClient = new SoapClient($wurl, array('trace' => 1,
            'exception' => 1, 'soap_version' => SOAP_1_2, 'connection_timeout' => 60, 'stream_context' => stream_context_create($opts)));