Hi Robert ----- Original Message ----- From: "Robert J. Lebowitz" <[EMAIL PROTECTED]> > I've scanned the dom4j documentation for an answer to this question, perhaps > the easiest way to find an answer is to simply ask. > > I was quite pleased to see that the new JAXM implementation is based on > dom4j. I'm currently looking at working on a project where I would make use > of both JAXM and JAXB (binding) to send and receive instances of class > objects via HTTP. I realize that although all my work is done with Java, > and RMI is certainly a possibility, I'm interested in experimenting with > SOAP, and JAXB as a self-learning process. > > My idea is to have software that uses JAXM to send and receive SOAP > messages, extract the message body, and "unmarshall" the xml using JAXB to > convert it back into an instance of Java class. > > JAXB's unmarshalling methods require an InputStream (or XMLScanner, whatever > that is) to work. So, I need to come up with a way to create an InputStream > from the SOAP message body document. I was looking around for some kind of > "obvious" method associated with the SOAPElement, SOAPNode, etc. classes > that allow you to "get" an InputStream from say, the root node, but I didn't > see one.
I missed it too; I think it needs to be part of a JAXM FAQ as its easy to miss. Firstly its good to remember that in JAXM, SOAPMessage represents a container of the XML SOAP document and possibly additional attachments. So its kinda like the MIME container. Whenever looking for how to interact with the SOAP XML document, look at the SOAPPart class in JAXM which represents the XML document - from there you can get hold of the SOAPEnvelope. In addition you can get and set the XML content of the document using a JAXP Source. The getContent() returns a JAXP Source (from javax.xml.transform.Source) so you should be able to use this to pipe the XML into any other JAXP compliant model or mechansim. > What would be the most efficient way to pull this off in dom4j (and > therefore, I assume JAXM)? JAXM uses dom4j as the SOAP XML model for SOAPEnvelope, SOAPHeader etc. If you want to go straight from the incoming SOAP message stream straight to JAXB as fast as possible then you're probably best off avoiding the JAXM SOAP API (SOAPEnvelope, SOAPHeader etc) and just using the JAXP Source to go straight through to JAXB. So just using the SOAPMessage & SOAPPart classes. Otherwise you'll be going through an intermediate XML representation. BTW while we're talking about JAXM here, the new JAX-Pack is out now http://java.sun.com/xml/javaxmlpack.html James _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user
