因此,我需要建立一个应用程序,将接收XML请求,并基于此,我将不得不返回响应XML。我知道如何发送请求并收到回复,但我从来没有以其他方式做过。我会发送这样的请求:如何接收XML请求并在PHP中发送响应XML?
private function sendRequest($requestXML)
{
$server = 'http://www.something.com/myapp';
$headers = array(
"Content-type: text/xml"
,"Content-length: ".strlen($requestXML)
,"Connection: close"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $server);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXML);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = curl_exec($ch);
if(curl_errno($ch)){
print curl_error($ch);
echo " something went wrong..... try later";
}else{
curl_close($ch);
}
return $data;
}
我的问题是 - 什么是接收端的代码?我如何捕获传入的请求? 谢谢。
顶尖的解决方案。 – Matth3w 2015-11-09 22:56:03