java 如何在Web服务调用期间拦截xml响应和请求?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/486864/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 12:36:30  来源:igfitidea点击:

How to intercept xml response and request during web service invocation?

javajaxbjax-ws

提问by mgamer

I wonder if there is some neat way to intercept xml request send during java webservice method invocation and xml given in response? I don't want to print those xmls to standard output but to "catch" them in some string.

我想知道是否有一些巧妙的方法来拦截在 java webservice 方法调用期间发送的 xml 请求和响应中给出的 xml?我不想将这些 xml 打印到标准输出,而是在某个字符串中“捕获”它们。

回答by krosenvold

Yes, normally you use a soap proxy like soapUI. Simply point your webservice client at the proxy and the proxy at the real service.

是的,通常您使用像soapUI这样的soap代理。只需将您的 Web 服务客户端指向代理,将代理指向实际服务。

回答by Chris Nava

Fiddler or SoapUI will let you see and even CHANGE the request/response in route.

Fiddler 或 SoapUI 将让您查看甚至更改路由中的请求/响应。

回答by OscarRyz

Yes, you can use a packet sniffer and see what's in your traffic.

是的,您可以使用数据包嗅探器来查看流量中的内容。

I have never got that far.

我从来没有走那么远。

What I have used is a very simple home made protocol, that reads all the input, print it and re-send all the info.

我使用的是一个非常简单的自制协议,它读取所有输入,打印它并重新发送所有信息。

回答by Jeroen van Bergen

If you can deploy servlets on the server providing the web service you might consider writing and deploying a simple Filter. You can use this to log both the inbound and the outbound traffic.

如果您可以在提供 Web 服务的服务器上部署 servlet,您可能会考虑编写和部署一个简单的过滤器。您可以使用它来记录入站和出站流量。