I am trying to send an API call through SoapClient in PHP. Everything works perfectly in my local dev environment, but when I try to do it on the production server, I get the following error:
object(SoapFault)#2 (9) { ["message":protected]=> string(25) "Could not connect to host"
I suspect the problem might come from the proxy we have on the server. I tried to send a Curl request to test if I can reach the API URL, and the following request works:
$param_curl = array(
CURLOPT_URL => "https://the.api.com/path",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPPROXYTUNNEL => true,
CURLOPT_PROXY => "http://my.proxy.com:123"
);
curl_setopt_array($curl, $param_curl);
curl_exec($curl);
But when I try the following call with SoapClient on the server (which works on my local dev environment), I get the "Could not connect to host" error:
$client = new SoapClient("wsdl.xml", [
'trace' => 1,
'cache_wsdl' => WSDL_CACHE_NONE,
'proxy_host' => "http://my.proxy.com",
'proxy_port' => "123"
]);
$result = $client->create($params);
I could send the Soap XML directly in a Curl request, but it kinda ruins the point of the Soap protocol.
Do any of you see something that I might have missed? Thanks a lot!