我的工作与我有关。但我遇到一个问题。 我将 xml 格式的数据发布到服务器,这是一个 Web 服务接口(interface)。
这是我的代码:
curl --data @feeqry.xml -H "SOAPAction: " -H "Content-Type:text/xml" -v http://myservice-interface
但是服务器返回如下: 没有 SOAPAction header !
所以我检查了数据发布,没有发送 SOAPAction header 。但 Content-Type header 在列表中,所以我的代码有问题吗?标题“SOAPAction”不必填充值,我在 python 和 loadrunner 脚本中完成了此操作,它运行良好。 在Python中,我这样定义标题:
h = {'SOAPAction':'', 'Content-Type':'text/xml'}
在 loadrunner 脚本中,我添加如下 header :
web_add_header("SOAPAction","\"\"");
两者都运作良好..所以请帮助我解决这个问题。非常感谢大家。
ps:原谅我糟糕的英语。
发布信息:
About to connect() to my server port 8888 (#0)
* Trying my server...
* Connected to my server (my server) port 8888 (#0)
> POST /my interface path HTTP/1.1
> User-Agent: curl/7.29.0
> Host: my server:8888
> Accept: */*
> Content-Type:text/xml
> Content-Length: 1299
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
< HTTP/1.1 500 Internal Server Error
< Date: Thu, 26 Nov 2015 12:09:20 GMT
< Connection: close
< Transfer-Encoding: chunked
< Content-Type: text/xml; charset=utf-8
< Content-Language: zh-CN
最佳答案
我在网站上得到了解决方案:http://curl.haxx.se/docs/manpage.html#-H 通过在冒号右侧提供不带内容的替换来删除内部 header ,如:-H“Host:”。如果您发送无值的自定义 header ,则其 header 必须以分号终止,例如 -H "X-Custom-Header;"发送“X-Custom-Header:”。
关于linux - 为什么curl没有发布我的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33938686/