Sunday, April 22, 2012

How to log SOAP Request and response XML in log file

Thanks to http://www.coderanch.com/t/549539/Web-Services/java/Convert-SOAP-response-SOAP-XmL
http://qa.netbeans.org/modules/j2ee/promo-g/end2end/hello_ws.html

It is mostly desired to log the SOAP request and response XML into log file.
But there is no direct way, using which you can log the XML, because the XML generation part is in the control of the webservice framework. But the good news that you can configure it to print the XML where ever you like it to.

Configure logging of XML on server side using Netbeans

Configure logging of XML on client side using Netbeans

How to convert SOAPMessage to a String

13 comments:

  1. thanks for this article

    ReplyDelete
  2. 1) The service.setHandlerResolver() thing did nothing on the client side, instead the add handler that you mention on the server side worked.
    2) You might want to correct the typoes, like soapmessagecontext and myhandler. And the ArrayList must be of type Handler, not myhandler.
    3) After doing all this it worked, so thank you nevertheless.

    ReplyDelete
  3. it worked for me. thanks a lot

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. I followed your instruction, but some reason it does not execute MyHandler class. I am using Websphere application server and used RAD to generated client stub (Generated By:JAX-WS RI IBM 2.1.6 in JDK 6 (JAXB RI IBM JAXB 2.1.10 in JDK 6). Please advise.

    ReplyDelete
    Replies
    1. This thing worked for me n websphere and is currently running in production. Visit source link, you might find something useful.

      Delete
    2. This thing worked for me n websphere and is currently running in production. Visit source link, you might find something useful.

      Delete
    3. I created handler-chain.xml and used @HandlerChain in my Service class for it to work. However, my next question is can I use the same SoapHandler implemented class to process different webservices.
      Thank you.

      Delete
    4. No. I think this can be used to process only 1 webservice as each webservice needs to have its own handler.

      Delete
  6. I need a java sample application to sign a SOAP request with a public key. Can someone help?

    ReplyDelete
  7. Here I leave a way to save the logs of soap messages with c#
    http://www.systemdeveloper.org/2014/06/tracesoapmessage

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Cool and I have a super offer: What Do House Renovations Cost split level home additions

    ReplyDelete