SOAPFaultCode soapCode = factory.createSOAPFaultCode(soapFault);
QName soapValueQName = xmlFault.getCode().toQName(ns.getNamespaceURI());
if (isSoap11) {
soapCode.setText(soapValueQName);
} else {
SOAPFaultValue soapValue = factory.createSOAPFaultValue(soapCode);
soapValue.setText(soapValueQName);
}
// 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.
OMSourcedElementImpl element =
new OMSourcedElementImpl(blocks[i].getQName(), factory, blocks[i]);
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