Iterator eachChild = getChildElementNodes();
if (eachChild.hasNext()) {
firstChild = (SOAPElement) eachChild.next();
if (firstChild.getElementName().equals(headerName)) {
log.severe("SAAJ0120.impl.header.already.exists");
throw new SOAPExceptionImpl("Can't add a header when one is already present.");
} else if (!firstChild.getElementName().equals(bodyName)) {
log.severe("SAAJ0121.impl.invalid.first.child.of.envelope");
throw new SOAPExceptionImpl("First child of Envelope must be either a Header or Body");
}
}
header = (HeaderImpl) createElement(headerName);
insertBefore(header, firstChild);