Muhammad Arslan Jamshaid
Muhammad Arslan Jamshaid

Reputation: 1197

Curl not able to Connect to host while Curl is enabled on Server

I am calling a webservice using curl, it is working fine in localhost but when I use the same script on my live website to call it outputs the error:

Couldn't connect to host

Here are my Live website curl settings enter image description here

 $soap_request = '<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
    <InsertData xmlns="http://exampleServiceSite:6265">          
      <remarks>No Remarks</remarks>
      <insuranceValue>0</insuranceValue>
    </InsertData>
    </soap:Body>
    </soap:Envelope>';

$header = array(
    "POST /Service1.asmx HTTP/1.1",
        "Content-type: text/xml;charset=\"utf-8\"",
        "Accept: text/xml",
        "Cache-Control: no-cache",
        "Pragma: no-cache",
        "SOAPAction: \"http://exampleServiceSite:6265/InsertData\"",
        "Content-length: ".strlen($soap_request),
    );

    $soap_do = curl_init();
        curl_setopt($soap_do, CURLOPT_URL,            "http://exampleServiceSite:6265/" );
        curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
        curl_setopt($soap_do, CURLOPT_POST,           true );
        curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $soap_request);
        curl_setopt($soap_do, CURLOPT_HTTPHEADER,     $header);
        $result = curl_exec($soap_do);
        var_dump($result);

Upvotes: 0

Views: 1803

Answers (1)

Craig
Craig

Reputation: 222

Do you have SSH access to your dev machine?

If so open an SSH session and try this:

>telnet exampleServiceSite 6265

do you get something like this come up?

Trying 62.253.72.158...
Connected to google.com.
Escape character is '^]'.

Upvotes: 1

Related Questions