Convert Node to Document ?

Hi All,

I am using xmlbeans for in my webservice client. i am calling the webservice usgin SOAP APIs. I am facing a problem :

I created the jar file out of my wsdl then instantiated one of the classes. Now i need to add the object in the SOAPMessage object, for which I did this:

Node nd = myInstance.getDomNode();

// Here I am getting error. I am not able to cast Node nd to a Document.

SOAPBodyElement ele = soapBodyInstance.addDocument((Document) nd);

Is there any other way to convert a node into document?

[586 byte] By [arpan_cyba] at [2007-11-26 16:46:19]
# 1

You can only perform casting in the reverse order ((Node)Document) because the Document interface is subclassed from the Node interface. Instead, you should do something like this:Node nd = myInstance.getDomNode();

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder parser = factory.newDocumentBuilder();

DOMImplementation domImpl = parser.getDOMImplementation();

Document doc = domImpl.createDocument(null, nd, null);

SOAPBodyElement ele = soapBodyInstance.addDocument(doc);

prgguya at 2007-7-8 23:13:44 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...