A服务器上 生成xml,并模拟post请求到B服务器,其中红色的部分根据自身服务器实际情况调整,下面是直接请求本地(B服务器)的index.php文件
<INFO>
<InfoType>TESTINFO</InfoType>
<Version>1.0</Version>
<UserName>TEST</UserName>
<UserPwd>TEST</UserPwd>
</INFO>';
$header = "POST /index.php HTTP/1.0\r\n";
$header.= "Content-Type: text/xml\r\n";
$header.= "Content-Length: " . strlen($req) ."\r\n\r\n";
$fp = fsockopen(" localhost", 80, $errno, $errstr, 30);
fputs($fp, $header .$req);
while ( ! feof ( $fp ) )
{
$res = fgets ( $fp, 1024 );
var_dump($res).'<br />';
}
在index.php文件中 接受post过来的xml数据
echo $HTTP_RAW_POST_DATA 其中 $HTTP_RAW_POST_DATA 即为post过来的数据