You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by "Rafert, Tim" <tr...@tanning.com> on 2002/02/09 00:15:39 UTC

Body.unmarshall() removing the root element?

Given this XML:
 
<?xml version="1.0" encoding="UTF-8"?>
<REQUEST>
  <A>foo</A>
  <B>bar</B>
</REQUEST>
 
When I use the above xml as the bytes found in mInStream in the below code:
 
        DocumentBuilderFactory
mDocBuilderFactory=DocumentBuilderFactory.newInstance();
        DocumentBuilder mDocBuilder=mDocBuilderFactory.newDocumentBuilder();
        Document doc=mDocBuilder.parse(mInStream);
        Body mBody=Body.unmarshall(doc.getDocumentElement(),aSOAPContext);
        Envelope mEnvelope=new Envelope();
        mEnvelope.setBody(mBody);
 
The "REQUEST" element has disappeared.  Is that expected???  It appears to
throw away whatever the root element is within the xml.  Only "A" and "B"
are in the SOAP body and sent via SOAP.  If I put a bogus root element
enclosing all of the above xml then I get what I want (but I don't
understand why).  
 
Is the xml that is being unmarshalled into the BODY supposed to have a
"SOAP-ENV:Body" element around it?  When I tried that the parse was failing.
 
I'm using soap version 2.2
 
Thanks for any guidance.
Tim