I'm quite stuck in how to edit this script be able to take a request from jquery and return to me the value the script returns? Any help is most gratefully appreciated?
I can use it to pass an xml file and url from the filesystem and get the return I expect but would really like to be able to use it as a proxy to a wsdl service.
[edit] Due to environmental changes I'm wanting to use the below script to pass back to me the xml return from a wsdl service that I'm passing xml. It works fine when I do so from the command line - I'm just unsure how to be able to get the script to accept a post and then return the xml return from the service call.
I'm using the script as follows from the command line:
php file.php theurl <test.xml
^^ Which returns to me the xml I would like to then pass back to the frontend
<?php
ini_set('display_errors', "1");
$url= $argv[1];
echo "url
$url
";
preg_match("/https?:\/\/([^\/]*)(.*)/", $url, $matches);
$host=$matches[1];
$request=$matches[2];
$mxml=fread(STDIN,65536);
$yt =curl_init();
$header = "POST $request HTTP/1.0
";
$header .= "Host: $host
";
$header .= "SoapAction:";
$header .= "Content-Type: text/xml
";
$header .= "Content-Length: ".strlen($mxml)."
";
$header .= "Content-Transfer-Encoding: text
";
$header .= "Connection-Close: close
";
echo "header
$header
";
$header .= $mxml;
curl_setopt($yt, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($yt, CURLOPT_URL, $url);
curl_setopt($yt, CURLOPT_CUSTOMREQUEST, $header);
curl_setopt($yt, CURLOPT_RETURNTRANSFER, true);
$rxml=curl_exec($yt);
echo "sent
$mxml
";
echo "received
$rxml
";
echo curl_error($yt);
?>