您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php 怎么发送xml报文

2024/2/24 15:49:59发布20次查看
php 如何发送xml报文
post http/1.0
user-agent:
content-type: application/x-fox
content-length: nnnn
...

现在要发送如上格式的xml数据,试过curl但不成功,大家帮帮忙
------解决方案--------------------
curl是可以的,但是参数设置比较麻烦。这种情况有一些现成的类库实现,提供一个简单的示例
if( $_server['request_method'] === 'post' ){
// 接收
$content = file_get_contents('php://input');
$xml = simplexml_load_string($content);
echo 来自xml接收方的响应\n;
print_r( get_object_vars($xml) );
exit;
}
// 发送行为
$xml = < 'post',
'user_agent' => '',
'header' => content-type: application/x-www-form-urlencoded,
'content' => $xml
)
);
$context = stream_context_create($setting);
$url = 'http://localhost/'. $_server['request_uri'];
$response = file_get_contents($url, null, $context);
echo $response;
需要说明你的http请求示例中,请求内容实体与报头需要相隔两组\r\n。另外你的xml文件格式不正确,而且标签属性里还包含全角符号
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product