if ("Envelope".equalsIgnoreCase(localName) ||
"Header".equalsIgnoreCase(localName) || "Body".equalsIgnoreCase(localName)) {
log.severe("SAAJ0103.impl.cannot.add.fragements");
throw new SOAPExceptionImpl(
"Cannot add fragments which contain elements "
+ "which are in the SOAP namespace");
}
if ("Fault".equalsIgnoreCase(localName) && !"Body".equalsIgnoreCase(this.getLocalName())) {
log.severe("SAAJ0154.impl.adding.fault.to.nonbody");
throw new SOAPExceptionImpl("Cannot add a SOAPFault as a child of " + this.getLocalName());
}
if ("Detail".equalsIgnoreCase(localName) && !"Fault".equalsIgnoreCase(this.getLocalName())) {
log.severe("SAAJ0155.impl.adding.detail.nonfault");
throw new SOAPExceptionImpl("Cannot add a Detail as a child of " + this.getLocalName());
}
if ("Fault".equalsIgnoreCase(localName)) {
// if body is not empty throw an exception
if (!elementURI.equals(this.getElementName().getURI())) {
log.severe("SAAJ0158.impl.version.mismatch.fault");
throw new SOAPExceptionImpl("SOAP Version mismatch encountered when trying to add SOAPFault to SOAPBody");
}
Iterator it = this.getChildElements();
if (it.hasNext()) {
log.severe("SAAJ0156.impl.adding.fault.error");
throw new SOAPExceptionImpl("Cannot add SOAPFault as a child of a non-Empty SOAPBody");
}
}
}
// preserve the encodingStyle attr as it may get lost in the import