I have trying calling a soap of TCS through postman and it works fine there the only problem occurs when i am trying to call it through code getting this error:
"Server was unable to process request. ---> Data at the root level is invalid. Line 1, position 1"
What I have tried:
This is my XML:
<pre lang="HTML">
define('tcs', "http://track.tcs.com.pk/trackingaccount/track.asmx");
$xml = '<?xml version="1.0" encoding="utf-8"?>';
$xml.= '<SOAP-ENV: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/">';
$xml.= '<SOAP-ENV:Body>';
$xml.= '<DataSet_DeliveryDetails_CN xmlns="http://tempuri.org/">';
$xml.= '<CN>30074955506</CN>';
$xml.= '</DataSet_DeliveryDetails_CN>';
$xml.= '</SOAP-ENV:Body>';
$xml.= '</SOAP-ENV:Envelope>';
This is my curl request :
$c = curl_init();
curl_setopt($c, CURLOPT_URL, tcs);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, array('xml' => $xml));
curl_setopt($c, CURLOPT_HTTPHEADER, array('Content-Type=application/soap+xml', 'charset=utf-8'));
$result = curl_exec($c);
dd($result);