PHP CURL Soap Request Print Response -
hello trying send soap request powerpay.biz , not getting response, plus when use test url
https://gkicmerchants.com/admin/classes/soap-request.xml
i error
warning: simplexmlelement::__construct() [simplexmlelement.--construct]: entity: line 1: parser error : start tag expected, '<' not found in /home/content/g/k/i/gkic1848/html/admin/classes/submit_applicant.class.php on line 299
here code:
$username = 'user'; $password = 'password'; $credentials = $username.":".$password; $url = "http://gkicmerchants.com/admin/classes/soap-server.php"; $soap_request = '<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/"> <soap:body> .... </soap:body> </soap:envelope>'; $header = array( "content-type: text/xml;charset=\"utf-8\"", "accept: text/xml", "cache-control: no-cache", "pragma: no-cache", "soapaction: '".$url."'", "content-length: ".strlen($soap_request), ); $curl = curl_init(); curl_setopt($curl, curlopt_httpauth, curlauth_basic ) ; curl_setopt($curl, curlopt_userpwd, $credentials); curl_setopt($curl, curlopt_sslversion,3); curl_setopt($curl, curlopt_ssl_verifypeer, false); curl_setopt($curl, curlopt_ssl_verifyhost, 2); curl_setopt($curl, curlopt_header, true); curl_setopt($curl, curlopt_post, 1); curl_setopt($curl, curlopt_postfields, $soap_request ); curl_setopt($curl, curlopt_httpheader, $header); curl_setopt($curl, curlopt_followlocation, 1); curl_setopt($curl, curlopt_returntransfer, 1); curl_setopt($curl, curlopt_useragent, "mozilla/4.0 (compatible; msie 5.01; windows nt 5.0)"); curl_setopt($curl, curlopt_url, $url); // perform request $xml_result = curl_exec($curl); // check errors if ($xml_result === false) { $error_occurred = true; } else { $xml = new simplexmlelement($xml_result); print_r($xml); }
is wrong curl_setopt options?
do not include response header output. drop line:
curl_setopt($curl, curlopt_header, true);
Comments
Post a Comment