简体   繁体   English

如何捕获Java应用发送的SOAP请求

[英]How to capture the SOAP request send by the java app

I have a REST API written in java and spring which makes a backend call to a SOAP service. 我有一个用Java和spring编写的REST API,它对SOAP服务进行了后端调用。 The SOAP web service code are packaged in a 3rd party jar. SOAP Web服务代码打包在第3方jar中。 So don't have access to change the code. 因此,无权更改代码。 But I can change the SOAP service endpoint by setting a env variable. 但是我可以通过设置env变量来更改SOAP服务端点。

How can I capture the raw SOAP request sent by the REST API? 如何捕获REST API发送的原始SOAP请求?

You can intercept the SOAP Request by using number of tools. 您可以使用多种工具来拦截SOAP请求。

I would suggest either use TCPMonitor ( https://ws.apache.org/tcpmon/tcpmontutorial.html ) or wiresharks ( https://www.wireshark.org/ ). 我建议使用TCPMonitor( https://ws.apache.org/tcpmon/tcpmontutorial.html )或wiresharks( https://www.wireshark.org/ )。

TCPMonitor acts like a proxy (So your endpoint should point to TCPMonitor), and it will relay the message back to your service. TCPMonitor的作用类似于代理(因此,您的端点应指向TCPMonitor),它将把消息中继回您的服务。

Wireshark is a network protocol analyser. Wireshark是网络协议分析器。 It captures all the TCP/UDP packets (which includes the HTTP as well). 它捕获所有TCP / UDP数据包(也包括HTTP)。 You just have to capture the packets. 您只需要捕获数据包。 No modifications from server and client ends required. 无需服务器端和客户端进行任何修改。 You can then filter the HTTP/HTTPS packets to look for your requests. 然后,您可以过滤HTTP / HTTPS数据包以查找您的请求。

You can always use a network packet Analyser such as tcpdump or wireshark to capture packets sent specifically to your 'endpoint'. 您始终可以使用网络数据包分析器(例如tcpdumpwireshark)来捕获专门发送到“端点”的数据包。

ALTERNATIVELY 另外

You can write a tiny proxy to capture requests on a local port and forward them to the actual endpoint and route response after printing it to sys-out. 您可以编写一个微型代理以捕获本地端口上的请求,并将请求转发到实际端点,并在将请求打印到sys-out之后路由响应。 You, in that case, will specify the proxy as the endpoint to your program. 在这种情况下,您将指定代理作为程序的终结点。

I am not sure of any existing proxy which does that, but I think haproxy will not . 我不确定是否有现有的代理可以这样做,但是我认为haproxy不会

如果您使用的是Windows,则可以使用ProxyTracePocketSoap和其他PocketSoap.com工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM