php - 如何能够ajax发布并从此脚本返回?

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);
?>

Sussed it. Sorry forgot to post answer. Hopefully help someone else:

<?php
$url = 'http://myURL';
$xmlpost = file_get_contents('php://input');

$header =   "POST $url  HTTP/1.0
";
$header .=  "Host: myHOST
";
$header .=  "SoapAction: ''";

$ch = curl_init();

//Set the URL
curl_setopt($ch, CURLOPT_URL, $url);
//Enable POST data
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlpost);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);

//curl_exec automatically writes the data returned
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
$.post('path/to/php/', function(data)
{
    $('body').append('<div id="outputs"></div>');
    $('#outputs').html($(data).find('name_of_xml_node').text());
}, 'xml');

maybe.. can't guarantee this one, without at the least maybe some sample data.. as well as this would be more example to work with rather than actually based off what your getting for xml data..

Also you want your PHP to output the XML only no extra strings or anything else like that, that can break the formatting of XML