http服务器 post xml文件,通过http接收xml文件post

我有一个测试脚本,通过http post发送xml文件,当我在内部使用它时,它似乎可以正常工作。当我将脚本移动到可从外部访问的Web服务器时,似乎没有任何事情发生。任何任何想法?通过http接收xml文件post

if ($_SERVER['REQUEST_METHOD'] == 'POST')

{

$inp = fopen("php://input");

$outp = fopen("xmlfile" . date("YmdHis") . ".xml", "w");

while (!feof($inp)) {

$buffer = fread($inp, 8192);

fwrite($outp, $buffer);

}

fclose($inp);

fclose($outp);

echo "

test responseOK";

}

?>

要发布的XML我使用卷曲,不知道这是否是问题?我不发送到安全连接(HTTPS):

function httpsPost($Url, $xml_data)

{

//Initialisation

$ch=curl_init();

//Set parameters

curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);

curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);

curl_setopt($ch, CURLOPT_URL, $Url);

//Return a variable instead of posting it directly

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//Activate the POST method

curl_setopt($ch, CURLOPT_POST, 1);

//Request

curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);

curl_setopt($ch, CURLOPT_TIMEOUT, 4);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

//execute the connexion

$result = curl_exec($ch);

//Close it

curl_close($ch);

return $result;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用curl命令进行POST请求发送XML文件,可以按照以下步骤进行操作: 1. 首先,将XML文件的内容保存到一个文件中,比如1.xml。 2. 然后,使用curl命令执行POST请求,并指定文件的路径作为数据参数。命令的格式如下: ``` cat 1.xml | curl -X POST -H 'Content-type:text/xml' -d @- http://1.1.1.1::8081/httpInvokeServlet ``` 这个命令会使用cat命令将1.xml文件的内容读取并通过管道传递给curl命令的-d参数。同时,通过-H参数指定请求头的Content-type为text/xml。 3. 替换命令中的1.xml为你实际的XML文件路径和文件名。 总结起来,使用curl命令发送POST请求并提交XML文件的步骤如下: 1. 将XML文件保存到一个文件中,比如1.xml。 2. 使用命令`cat 1.xml | curl -X POST -H 'Content-type:text/xml' -d @- http://1.1.1.1::8081/httpInvokeServlet`发送POST请求,并将文件内容作为数据参数传递给curl命令。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [curl模拟post json或post xml文件](https://blog.csdn.net/db9902943/article/details/101241250)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [如何用Curl 来post xml 数据](https://blog.csdn.net/weixin_30872671/article/details/95253137)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值