A node cannot be part of two DOMs, you'll need to detach it from one and
import it into the SOAPMessage DOM,
Kevin Jones
http://kevinj.develop.com
> -----Original Message-----
> From: Karr, David [mailto:David.Karr_at_wamu.net]
> Sent: 05 December 2003 22:18
> To: users_at_jax-rpc.dev.java.net
> Subject: RE: Adding SOAPHeader children from a NodeList
>
>
> I need a real SOAPMessage. My downstream API is depending on that.
>
> So let's say I've parsed a document into a Document. I've
> created an empty SOAPMessage. I've found an Element that I
> want to just copy into my SOAPMessage header, along with
> other elements, either copied or created manually.
>
> I tried just using the "Node.appendChild(Node)" method, as
> SOAPElement is just a Node, as you say. Unfortunately, this
> failed with:
>
> ---------------
> WRONG_DOCUMENT_ERR: A node is used in a different document
> than the one that created it.
> org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used
> in a different document than the one that created it.
> at org.apache.xerces.dom.ParentNode.internalInsertBefore(Unknown
> Source)
> at org.apache.xerces.dom.ParentNode.insertBefore(Unknown Source)
> at org.apache.xerces.dom.NodeImpl.appendChild(Unknown Source)
> ---------------
>
> I tried passing the node to be copied through
> "cloneNode(true)", but that had no effect.
>
> > -----Original Message-----
> > From: Kevin Jones [mailto:kevinj_at_develop.com]
> >
> > Do you actually need a SOAPMessage or do you need a SOAP message?
> >
> > I find that using SAAJ to build anything apart from a SOAP fault a
> > complete pain. You're almost certainly better off in this
> case using
> > DOM/JDOM/StAX/JAXB rather than SAAJ.
> >
> > Even if you need a SOAPMessage you can build the data using
> one of the
> > other APIs and then import it (call addDocument on the
> SOAPBody), and
> > remember that in the latest version of SAAJ everything is an
> > org.w3c.dom.Node, so at the very least you can treat it like a DOM.
> >
> > BTW, SAAJ like many Java APIs is factory based to allow for
> multiple
> > implementations which makes the API harder to use and in
> the case of
> > SAAJ, which is a relatively simple API, is something of an overkill
> > (IMHO of course),
> >
> > Kevin Jones
> > http://kevinj.develop.com
> >
> > > -----Original Message-----
> > > From: Karr, David [mailto:David.Karr_at_wamu.net]
> > > Sent: 04 December 2003 21:49
> > > To: users_at_jax-rpc.dev.java.net
> > > Subject: Adding SOAPHeader children from a NodeList
> > >
> > >
> > > I'm trying to construct a SOAPMessage from a message that is
> > > "soap-like". It has a "header" element and a "body" element,
> > > but it doesn't quite match the SOAP 1.1 schema, so I can't
> > > create a SOAPMessage directly from it.
> > >
> > > So, I need to create an empty SOAPMessage and then add pieces
> > > to it. I'm trying to figure out the easiest way to get some
> > > of this done. It appears that I have to take the SOAPHeader
> > > object obtained from the SOAPMessage and use the
> > > "addChildElement(SOAPElement)" method from the SOAPElement
> > > base class. It appears that I can't create SOAPElement
> > > objects directly, I have to use the
> > > "SOAPFactory.createElement()" method. This has overloaded
> > > versions of "(name)", "(localName)", and "(localName,
> prefix, uri)".
> > >
> > > It appears that I have to create a SOAPElement using a
> > > particular name (copied from the original), and then manually
> > > add the content of that element.
> > >
> > > Isn't there an easier way to do this?
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
> > > For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
> > >
> > >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
> > For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
> For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net