Skip to content

Instantly share code, notes, and snippets.

@nateflink
Created April 11, 2016 05:07
Show Gist options
  • Save nateflink/e156153fbf001c253ccb6d93c8ff605e to your computer and use it in GitHub Desktop.
Save nateflink/e156153fbf001c253ccb6d93c8ff605e to your computer and use it in GitHub Desktop.
<?php
$xml_post_string =
'<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.edocbuilder.com/">
<SOAP-ENV:Body>
<ns1:getOrderFile>
<ns1:docSessionID>replace-with-real-a49a-3862345df1061</ns1:docSessionID>
<ns1:email>EMAIL</ns1:email>
<ns1:password>PASSWORD</ns1:password>
</ns1:getOrderFile>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>';
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: http://www.edocbuilder.com/getOrderFile",
"Content-length: ".strlen($xml_post_string),
);
// PHP cURL for https connection with auth
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, "http://engine.edocbuilder.com/services/builddoc.asmx?op=getOrderFile");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
curl_close($ch);
$response1 = str_replace("<soap:Body>","",$response);
$response2 = str_replace("</soap:Body>","",$response1);
$parser = simplexml_load_string($response2);
var_dump ($parser);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment