如何在服务器端或客户端以编程方式记录SOAP消息和HTTP标头?



一直在搜索很长时间和测试。

我只想将肥皂消息详细信息和传输协议请求/响应(标题)和它一起记录。

到目前为止找到了

- 处理程序 ..要输出肥皂消息作为控制台上的RAW XML,这是非常好的解决方案。但是,对于 http header( mimeheaders 使用)似乎输出似乎太少了。例如,在客户端我只会得到

Accept : text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Content-Type : text/xml; charset=utf-8
Content-Length : 260

- 系统属性

System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true");
System.setProperty("com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump", "true");
System.setProperty("com.sun.xml.ws.util.pipe.StandaloneTubeAssembler.dump", "true");
System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true");
System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true");

这是控制台的输出,完整的HTTP标头&肥皂消息。但不是可自定义 - 可用于记录,操纵标题/消息。这是一个样本

---[HTTP request - http://localhost:8080/Testmart/TestMartCatalogService]---
Accept: text/xml, multipart/related
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
User-Agent: JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e
<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:getProducts xmlns:ns2="http://www.testmart.com"><arg0>books</arg0></ns2:getProducts></S:Body></S:Envelope>--------------------
---[HTTP response - http://localhost:8080/Testmart/TestMartCatalogService - 200]---
null: HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 414
Content-Type: text/xml;charset=UTF-8
Date: Sat, 30 Sep 2017 11:42:56 GMT
Server: JBoss-EAP/7
X-Powered-By: Undertow/1
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/><soap:Body><ns1:getProductsResponse xmlns:ns1="http://www.testmart.com"><return xmlns=""><item>Inferno</item><item>Joyland</item><item>The Game Of Thrones</item></return></ns1:getProductsResponse><TestBodyElement>hahahaha</TestBodyElement></soap:Body></soap:Envelope>--------------------

- Eclipse TCP/IP Monitor或Wireshark

两者都非常适合作为以前的解决方案监视,但是像第一个具有这样的输出(或以前)解决方案的程序化解决方案非常适合在代码中控制它。

那么,是否有其他方法或我可能会错过的东西,例如处理程序或在处理程序中会像转储配置一样输出细节?任何建议都非常感谢。

解决方案i是通过使用getResponseContext()

Map<String, Object> responseHeaders;
responseHeaders = sourceDispatch.getResponseContext();
Object cookie = responseHeaders.get("javax.xml.ws.http.response.headers");

最新更新