SOAPFault fault = body.getFault();
Iterator itr = fault.getChildElements();
while (itr.hasNext()) {
SOAPElement se = (SOAPElement) itr.next();
if (se.getLocalName().equals(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME)) {
if (log.isDebugEnabled()) {
log.debug("Converting: faultcode");
}
// Axis2 SAAJ stores the acutal faultcode text under a SOAPFaultValue object, so we have to
// get that and add it as a text node under the original element.
Node value = se.getFirstChild();
if (value != null && value instanceof org.apache.axis2.saaj.SOAPElementImpl) {
org.apache.axis2.saaj.SOAPElementImpl<?> valueElement = (org.apache.axis2.saaj.SOAPElementImpl<?>) value;
OMElement e = valueElement.getOMTarget();
String content = e.getText();
SOAPElement child = fault.addChildElement(new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_CODE_LOCAL_NAME));
child.addTextNode(content);
se.detachNode();
}
}
else if (se.getLocalName().equals(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME)) {
if (log.isDebugEnabled()) {
log.debug("Converting: detail");
}
se.setElementQName(new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_DETAIL_LOCAL_NAME));
}
else if (se.getLocalName().equals(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME)) {
if (log.isDebugEnabled()) {
log.debug("Converting: faultstring");
}
se.setElementQName(new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME));
// Axis2 SAAJ stores the acutal faultstring text under a SOAPFaultValue object, so we have to
// get that and add it as a text node under the original element.
Node value = se.getFirstChild();
if (value != null && value instanceof org.apache.axis2.saaj.SOAPElementImpl) {
org.apache.axis2.saaj.SOAPElementImpl<?> valueElement = (org.apache.axis2.saaj.SOAPElementImpl<?>) value;
OMElement e = valueElement.getOMTarget();
String content = e.getText();
SOAPElement child = fault.addChildElement(new QName(se.getNamespaceURI(), SOAP11Constants.SOAP_FAULT_STRING_LOCAL_NAME));
child.addTextNode(content);
se.detachNode();
}
}
}