• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why IllegalArgumentException is being thrown?

 
Arsh Ahmad
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an XML Document consisting of SOAP Envelope and SOAP Body elements which is unmarshalled into a SOAP Envelope using the following code:

mEnv = org.apache.soap.Envelope.unmarshall(parentDoc.getDocumentElement());

where parentDoc contains the XML Document. This works fine.

But now I have added code to create a new Document consisting of a SOAP Header element which is added to parentDoc using the following:

parentRoot.insertBefore(hdrNode, bodyElem);

At this point the XML Document looks like the following:



But when unmarshalling this using the following code again:

mEnv = org.apache.soap.Envelope.unmarshall(parentDoc.getDocumentElement());

throws the following exception:

java.lang.IllegalArgumentException: An 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' element must contain a: 'http://schemas.xmlsoap.org/soap/envelope/:Body' element.

Can anybody tell me why this exception is being thrown, when the XML clearly has the Body element?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!