try
{
SOAPMessage faultMsg = null;
if (ex instanceof FaultMessageException)
{
final FaultMessageException fme = (FaultMessageException) ex ;
final Message faultMessage = fme.getReturnedMessage() ;
if (faultMessage != null)
{
final Body body = faultMessage.getBody() ;
final QName faultCode = (QName)body.get(Fault.DETAIL_CODE_CONTENT) ;
final String faultDescription = (String)body.get(Fault.DETAIL_DESCRIPTION_CONTENT) ;
final String faultDetail = (String)body.get(Fault.DETAIL_DETAIL_CONTENT) ;
if (faultCode != null)
{
faultMsg = SOAP_MESSAGE_FACTORY.createMessage() ;
final SOAPFault fault = faultMsg.getSOAPBody().addFault(faultCode, faultDescription) ;
if (faultDetail != null)
{
try
{
final Document detailDoc = parseAsDom(faultDetail) ;
final Detail detail = fault.addDetail() ;
detail.appendChild(detailDoc.getDocumentElement()) ;
}
catch (final Exception ex2)
{
LOGGER.warn("Failed to parse fault detail", ex2) ;
}
}
}
else
{
final Throwable cause = fme.getCause() ;
faultMsg = (cause != null) ? generateFault(cause) : generateFault(ex) ;
}
}
}