Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pretty Print SOAP message

 
Daniel Larusso
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is kind of a newbie question... i'm trying to pretty print my request SOAP message after a javax.xml.rpc.GenericHandler implementation adds in some custom headers in my client code.

Any idea how i do this? I'm basically trying to log the contents of the SOAPEnvelope object. Here is the code im working with:

SOAPMessageContext smc = (SOAPMessageContext)context;
SOAPEnvelope se = smc.getMessage().getSOAPPart().getEnvelope();
 
Daniel Larusso
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry... I should have RTFM'ed a little more. SOAPMessage has a function called "writeTo" that takes an OutputStream... Solved the printing problem, but it doesn't pretty print the SOAP message.
 
Watsh Rajneesh
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the following code to pretty print the soap message xml (code excerpted from Writer.java samples code with XercesJ 2.8.0 distribution).


The usage for above writer is:
Writing to Stream:

Writing to std out:

where, xmlDoc is of type org.w3c.dom.Document but you can pass a SOAPMessage org.w3c.dom.Node type too.
[ September 11, 2006: Message edited by: Watsh Rajneesh ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic