aspose file tools*
The moose likes Web Services and the fly likes Can I use a SAXParser on a SOAPMessage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Can I use a SAXParser on a SOAPMessage" Watch "Can I use a SAXParser on a SOAPMessage" New topic
Author

Can I use a SAXParser on a SOAPMessage

Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Hi All,
I am new to SOAP so please forgive me if I mix apples and oranges here.
I have a java web app that uses soap and I need to parse a SoapMessage object. I would like to use the parse method of a SAXParser object to do this.
I have found a tutorial on using a SAXParser by extending an org.xml.sax.helpers.DefaultHandler class, but the example expects a user to parse a file, not a SOAPMessage. The parse method seems to expect a path to a file, and I am having trouble finding resources on making this work for a SOAPMessage. A lot of sites recommend using Axis, but I must work with SOAP as this is how another app I communicate with is set up.
Could anyone point me at a good resource that I could use that will help me to parse a javax.xml.soap.SOAPMessage object using SAX ?
Thanks!
Kim
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18114
    
    8

Well, there's the API documentation for a start. If you look at it, you will see that there are several overloaded versions of parse that allow you to parse not only from a File, but also (for example) from an InputStream.

But looking at the API documentation for SOAPMessage, I see that you can get a SOAPBody object from it, and a SOAPHeader object, and so on. The documentation for those two objects says that they implement org.w3c.Element. In other words, the parsing is already done for you if you get those objects. You can just use ordinary DOM-wrangling techniques to access the data.
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Thank you, that makes sense, maybe I am making this harder than it has to be. I will take a look at that.
Kim
 
 
subject: Can I use a SAXParser on a SOAPMessage
 
Similar Threads
SAX Parser
SAAJ API: recovering the SOAPMessage object from a soap message
how to pass the SOAPMessage object as argument to the server interface class from cli
Understanding how to write spring ws using JAXB
Sending requests in xml