I developed a SOAP call on PHP (inside WordPress) which works perfectly on local (MAMP) but when I upload to a shared host it doesn’t work. The request’s response is "Fail to connect to server(…)".
I tried to use the same PHP version and increase the server response time but it still doesn’t work.
Funny part: two other related endpoints work, just a specific one doesn’t.
A bit of my code:
[…] ob_start();
error_reporting (E_ALL & ~ E_NOTICE & ~ E_DEPRECATED);
ini_set('max_execution_time', 3600);
ini_set("memory_limit","128M");
ini_set('default_socket_timeout', 60);
ini_set("soap.wsdl_cache_enabled", "0");
header("Access-Control-Allow-Origin: *");
[…]
$params = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:val="johndoe">
<soapenv:Header/>
<soapenv:Body>
<val:SomeThing.Execute>
<val:SomeThing2>'.$SomeThing2.'</val:SomeThing2>
<val:SomeThing3>'.$SomeThing3.'</val:SomeThing3>
<val:SomeThing4>'.$SomeThing4.'</val:SomeThing4>
</val:SomeThing.Execute>
</soapenv:Body>
</soapenv:Envelope>';
$ch = curl_init();
$url = $url_geral;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('autentica: /','Content-Type: application/xml'));
curl_setopt($ch, CURLOPT_TIMEOUT, '600');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$output = curl_exec($ch);
$response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
2
Answers
I solved my issue. Indeed I was/am using a cURL insted of SOAP, but the point is that my shared hosting was blocking the port.
I contacted them and they opened the proper door. Now it works.
Thanks to everyone who collaborated.
Can you verify that soap library is installed on your webserver?
And I think you should use build in soap client: