我正在使用php中的API。客户端API将结果作为xml文件发送到我的URL。我使用file_get_contents
来读取他们希望我回复<xml>Accepted</xml>
的xml文件。这该怎么做?
例:
if ( $_SERVER['REQUEST_METHOD'] === 'POST' )
{
//Read the xmlinput and write to the file
$xml = file_get_contents('php://input');
// ..Do something..
return('<?xml version="1.0" encoding="utf-8"?><xml>Accepted</xml>');
}
我不知道如何在不启动新卷曲的情况下将xml发送回同一会话。
我们可以使用CGI吗?如果是这样,怎么样?
你在使用SoapClient吗?如果是这样,它是否符合版本1.2?
<?php
// ...
$client = new SoapClient('some.wsdl', ['soap_version' => SOAP_1_2]);
您可以输出(RFC7303取代RFC3023)。
<?php
// ...
header('Content-Type: text/html; charset=utf-8');
echo "<?xml version='1.0' encoding='UTF-8'?>";