-
1. Re: How Do I See the XML?
oskar.carlstedt Mar 22, 2007 4:44 AM (in response to flindet)Hi!
You can always turn on TRACE debugging on the ws messages. There is an uncommented row in the JBOSS_HOME/server/default/conf/log4j.xml. Now you will see the messages in the JBOSS_HOME/server/default/log/server.log file.
By default the CONSOLE-appender in log4j.xml has a threshold parameter set to INFO. This makes log4j to reject all messages with lower priority than this value. If you set threshold to TRACE you will get a lot of info, more than you want.
You can always create a handler (http://jbws.dyndns.org/mediawiki/index.php/JAX-WS_User_Guide#Handler_Framework) to monitor the result of the ws, but it might be tricky. Another way is to create an http filter (http://java.sun.com/products/servlet/Filters.html) that will check your incoming request and outgoing response.
Best
Oskar
[/url] -
2. Re: How Do I See the XML?
oskar.carlstedt Mar 22, 2007 4:47 AM (in response to flindet)Sorry, the links got messed.
JBossWS Handler: http://jbws.dyndns.org/mediawiki/index.php/JAX-WS_User_Guide#Handler_Framework
Servlet filter: http://java.sun.com/products/servlet/Filters.html
//Oskar -
3. Re: How Do I See the XML?
qpool.char Mar 22, 2007 6:29 AM (in response to flindet)There is also a tool called "wsmonitor" that is quickly configured. It receives the incoming request on a certain port, prints it out and forwards it to the service endpoint.
Therefore you have to change the service endpoint location in your client, perhaps by setting the BindingProperties. -
4. Re: How Do I See the XML?
flindet Mar 22, 2007 12:27 PM (in response to flindet)Thanks, guys. This is all great advice. I appreciate it.
-
5. Re: How Do I See the XML?
flindet Mar 22, 2007 12:31 PM (in response to flindet)By the way, oskar, I got the handler working. This is very nice. ;-)
-
6. Re: How Do I See the XML?
rmartony Mar 30, 2007 10:36 AM (in response to flindet)I created a handler, how can I print out the XML of the incoming request?
I have the SOAPMessage, SOAPHeader and SOAPBody.
What should I do next?
I'm using JBossWS-1.0.4.GA, installed into JBoss AS 4.0.5.GA.
Regards,
Rafael. -
7. Re: How Do I See the XML?
joshlam Mar 30, 2007 2:02 PM (in response to flindet)You can try something like:
public boolean handleMessage(SOAPMessageContext ctx) { boolean outbound= ((Boolean)ctx.get(SOAPMessageContext.MESSAGE_OUTBOUND_PROPERTY)).booleanValue(); SOAPMessage m = ctx.getMessage(); ByteArrayOutputStream bo = new ByteArrayOutputStream(); try { if (outbound) { m.writeTo(bo); System.out.println("Outbound: "+bo.toString()); } else // inbound { m.writeTo(bo); System.out.println("Inbound: "+bo.toString()); } } catch (SOAPException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } return true; }
-
8. Re: How Do I See the XML?
flindet Apr 6, 2007 12:24 PM (in response to flindet)rmartony, here's what I ended up doing to log my full SOAP message. It's based heavily on the example handlers included with JBossWS.
public class ProtocolHandler extends GenericSOAPHandler { /** * The {@link Logger} used for writing logging messages. */ private static Logger log = Logger.getLogger(ProtocolHandler.class); /* (non-Javadoc) * @see org.jboss.ws.core.jaxws.handler.GenericSOAPHandler#handleOutbound(javax.xml.ws.handler.MessageContext) */ @Override public boolean handleOutbound(final MessageContext msgContext) { if (log.isInfoEnabled()) { return logMessage(msgContext); } return true; } /* (non-Javadoc) * @see org.jboss.ws.core.jaxws.handler.GenericSOAPHandler#handleInbound(javax.xml.ws.handler.MessageContext) */ @Override public boolean handleInbound(final MessageContext msgContext) { if (log.isInfoEnabled()) { return logMessage(msgContext); } return true; } /** * Logs the full SOAP message. * * @param messageContext The message context containing the SOAP message to be handled. * @return True if handler processing should continue, false otherwise. * @throws WebServiceException If the SOAP message is malformed. */ private boolean logMessage(final MessageContext messageContext) { try { SOAPMessage soapMessage = ((SOAPMessageContext) messageContext).getMessage(); if (soapMessage.getSOAPBody().getChildElements().hasNext()) { SOAPElement soapElement = (SOAPElement) soapMessage.getSOAPBody().getChildElements().next(); if (soapElement.getChildElements().hasNext()) { soapElement = (SOAPElement) soapElement.getChildElements().next(); ByteArrayOutputStream xmlStream = new ByteArrayOutputStream(); soapMessage.writeTo(xmlStream); log.info(new String(xmlStream.toByteArray())); } } return true; } catch (SOAPException ex) { throw new WebServiceException(ex); } catch (IOException ex) { throw new WebServiceException(ex); } } }
-
9. Re: How Do I See the XML?
rmartony Apr 10, 2007 11:03 AM (in response to flindet)Hi flindet and joshlam, thank you very much for your help.
Regards,
Rafael.