// Set the primary Reason Text
SOAPFaultReason soapReason = factory.createSOAPFaultReason(soapFault);
if (isSoap11) {
soapReason.setText(xmlFault.getReason().getText());
} else {
SOAPFaultText soapText = factory.createSOAPFaultText(soapReason);
soapText.setText(xmlFault.getReason().getText());
soapText.setLang(xmlFault.getReason().getLang());
}
// Set the Detail and contents of Detail
Block[] blocks = xmlFault.getDetailBlocks();
if (blocks != null && blocks.length > 0) {
SOAPFaultDetail detail = factory.createSOAPFaultDetail(soapFault);
if (!ignoreDetailBlocks) {
for (int i = 0; i < blocks.length; i++) {
// A Block implements OMDataSource. So create OMSourcedElements
// for each of the Blocks.
OMSourcedElement element =
factory.createOMElement(blocks[i], blocks[i].getQName());
detail.addChild(element);
}
}
}
// Now set all of the secondary fault information
// Set the SubCodes
QName[] subCodes = xmlFault.getSubCodes();
if (subCodes != null && subCodes.length > 0) {
OMElement curr = soapCode;
for (int i = 0; i < subCodes.length; i++) {
SOAPFaultSubCode subCode = (i == 0) ?
factory.createSOAPFaultSubCode((SOAPFaultCode)curr) :
factory.createSOAPFaultSubCode((SOAPFaultSubCode)curr);
SOAPFaultValue soapSubCodeValue = factory.createSOAPFaultValue(subCode);
soapSubCodeValue.setText(subCodes[i]);
curr = subCode;
}
}
// Set the secondary reasons and languages
XMLFaultReason reasons[] = xmlFault.getSecondaryReasons();
if (reasons != null && reasons.length > 0) {
for (int i = 0; i < reasons.length; i++) {
SOAPFaultText soapReasonText = factory.createSOAPFaultText(soapReason);
soapReasonText.setText(reasons[i].getText());
soapReasonText.setLang(reasons[i].getLang());
}
}
// Set the Role
if (xmlFault.getRole() != null) {