Element subchild = DOMUtil.getFirstChildElement(child);
if (subchild != null) {
details = new DOMSource(subchild);
subchild = DOMUtil.getNextSiblingElement(subchild);
if (subchild != null) {
throw new SoapFault(SoapFault.RECEIVER, "Multiple elements are not supported in Detail");
}
}
child = DOMUtil.getNextSiblingElement(child);
childname = DOMUtil.getQName(child);
}
// Nothing should be left
if (childname != null) {
throw new SoapFault(SoapFault.SENDER, "Unexpected element: " + childname);
}
// Parse soap 1.2 faults
} else {
// Fault code
Element child = DOMUtil.getFirstChildElement(element);
checkElementName(child, SoapMarshaler.SOAP_12_FAULTCODE);
Element subchild = DOMUtil.getFirstChildElement(child);
checkElementName(subchild, SoapMarshaler.SOAP_12_FAULTVALUE);
code = DOMUtil.createQName(subchild, DOMUtil.getElementText(subchild));
if (!SoapMarshaler.SOAP_12_CODE_DATAENCODINGUNKNOWN.equals(code) &&
!SoapMarshaler.SOAP_12_CODE_MUSTUNDERSTAND.equals(code) &&
!SoapMarshaler.SOAP_12_CODE_RECEIVER.equals(code) &&
!SoapMarshaler.SOAP_12_CODE_SENDER.equals(code) &&
!SoapMarshaler.SOAP_12_CODE_VERSIONMISMATCH.equals(code)) {
throw new SoapFault(SoapFault.SENDER, "Unexpected fault code: " + code);
}
subchild = DOMUtil.getNextSiblingElement(subchild);
if (subchild != null) {
checkElementName(subchild, SoapMarshaler.SOAP_12_FAULTSUBCODE);
Element subsubchild = DOMUtil.getFirstChildElement(subchild);
checkElementName(subsubchild, SoapMarshaler.SOAP_12_FAULTVALUE);
subcode = DOMUtil.createQName(subsubchild, DOMUtil.getElementText(subsubchild));
subsubchild = DOMUtil.getNextSiblingElement(subsubchild);
if (subsubchild != null) {
checkElementName(subsubchild, SoapMarshaler.SOAP_12_FAULTSUBCODE);
throw new SoapFault(SoapFault.RECEIVER, "Unsupported nested subcodes");
}
}
// Fault reason
child = DOMUtil.getNextSiblingElement(child);
checkElementName(child, SoapMarshaler.SOAP_12_FAULTREASON);
subchild = DOMUtil.getFirstChildElement(child);
checkElementName(subchild, SoapMarshaler.SOAP_12_FAULTTEXT);
reason = DOMUtil.getElementText(subchild);
subchild = DOMUtil.getNextSiblingElement(subchild);
if (subchild != null) {
throw new SoapFault(SoapFault.RECEIVER, "Unsupported multiple reasons");
}
// Fault node
child = DOMUtil.getNextSiblingElement(child);
QName childname = DOMUtil.getQName(child);
if (SoapMarshaler.SOAP_12_FAULTNODE.equals(childname)) {
node = URI.create(DOMUtil.getElementText(child));
child = DOMUtil.getNextSiblingElement(child);
childname = DOMUtil.getQName(child);
}
// Fault role
if (SoapMarshaler.SOAP_12_FAULTROLE.equals(childname)) {
role = URI.create(DOMUtil.getElementText(child));
child = DOMUtil.getNextSiblingElement(child);
childname = DOMUtil.getQName(child);
}
// Fault details
if (SoapMarshaler.SOAP_12_FAULTDETAIL.equals(childname)) {
subchild = DOMUtil.getFirstChildElement(child);
if (subchild != null) {
details = new DOMSource(subchild);
subchild = DOMUtil.getNextSiblingElement(subchild);
if (subchild != null) {
throw new SoapFault(SoapFault.RECEIVER, "Multiple elements are not supported in Detail");
}
}
child = DOMUtil.getNextSiblingElement(child);
childname = DOMUtil.getQName(child);
}
// Nothing should be left
if (childname != null) {
throw new SoapFault(SoapFault.SENDER, "Unexpected element: " + childname);
}
}
SoapFault fault = new SoapFault(code, subcode, reason, node, role, details);
return fault;
}