5

Been searching for long on this and testing.

I want simply to log SOAP message details and the transport protocol request/response (header) along with it.

What I've found so far:

- Handlers .. to output the soap messages as raw xml on console output this is very good solution. However, for HTTP header (MimeHeaders used) it seems the output is too little. For example on client I get only

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

- System properties

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");

This is perfect as output to the console, full http headers & soap message. But not customize-able for logging, manipulating the header/message. Here is a sample

---[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 OR WireShark

Both are perfect for monitoring as the previous solution but programmatic solution like the first one with output like this (or previous) solution would extremely perfect to control it inside the code.

So is there another way or something I might missed to use like the Handlers or in the Handlers that would output details like the dump configuration does ? Any suggestions are very appreciated.

Community
  • 1
  • 1
Anddo
  • 2,144
  • 1
  • 14
  • 33
  • Answered here: https://stackoverflow.com/questions/1945618/tracing-xml-request-responses-with-jax-ws https://stackoverflow.com/questions/5350476/tracing-xml-request-responses-with-jax-ws-when-error-occurs – gavenkoa Mar 13 '19 at 12:38
  • First one already mentioned the question as **System properties** found solution, yet not the one that I can use or asked about. Thank you suggesting though. – Anddo Mar 13 '19 at 13:07
  • 2
    Look particularly at my https://stackoverflow.com/a/55141793/173149 Response headers are available via `BindingProvider.getResponseContext().get("javax.xml.ws.http.response.headers")`. Together it should provide all parts programatically at the end of request as attributes of map without forcing to follow any framework convention. – gavenkoa Mar 13 '19 at 13:33
  • 2
    https://www.javaworld.com/article/2077679/get-a-handle-on-the-jax-ws-api-s-handler-framework.html?page=2 – gavenkoa Mar 13 '19 at 13:34
  • 1
    Seems gavenkoa answered this ! It's perfect to be honest but needs testing – Muhammad Attia Jul 03 '19 at 07:34

1 Answers1

2

The solution I is by using getResponseContext()

Map<String, Object> responseHeaders;
responseHeaders = sourceDispatch.getResponseContext();
Object cookie = responseHeaders.get("javax.xml.ws.http.response.headers");
Muhammad Attia
  • 490
  • 3
  • 13