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.
Trying to see if the SOAP MessageFactory can use xerces2 Dom Implementation while exposing the SOAPPart.
Joined: Oct 21, 2009
Also, just curious...
# or to allow for both versions of SOAP messages. The latter allow
# * for processing of incoming SOAP 1.1 and 1.2 messages
How would one go about that? I did not find any appropriate SOAPConstant entry for 'both' versions. Just do an AND (&) operation on the two constants (1.1 & 1.2)?