protected OMElement constructNode(OMElement parent, String elementName,
boolean isEnvelope) {
OMElement element = null;
if (parent == null) {
if (!elementName.equalsIgnoreCase(SOAPConstants.SOAPENVELOPE_LOCAL_NAME)) {
throw new SOAPProcessingException("First Element must contain the local name, "
+ SOAPConstants.SOAPENVELOPE_LOCAL_NAME, SOAPConstants.FAULT_CODE_VERSION_MISMATCH);
}
envelope =
(SOAPEnvelopeImpl) soapFactory.createSOAPEnvelope(this);
element = envelope;
processNamespaceData(element, true);
// fill in the attributes
processAttributes(element);
} else if (elementLevel == 2) {
// this is either a header or a body
if (elementName.equals(SOAPConstants.HEADER_LOCAL_NAME)) {
if (headerPresent) {
throw new SOAPProcessingException("Multiple headers encountered!", getSenderFaultCode());
}
if (bodyPresent) {
throw new SOAPProcessingException("Header Body wrong order!", getSenderFaultCode());
}
headerPresent = true;
element =
soapFactory.createSOAPHeader((SOAPEnvelope) parent,
this);
// envelope.setHeader((SOAPHeader)element);
processNamespaceData(element, true);
processAttributes(element);
} else if (elementName.equals(SOAPConstants.BODY_LOCAL_NAME)) {
if (bodyPresent) {
throw new SOAPProcessingException("Multiple body elements encountered", getSenderFaultCode());
}
bodyPresent = true;
element =
soapFactory.createSOAPBody((SOAPEnvelope) parent,
this);
// envelope.setBody((SOAPBody)element);
processNamespaceData(element, true);
processAttributes(element);
} else {
throw new SOAPProcessingException(elementName
+
" is not supported here. Envelope can not have elements other than Header and Body.", getSenderFaultCode());
}
} else if ((elementLevel == 3)
&&
parent.getLocalName().equalsIgnoreCase(SOAPConstants.HEADER_LOCAL_NAME)) {
// this is a headerblock
try {
element =
soapFactory.createSOAPHeaderBlock(elementName, null,
(SOAPHeader) parent, this);
} catch (SOAPProcessingException e) {
throw new SOAPProcessingException("Can not create SOAPHeader block", getReceiverFaultCode(), e);
}
processNamespaceData(element, false);
processAttributes(element);
} else if ((elementLevel == 3) &&