• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

How to get document object From SOAP Message?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.



What are the options experts can hint at?
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
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.
Best wishes!
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
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:

Best wishes!
 
chaitu sravs
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Any ideas?
 
chaitu sravs
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)?
 
chaitu sravs
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never mind the original problem.

We were able to use the code at http://www.troubleshooters.com/tpromag/200103/codexercises.htm#_domwalkerjava to flat-walk a DOM tree from SOAPPart.

We are now left with only the problem of how to make the MessageFactory work for 'both versions'.

Thanks.
 
Space seems cool in the movies, but once you get out there, it is super boring. Now for a fascinating tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic