首页 > 解决方案 > 通过 curl 发出肥皂请求不起作用并且服务器返回“来自服务器的空回复”

问题描述

嗨,我正在尝试使用 curl 向肥皂端点发出发布请求。但是它不返回任何东西。然后是 curl 请求。

    curl -v -X POST --header "Content-Type: text/xml;charset=UTF-8"  --data @soap-req.xml http://192.168.123.219:8085/engage/stats
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 192.168.123.219...
* TCP_NODELAY set
* Connected to 192.168.123.219 (192.168.123.219) port 8085 (#0)
> POST /engage/stats HTTP/1.1
> Host: 192.168.123.219:8085
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Type: text/xml;charset=UTF-8
> Content-Length: 309
> 
* upload completely sent off: 309 out of 309 bytes
* Empty reply from server
* Connection #0 to host 192.168.123.219 left intact
curl: (52) Empty reply from server

以下是soap request 9 soap-req.xml文件的内容

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:eng="http://openmindnetworks.com/engage/">
   <soapenv:Header/>
   <soapenv:Body>
      <eng:getCampaignStats>
         <id>f4202b29-5db5-4cec-965f-70710fcdb60d</id>
      </eng:getCampaignStats>
   </soapenv:Body>
</soapenv:Envelope>

但是,当我使用肥皂 UI 时,它工作正常。

如果您能帮我解决问题,不胜感激

谢谢你

标签: httpunixcurlsoaplibcurl

解决方案


每当我提出肥皂请求时,我们都应该始终添加soapaction 标头。因为它丢失了,所以服务器的响应是空的。

curl  -H 'Content-Type: application/soap+xml; charset=UTF-8'
      -H 'SOAPAction: http://openmindnetworks.com/engage/getCampaignStats'
      --data @soap-req.xml http://192.168.123.219:8085/engage/stats

推荐阅读