-----Mensagem original-----
De: Bastien Koert [] 
Enviada em: quinta-feira, 4 de outubro de 2012 11:54
Para: PHP-General
Assunto: [PHP] cURL issues posting to an end point

Hi All,

I have a page that receives third party data into my app, xml data via https
post. This works fine and I receive the data as expected. The issue I am
facing is around posting XML data back as a synchronous response to the post
I receive. I am using the following code:

function sendXMLConfirmation($data)
   * XML Sender/Client.
  // Get our XML. You can declare it here or even load a file.

  $xml_builder = '<?xml version="1.0" encoding="utf-8"?>
                                <Envelope version="01.00">
                                                <TimeStamp>'.date("Y-m-d H:m
<LongDescription>CANDIDATE Data transfer was a success</LongDescription>
  // We send XML via CURL using POST with a http header of text/xml.
        $ch = curl_init();

        $url =

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);   // for https
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 4);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_builder);

----- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
-----   curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close'));

--- NEW ----
$sPost = '/Sprocessor/DispatchMessage.asmx';
$sHost = '';

curl_setopt($ch, CURLOPT_HTTPHEADER,
'User-Agent: My Program',
'Accept-Encoding: gzip, deflate',
'POST ' . $sPost . ' HTTP/1.1',
'Host: ' . $sHost,
'Content-type: application/soap+xml; charset="utf-8"',
'Content-Length: ' . strlen($xml_builder)

---- END NEW -----
        //Execute the request and also time the transaction ( optional )

        $start = array_sum(explode(' ', microtime()));

        $result = curl_exec($ch);
        // Print CURL result.
        echo $ch_result;

The endpoint recipient says they are not receiving the data and I am at a
loss to figure out why. Any insight would be appreciated.




Cat, the other other white meat

PHP General Mailing List ( To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to