如何将 XML 字符串 POST 到 Web 服务进行测试?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1244433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I POST an XML string to a webservice for testing?
提问by Priyank
We have developed a RESTful web service which expects an XML string to arrive as "parameter". For QA to test the web service, I am looking for a simple way to POST an XML string to a URL, then display the XML response from the server.
我们开发了一个 RESTful Web 服务,它期望一个 XML 字符串作为“参数”到达。为了让 QA 测试 Web 服务,我正在寻找一种将 XML 字符串 POST 到 URL,然后显示来自服务器的 XML 响应的简单方法。
Is there an easy way to POST an XML string to a URL?
有没有一种简单的方法可以将 XML 字符串发布到 URL?
回答by ohnoes
Get the Firefox Poster add-on.
获取Firefox 海报插件。
A developer tool for interacting with web services and other web resources that lets you make HTTP requests, set the entity body, and content type. This allows you to interact with web services and inspect the results.
用于与 Web 服务和其他 Web 资源交互的开发人员工具,可让您发出 HTTP 请求、设置实体主体和内容类型。这允许您与 Web 服务交互并检查结果。
回答by David Aleu
I used wget for that, there are Windows and Linux versions. Not GUI either but no need of graphical interface for such simple task.
我为此使用了 wget,有 Windows 和 Linux 版本。也不是 GUI,但不需要图形界面来完成这样简单的任务。
For example:
例如:
wget "http://url_of_my_web_service?param1=123¶m2=abc" --post-file="xmlTestFile.xml" --header="Content-Type:text/xml"
Where the xmlTestFile.xml it's an xml file in the same directory you run the wget command.
其中 xmlTestFile.xml 是您运行 wget 命令的同一目录中的 xml 文件。
If you want to send a xml string instead of a xml file, use --post-data="string"
如果要发送 xml 字符串而不是 xml 文件,请使用 --post-data="string"
回答by John Saunders
回答by Steve Bennett
Chrome's DHC by Restletis pretty good. For some reason the "form" and "transformation" options are disabled for me though.
回答by jle
回答by helgatheviking
Obviously an old question, but google brought me here so I wanted to add another resource:
显然是一个老问题,但谷歌把我带到这里,所以我想添加另一个资源:
Tell it where to send the info, how you want it posted and the data you want to send and it will print out the response from the website.
告诉它在哪里发送信息,你希望它如何发布以及你想要发送的数据,它会打印出网站的响应。
回答by Giraldi
Just an addition to the Firefox add-on, since Posterseems out of date, you may try HttpRequester.
只是Firefox 插件的一个补充,因为Poster似乎已经过时,您可以尝试HttpRequester。
回答by Joxi
HttpMastercan be used for this testing scenario.
HttpMaster可用于此测试场景。
It supports XML posting (with possible parameters, if you need multiple requests in one batch) and viewers (raw and friendly) to view response. If you need only simple post and get, then it's quite possible that such full-fledged tools are simply too much; maybe some browser plugin could be sufficient for simple requests.
它支持 XML 发布(带有可能的参数,如果您需要一批中的多个请求)和查看器(原始和友好)来查看响应。如果你只需要简单的 post 和 get,那么这种成熟的工具很可能就太多了;也许一些浏览器插件足以满足简单的请求。
回答by alexknowshtml
If you're on OSX, HTTP Client App is incredibly useful for debugging HTTP services..headers, XML, whatever you like.
如果您使用的是 OSX,HTTP 客户端应用程序对于调试 HTTP 服务非常有用。标头、XML,无论您喜欢什么。

