soapTexts = soapReason.getAllSoapTexts();
SOAPFaultText reasonText = (SOAPFaultText)soapTexts.get(0);
text = reasonText.getText();
lang = reasonText.getLang();
}
XMLFaultReason reason = new XMLFaultReason(text, lang);
// Construct the XMLFault from the required information (code, reason, detail blocks)
XMLFault xmlFault = new XMLFault(code, reason, detailBlocks);
// Add the secondary fault information
// Get the SubCodes
SOAPFaultSubCode soapSubCode = soapCode.getSubCode();
if (soapSubCode != null) {
List<QName> list = new ArrayList<QName>();
// Walk the nested sub codes and collect the qnames
while (soapSubCode != null) {
SOAPFaultValue soapSubCodeValue = soapSubCode.getValue();
QName qName = soapSubCodeValue.getTextAsQName();
list.add(qName);
soapSubCode = soapSubCode.getSubCode();
}
// Put the collected sub code qnames onto the xmlFault
QName[] qNames = new QName[list.size()];
xmlFault.setSubCodes(list.toArray(qNames));
}
// Get the secondary Reasons...the first reason was already saved as the primary reason
if (soapTexts != null && soapTexts.size() > 1) {
XMLFaultReason[] secondaryReasons = new XMLFaultReason[soapTexts.size() - 1];
for (int i = 1; i < soapTexts.size(); i++) {
SOAPFaultText soapReasonText = (SOAPFaultText)soapTexts.get(i);
secondaryReasons[i - 1] = new XMLFaultReason(soapReasonText.getText(),
soapReasonText.getLang());
}
xmlFault.setSecondaryReasons(secondaryReasons);
}