I have been following some other examples I found on here including this one: Send an XML post request to a web server with CURL and also some external examples such as http://www.phpmind.com/blog/2009/08/how-to-post-xml-using-curl/
For some reason my code is not working. I am repeatedly getting a response of 0 after a lengthy period of time when I try visiting the php file on the actual server.
The exact same XML returns a response of 200 OK when I test posting it to the same request URL in the Chrome Advance REST Client, so clearly the URL is working.
Can anyone please tell me what is wrong with my PHP code?
<?php
$xml_data ='<cXML version="1.2.005" xml:lang="en-US" payloadID="removedforprivacy" timestamp="2017-05-15T13:00:00.000">'
.'<Header>'
.'<From>'
.'<Credential domain="DUNS">'
.'<Identity>removedforprivacy</Identity>'
.'</Credential>'
.'<Credential domain="CompanyName">'
.'<Identity>removedforprivacy</Identity>'
.'</Credential>'
.'</From>'
.'<To>'
.'<Credential domain="CompanyName">'
.'<Identity>removedforprivacy</Identity>'
.'</Credential>'
.'</To>'
.'<Sender>'
.'<Credential domain="DUNS">'
.'<Identity>removedforprivacy</Identity>'
.'<SharedSecret>removedforprivacy</SharedSecret>'
.'</Credential>'
.'</Sender>'
.'</Header>'
.'<Request deploymentMode="production">'
.'<OrderRequest>'
.'<OrderRequestHeader orderID="999" orderDate="2017-05-08 02:41:17" type="new">'
.'<BillTo>'
.'<Address>'
.'<Name xml:lang="en-US">Nicole Testing</Name>'
.'<PostalAddress name="Nicole Testing">'
.'<DeliverTo>Nicole Testing</DeliverTo>'
.'<Street>1 Test St.</Street>'
.'<Street></Street>'
.'<City>Melbourne</City>'
.'<State>VIC</State>'
.'<PostalCode>3000</PostalCode>'
.'<Country isoCountryCode="AU">AU</Country>'
.'</PostalAddress>'
.'</Address>'
.'</BillTo>'
.'<Comments xml:lang="en-US"></Comments>'
.'</OrderRequestHeader>'
.'<ItemOut lineNumber="1" quantity="1" requestedDeliveryDate="2017-05-20T13:49:32">'
.'<ItemID>'
.'<SupplierPartID>51239929_GC</SupplierPartID>'
.'<SupplierPartAuxiliaryID>Joe Simth</SupplierPartAuxiliaryID>'
.'</ItemID>'
.'<ItemDetail>'
.'<UnitPrice>'
.'<Money currency="AUD">1.32</Money>'
.'</UnitPrice>'
.'<Description xml:lang="en-US">Relaxed Tiger</Description>'
.'<UnitOfMeasure>Landscape Size: 24” x 16”</UnitOfMeasure>'
.'<URL>http://image.url.removed.for.privacy</URL>'
.'<Extrinsic name="quantityMultiplier">1</Extrinsic>'
.'</ItemDetail>'
.'<ShipTo>'
.'<Address addressID="0001">'
.'<Name xml:lang="en-US">Your Name</Name>'
.'<PostalAddress name="">'
.'<DeliverTo>Nicole Testing</DeliverTo>'
.'<Street>1 Test St.</Street>'
.'<Street></Street>'
.'<City>Melbourne</City>'
.'<State>VIC</State>'
.'<PostalCode>3000</PostalCode>'
.'<Country isoCountryCode="AU">AU</Country>'
.'</PostalAddress>'
.'</Address>'
.'</ShipTo>'
.'</ItemOut>'
.'</OrderRequest>'
.'</Request>'
.'</cXML>';
$url = 'http://removed.for.privacy';
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml')); // also tried this with application/xml and same response.
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $xml_data );
$response = curl_exec($ch);
print_r($response);
echo "HTTP response code: ".(int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
?>