Click here to Skip to main content
15,888,293 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

PHP
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);
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900