SoapFault exception: Could not connect to host
The problem was solved.The problem is the cache
ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);
PHP Soap Fault: Could not connect to host
Finally, I got the solution,
I found the problem. The host I was trying to connect is redirecting to another domain name. For some reason, PHP 5.6 doesn't carry the location automatically. So i defined the same soap url in the location options.
Eg:
$params = array('location' => {soapurl});
$client = new SoapClient({soapurl},$params);
Thanks for your time. :)
PHP SoapClient: SoapFault exception Could not connect to host
You need to improve your debugging efforts even further:
ad 1) Does the WSDL change a lot? If not, turn on WSDL caching. You don't need to connect to the server to fetch the WSDL file.
Is the output you mentioned really created in echo $e->getMessage();
? You could add some debugging code inside the catch()
block, for example:
- check if you can connect to the server in another way (for example
file_get_contents($soap_url)
) - if not, check what kind of error you are getting
- print the time and check the error logs on the SOAP server
- a 403 Forbidden or similar error points on a problem on the server
- a Could not connect error points to a network problem (not exclusively but chances are higher for that)
- You could try to put it in a loop (something along the lines of
for ($i = 0; $i <= 5; $i++) { /* ... */ sleep(1); continue; }
) to see if a second try would make it work
All in all, "sometimes errors" are hard to debug, so either you should try to make it reproducible (which will point at the problem), or you need to record and output as much data as possible so that you can see where the problem was at the time when it occurred.
SoapFault exception [HTTP] Could not connect to host: With Local SSL Certificate
I solved the problem by splitting the PEM file into two seperate key and crt files using openssl:
openssl pkcs12 -in certname.pem -nocerts -out key.pem -nodes
openssl pkcs12 -in certname.pem -nokeys -out bla.crt
Using this and setting these values in the code, it did work.
Related Topics
Codeigniter - File Upload Required Validation
Php's File_Exists() Will Not Work for Me
How to Bulk Update MySQL Data with One Query
Codeigniter Model Error: Undefined Property
MySQL Query In() Clause Slow on Indexed Column
Where to Put the PHP Artisan Migrate Command
Simple Comet Example Using PHP and Jquery
Check If Laravel Model Got Saved or Query Got Executed
How to Make Apache Serve Index.PHP Instead of Index.Html
Soapfault Exception: Could Not Connect to Host
When Do I Use PHP_Eol Instead of \N and Vice-Versa? Ajax/Jquery Client Problem
How to Match Accented Characters with PHP Preg
Unescape or HTML Decode in Twig (PHP Templating)
Swift_Transportexception Connection Could Not Be Established with Host Smtp.Gmail.Com