• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

How do you see the xml being sent when you invoke a service on a JAX-WS generated client?

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I generated client classes from wsimport for a wsdl I am supposed to interface with. When I invoke a method on the web service, e.g. public FooResponse getFoo(FooRequest request), is there a way to view the xml that is being sent to the service?

Thanks,
Rob
 
Greenhorn
Posts: 5
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use wsmonitor

This tool, wsmonitor, is a light-weight, easy to use SOAP and HTTP traffic monitoring tool. This tool uses port forwarding to capture the SOAP messages and HTTP headers between a sender and a receiver and displays them nicely formatted in a graphical user interface.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SOAPui is another widely used tool for this.

Bill
 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can I log the SOAP XML into the log file?
How can I?

I have the object that is being passed to the web service function.

Let say

enquire(Employee e)


I want the contents of the SOAP request XML to be logged into the log file for later debugging if required.

Is it possible?
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using any frameworks like Apache CXF or Metro.. for your webservices or client?
 
Rob Dennett
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I too would like to know how to log the xml request and response (and preferably intercept it so I can scrub it). I am just using the client I generated from wsimport. I don't believe I am using cxf or metro or axis, but I am not that experienced with web services. The client is running out of a Tomcat instance.

Can you create a javax.xml.ws.handler.LogicalHandler and use that to act as a filter?

Thanks,
Rob
 
Rob Dennett
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It worked. I created a class that implements LogicalHandler<LogicalMessageContext> and cast the service stub to a javax.xml.ws.BindingProvider and added handler to the binding provider's binding's handler chain.

Rob
 
Yogesh Gandhi
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
rob,

i am very new to webservices.
can you please share the detailed code and steps using which anyone can log webservices into log file.

i am ready to write a blog on this information so that people googling it can find it on net.

request you to please share detailed steps and code if possible for beginners.
 
Rob Dennett
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well the way it works is that I created a class which implements javax.xml.ws.handler.LogicalHandler<javax.xml.ws.handler.LogicalMessageContext>. In the handleMessage method, I take the LogicalMessageContext and extract the javax.xml.ws.LogicalMessage from it and use a javax.xml.transform.Transformer to transform javax.xml.ws.LogicalMessage.getPayload() into a StreamResult (which is wrapping a ByteArrayOutputStream().



 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using METRO 2.0 library, you can do the following in your code to see HTTP Request/Response on console(client side setting).

HttpTransportPipe.dump = true;


package to import:
import com.sun.xml.ws.transport.http.client.HttpTransportPipe;

You can do this just before invoking SOAP Call.

Thanks
Chintan.
reply
    Bookmark Topic Watch Topic
  • New Topic