karthika pommudu

karthika pommudu

  • NA
  • 321
  • 32.2k

How to get the xml repsonse here..

Mar 7 2019 3:18 AM
Very urgent ..help to get this response
 
We are tried the xml api call with curl function,but I Can't get xml repsonse from this & I got a response like sequence format
 
Code format are:
  1. <?php  
  2. $soapUrl = "http://locationinfo.addtech.in/LocationInfo.asmx?op=ADDGetLiveData";  
  3. $soapUser = "......."// username  
  4. $soapPassword = "........"// password  
  5. $lIMEI = ".........";  
  6. $xml_post_string = '<?xml version="1.0" encoding="utf-8"?>  
  7. <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  8. xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
  9. xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">  
  10. <soap:Header>  
  11. <Authentication xmlns="http://ADDtech.org/">  
  12. <User>'.$soapUser.'</User>  
  13. <Password>'.$soapPassword.'</Password>  
  14. </Authentication>  
  15. </soap:Header>  
  16. <soap:Body>  
  17. <ADDGetLiveData xmlns="http://ADDtech.org/">  
  18. <lIMEI>'.$lIMEI.'</lIMEI>  
  19. </ADDGetLiveData>  
  20. </soap:Body>  
  21. </soap:Envelope>'; // data from the form, e.g. some ID number  
  22. $headers = array(  
  23. "Content-type: text/xml;charset=\"utf-8\"",  
  24. "Accept: text/xml",  
  25. "Host: locationinfo.addtech.in",  
  26. "Cache-Control: no-cache",  
  27. "Pragma: no-cache",  
  28. "SOAPAction: http://ADDtech.org/ADDGetLiveData",  
  29. "Content-length: ".strlen($xml_post_string),  
  30. ); //SOAPAction: your op URL  
  31. $url = $soapUrl;  
  32. // PHP cURL for https connection with auth  
  33. $ch = curl_init();  
  34. // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);  
  35. curl_setopt($ch, CURLOPT_URL, $url);  
  36. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml;charset=\"utf-8\"'));  
  37. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
  38. // curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); // username and password - declared at the top of  
  39. // curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);  
  40. curl_setopt($ch, CURLOPT_TIMEOUT, 10);  
  41. curl_setopt($ch, CURLOPT_POST, true);  
  42. curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request  
  43. // converting  
  44. // header( 'Content-type: text/xml' );  
  45. $response = curl_exec($ch);  
  46. curl_close($ch);  
  47. print_r($response);  
  48. ?>
Now Got a Response like:
 
8.70418078.01902507/Mar/2019 10:42:16 AM0.00OffGPSNorth100%Strong SignalPower Connected
 
Actually we want response like :
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"  
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4. xmlns:xsd="http://www.w3.org/2001/XMLSchema">  
  5. <soap:Body>  
  6. <ADDGetLiveDataResponse xmlns="http://ADDtech.org/">  
  7. <ADDGetLiveDataResult>  
  8. <Latitude>11.713210</Latitude>  
  9. <Longitude>78.083677</Longitude>  
  10. <PositionTime>04/Mar/2019 04:20:46 PM</PositionTime>  
  11. <Speed>25.00</Speed>  
  12. <ACC>Off</ACC>  
  13. <PositionType>GPS</PositionType>  
  14. <Direction>NorthWest</Direction>  
  15. <Battery>100%</Battery>  
  16. <GSMStrength>Strong Signal</GSMStrength>  
  17. <PowerStatus>Power Connected</PowerStatus>  
  18. </ADDGetLiveDataResult>  
  19. </ADDGetLiveDataResponse>  
  20. </soap:Body>  
  21. </soap:Envelope>  
Any help is greatly appreciated. Thanks for looking.

Answers (2)