In my servlet, I tried to form XML string; however, I got
the following error message when running it.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
org.w3c.dom.DOMException: DOM005 Wrong document
at org.apache.xerces.dom.ParentNode.internalInsertBefore(ParentNode.java,
Compiled Code)
at org.apache.xerces.dom.ParentNode.insertBefore(ParentNode.java,
Compiled Code)
at org.apache.xerces.dom.NodeImpl.appendChild(NodeImpl.java,
Compiled Code)
at NCustomerResult.NCustomer_comp(NCustomerResult.java, Compiled
Code)
at NCustomerResult.main(NCustomerResult.java, Compiled Code)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
In main(), NCustomerResult() is called to build xml using another class
called xmlTranslator.
public void NCustomer_comp(String action,String name,String contact_name,
String contact_num, String des)
{
System.out.println("NCustomerResult::NCustomer_comp,
Entering NCustomer_comp...");
try {
Hashtable attribute = new
Hashtable();
attribute.put("msg_corrid",
"abc4567890");
attribute.put("sessionid",
"ABCDEFGHIJKLMNOP1234567");
attribute.put("comp_corrid",
"123456");
attribute.put("asyn_flag",
"N");
attribute.put("contact_name",
contact_name);
attribute.put("contact_number",
contact_num);
attribute.put("description",
des);
xmlTranslator xmlT = new
xmlTranslator();
Element comp = xmlT.buildXMLCover(action,
attribute, "CUSTOMER");
// Build up an XML Document
key = docIn.createElement("CUSTOMER_KEY");
key.setAttribute("name",
name);
key.setAttribute("provider_name",
"KHT");
comp.appendChild(key);
// PROBLEM CODE <-----------------
// Send it to the
Servlet
// buildXML a = new
buildXML(args[0]);
//Document docOut
= sendRequest(docIn);
// Debug - write the
sent
// Document to stdout
XMLSerializer ser
= new XMLSerializer(System.out, null);
ser.serialize(docIn);
}
catch (Throwable e) {
e.printStackTrace();
}
}
In the error, it saids "DOM005 Wrong document". Is anything wrong
with "key" passed to appendChild()?
When I placed buildXMLCover() into the same file instead of in a different
class, it worked. Does anyone know
what's wrong with it? I'm new to Java servlet and XML, and have
tried to debug this for two days. I really
appreciate any comments you may have.
-chanel
-- Alcatel USA, Inc. 1000 Coit Road, Plano, Texas 75075 ******* The opinions expressed are not those of Alcatel USA, Inc. *******
