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">
<Sender>
<Id/>
<Credential>25412</Credential>
</Sender>
<Recipient>
<Id/>
</Recipient>
<TransactInfo transactType="response">
<TransactId>'.$hash.'</TransactId>
<TimeStamp>'.date("Y-m-d H:m
").'</TimeStamp>
<Status>
<Code>200</Code>
<ShortDescription>Success</ShortDescription>
<LongDescription>CANDIDATE Data transfer was a success</LongDescription>
</Status>
</TransactInfo>
<Packet>
<PacketInfo
packetType="response">
<PacketId>1</PacketId>
<Action>SET</Action>
<Manifest>Manifest
Data</Manifest>
<Status>
<Code/>
<ShortDescription/>
<LongDescription/>
</Status>
</PacketInfo>
<Payload><![CDATA[]]></Payload>
</Packet>
</Envelope>
';
// We send XML via CURL using POST with a http header of text/xml.
$ch = curl_init();
$url = 'https://staging.somesite.com/Sprocessor/DispatchMessage.asmx';
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'));
//Execute the request and also time the transaction ( optional )
$start = array_sum(explode(' ', microtime()));
$result = curl_exec($ch);
curl_close($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.
Thanks,
--
Bastien
Cat, the other other white meat
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php