This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I want to extract the Document object containing the SOAP XML from the below raw SOAP Message that contains an attachment. Ideally, I want to be able to load the below content into a SOAPMessage and then extract the DOM for the XML alone.
Have you considered implementing a service endpoint implementation class that implements Provider<SOAPMessage>?
The Provider interface is located in the javax.xml.ws package - see the JDK 1.6 API documentation for more information!
In its invoke-method, you would then receive a SOAPMessage object, which you can manipulate and extract information from using SAAJ.
If you want to extract the raw XML before the request reaches the web service, I suggest using a handler.
Good to know. But the problem is the suggested options can work only during communication.
I want to be able to process it offline in a standalone program. No client/endpoint involved, just a file with the content posted previously.
Very nice problem here:
1. I tried loading the content into an inputstream and was able to create a SOAPMessage.
2. I tried several ways to get a DocumentTraversal object from the SOAPMessage (its SOAPPart etc).
3. It looks like there is no way I can get a DocumentTraversal enabled Document object from a SOAPMessage's SOAPPart.
Is there any?
Joined: Oct 04, 2006
Ah, you said nothing about reading a message from a file in your original post.
First you read the entire file and separate the MIME parts from the SOAP message. For each of the MIME headers, you create an object of the class javax.xml.soap.MimeHeader. Each MimeHeader instance is added to an instance of javax.xml.soap.MimeHeaders. Then you can use the SAAJ API to read the SOAP message, like in the following example:
Joined: Oct 21, 2009
Sure. We are doing the same and are able to get the SOAPMessage.
The XML inside is huge and we are trying to 'flat' iterate all the nodes using DocumentTraversal interface, but looks like SOAPPart cannot be casted to DocumentTraversal as it does not implement the interface.