200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > php http请求xml数据 使用php从HTTP POST请求中检索XML

php http请求xml数据 使用php从HTTP POST请求中检索XML

时间:2019-08-22 14:06:33

相关推荐

php http请求xml数据 使用php从HTTP POST请求中检索XML

我检查了类似的问题但没有解决我面临的问题.

我正在构建一个Web服务,我想从HTTP POST请求中检索XML数据,操纵数据并返回响应.编写脚本时应考虑以下信息:

The communication mode is HTTP POST (not SOAP)

The content type is text/xml.

The POST request will contain only XML

The request will be a RAW POST directly to stream and NOT in a parameter.

我试过但我的脚本没有从HTTP POST请求中捕获数据.

我的剧本:

$postData = file_get_contents('php://input');

if(!empty($xml->MerchantReference)){

$merchRef = (string)$xml->MerchantReference;

$custRef = (int)$xml->CustReference;

$username = (string)$xml->ServiceUsername;

$password = (string)$xml->ServicePassword;

$db->setQuery(Check if customer exists in database);

if($db->countResultset() == 0)

{

header("Content-type: text/xml");

echo "<?xml version='1.0' encoding='UTF-8'?>";

echo "";

echo "".$merchRef."";

echo "";

echo "";

echo "0";

echo "".$custRef."";

echo "";

echo "";

echo "";

echo "";

echo "";

echo "";

echo "Customer is valid";

echo "";

echo "";

echo "";

exit;

}

这是HTTP POST请求:

MY URL

12345

abcdef

HTTPGENERICv31

bill

123456

abcdef

0

检索并操作数据后,我的脚本将返回响应.这是响应的方式:

3527

0

4565

Customer is Valid

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。