Advertisement
Mr_Djole

Untitled

Jan 9th, 2023 (edited)
1,086
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 KB | None | 0 0
  1. <?php
  2. $xml = <<<EOT
  3. <?xml version="1.0" encoding="utf-8"?>
  4. <soap: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/">
  5.   <soap:Body>
  6.     <InformacijaOPosiljci xmlns="http://TrackTrace.com">
  7.       <strPrijemniBroj>CH176197243US</strPrijemniBroj>
  8.     </InformacijaOPosiljci>
  9.   </soap:Body>
  10. </soap:Envelope>
  11. EOT;
  12.  
  13. $headers = [
  14.     "Content-Type: text/xml; charset=utf-8",
  15.     "Cache-Control: no-cache",
  16.     "Pragma: no-cache",
  17.     "Content-Length: ".strlen($xml)
  18. ];
  19.  
  20. $curlh = curl_init();
  21.  
  22. curl_setopt($curlh, CURLOPT_URL, 'https://e-racuni.postacg.me/TTService/Service1.asmx');
  23. curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true);
  24. curl_setopt($curlh, CURLOPT_TIMEOUT, 10);
  25. curl_setopt($curlh, CURLOPT_POST, true);
  26. curl_setopt($curlh, CURLOPT_POSTFIELDS, $xml);
  27. curl_setopt($curlh, CURLOPT_HTTPHEADER, $headers);
  28.  
  29. $resp = curl_exec($curlh);
  30.  
  31. curl_close($curlh);
  32.  
  33. $xml = new SimpleXMLElement($resp);
  34.  
  35. $xml->registerXPathNamespace('d', 'urn:schemas-microsoft-com:xml-diffgram-v1');
  36.  
  37. $tables = $xml->xpath('//TableName');
  38. foreach ($tables as $table) {
  39.     echo $table->Opis . PHP_EOL;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement