简体   繁体   中英

PHP Soap SSL Error [WSDL] SOAP-ERROR

I'm having some issues with SOAP and PHP. I'm running PHP 7 but having issues due to an comodo SSL cert. The code is below:

 $contextOptions = array(
'ssl' => array(
     'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true

)
);
$sslContext = stream_context_create($contextOptions);

$client = new SoapClient('https://XXXX.com/api/v2_soap/?wsdl', array('stream_context' => $sslContext));

$session = $client->login('apiUser', 'apiKey');
$filter = array('filter' => array(array('key' => 'status', 'value' => 'processing')));
$result = $client->salesOrderList($session, $filter);

var_dump ($result);

It seems to fail every time on the connection

Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL:Couldn't load from 'https://xxxxx.com/api/v2_soap/?wsdl' : failed to load external entity

curl works if I use -k but errors on SSL without, I thought that by doing the context options it should have skipped the ssl errors and carried on.

Thanks

It appears your SSL Situation could improve a lot, here are ideas you can try out, which may provide solutions to the problem:

  1. Implement a simple proxy service, using any tool, such as nginx or maybe python or even golang, that converts https traffic to http and strips the errors, and sits in the middle of all the traffic, this will allow you to see and debug the stuff that's passing trough easily.

  2. make sure the PHPINFO tool reports libssl and https is supported in your current php installation, review if the libeay is present as well, if on windows, you may need some dlls.

  3. review your current php.ini and figure out if you have access to enable extensions, if so, try installing the extension by uncommenting the commented lines which allow for https support in PHP, if you have no access to the php settings (perhaps a shared host) then:

  4. consider calling the php executable directly by making a copy of the php binary somewhere in the Web Server, and proceed to enable all the necessary php extensions directly in the server for your particular php copy, using a custom php.ini file; remember php itself can also be used as a Web Server.

  5. remember any changes to the php configuration require apache restart.

  6. If all else fails, you can always call curl directly from PHP using passthru() or exec.

  7. If you feel particularly desperate, you can always learn how to compile PHP by hand and enable whatever you need enabled, but I would admit this is overkill, the exercise will teach you a lot about PHP internals and will help you in the future, if you ever decide to write your own PHP extension.

Have fun solving the problem, and don't forget to report back how you did it!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM