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文件格式不正确,而且标签属性里还包含全角符号
