检查 jersey 和 jaxb 生成的 REST 请求和响应
我有一个方法:
@PUT
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.TEXT_PLAIN)
public String createQueue(JAXBElement<Queue> queueElement) {
// do some stuff here
return "";
}
现在,当我从客户端 java 应用程序调用此服务时,我想检查已创建的 HTTP 请求。我想查看由 jaxb 创建的 XML(请求正文)。是否有工具可以观察在特定 URL 上发出的请求/响应?
预先感谢,安德烈亚斯
I have a method:
@PUT
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.TEXT_PLAIN)
public String createQueue(JAXBElement<Queue> queueElement) {
// do some stuff here
return "";
}
Now, when I call this service from my client java application, I would like to inspect the HTTP request that has been created. I want to see the XML (request body) that is created by jaxb. Is there a tool that can observe requests / responses that are made on a particular URL?
Thanks in advance, Andreas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用一个简单的程序来充当代理并显示 HTTP 请求。那里有很多。由于您使用的是 Java,我建议使用简单的 TcpMon。如果您也经常使用肥皂,则可以使用 soapui 中的内置监视器。如果您还想查看浏览器的流量,您可以考虑 fiddler。
You can use a simple program that will act as a proxy and display the HTTP requests. There are plenty out there. Since you are using Java I suggest a simple TcpMon. If you use soap a lot also, you can use the built in monitor in soapui. If you also want to watch traffic from your browsers, you might consider fiddler.
为此,我会使用 Firefox + Firebug,它有很好的网络面板。
For that I would use Firefox + Firebug, which has nice network panel.
Charles 的 UI 比 Fiddler 好得多
Charles 和 Fiddler 是代理调试器。
如果您只想嗅探 http 流量,我推荐 Wireshark,因为它嗅探以太网级别的流量,并且无需更改代理设置
Charles has a much better UI than Fiddler
Charles and Fiddler are proxy debuggers.
If you just want to sniff the http traffic I recommend Wireshark since it sniff the traffic at the Ethernet level and there is no proxy settings to change