August 9, 2017

Debugging SOAP Issues

We recently had a very strange php SOAP issue that cropped up right after an upgrade to PHP on a development server took place.  It was a basic SOAP call to Fedex webservices that had always worked before.

After some precursory debugging, we found that the main error was “Uncaught SoapFault exception: [HTTP] Could not connect to host”.
It was strange, since we could easily CURL a response to the same Fedex HTTPS url without any issue.

Having a hunch it may be SSL related, we setup the SOAP call to ignore SSL Cert lookups/etc.

$client = new SoapClient($wsdl, array(
    //'trace' => 1,
    'stream_context' => stream_context_create(array(
        'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false, 
            'allow_self_signed' => true //can fiddle with this one.

To confirm our suspicions, the call started working right away. Doing a bit of digging on Stack Overflow, we found another person had been hit with the same issue ( Answer

Fatal error: Uncaught Error: [] operator not supported for strings in /home/silvatec/public_html/wp-content/themes/layerswp/core/helpers/post.php:62 Stack trace: #0 /home/silvatec/public_html/wp-content/themes/layerswp/partials/content-single.php(81): layers_post_meta(3990) #1 /home/silvatec/public_html/wp-includes/template.php(690): require('/home/silvatec/...') #2 /home/silvatec/public_html/wp-includes/template.php(647): load_template('/home/silvatec/...', false) #3 /home/silvatec/public_html/wp-includes/general-template.php(167): locate_template(Array, true, false) #4 /home/silvatec/public_html/wp-content/themes/layerswp/single.php(20): get_template_part('partials/conten...', 'single') #5 /home/silvatec/public_html/wp-includes/template-loader.php(74): include('/home/silvatec/...') #6 /home/silvatec/public_html/wp-blog-header.php(19): require_once('/home/silvatec/...') #7 /home/silvatec/public_html/index.php(17): require('/home/silvatec/...') #8 {main} thrown in /home/silvatec/public_html/wp-content/themes/layerswp/core/helpers/post.php on line 62