add DOM Document to SOAP Body (JAXM)
2 posts in topic
Flat View  Flat View

Posted By:   Mighty_Moses
Posted On:   Thursday, April 4, 2002 05:44 AM

I'm wondering how to add a DOM Tree as the Body content of a SOAPEnvelope. Am I blind ?


I have a xml document (lets say in a file or already parsed to a DOM-document). Now i want to send this using SOAP (utilizing JAXM). How to accomplish this ? I only found extensive methods for operation on the elements itself, but nothing for the case you already have the content.
Please help!

Re: add DOM Document to SOAP Body (JAXM)

Posted By:   Sharath_Jonnalagadda  
Posted On:   Thursday, April 18, 2002 02:21 AM

hai moses,

here is one such solution.

imagine sMessage as JAXM's SOAPMessage Classes object.

and imagine doc1 is the xml document which u have to add to the soap message

import org.dom4j.*;

DocumentSource source = (DocumentSource)


Document doc = source.getDocument();

Element elem = doc.getRootElement();

List elements = elem.elements();

Element body = elements.get(elements.size() -1);


DocumentSource dSource = new DocumentSource(doc1);




these steps should do the magic for u.



Re: add DOM Document to SOAP Body (JAXM)

Posted By:   vikas_pandya  
Posted On:   Thursday, April 4, 2002 10:45 AM

If you want to send xml document using SOAP(utilizing JAXM) then i would say easiest way to achieve this is using JAXM attachment (AttachmentPart API). pretty neat and clean way of sending documents as SOAP attachment.
About | Sitemap | Contact