private static SOAPMessageImpl toSOAPMessage(SOAPFaultException faultEx) throws SOAPException
{
assertFaultCode(faultEx.getFaultCode());
CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
SerializationContext serContext = (msgContext != null ? msgContext.getSerializationContext() : new SerializationContextJAXRPC());
NamespaceRegistry nsRegistry = serContext.getNamespaceRegistry();
SOAPMessageImpl soapMessage = createSOAPMessage();
SOAPEnvelopeImpl soapEnvelope = (SOAPEnvelopeImpl)soapMessage.getSOAPPart().getEnvelope();
SOAPBody soapBody = soapEnvelope.getBody();
QName faultCode = faultEx.getFaultCode();
if (faultCode.getNamespaceURI().length() > 0)
faultCode = nsRegistry.registerQName(faultCode);
String faultString = getValidFaultString(faultEx);
SOAPFault soapFault = soapBody.addFault(new NameImpl(faultCode), faultString);
String faultActor = faultEx.getFaultActor();
if (faultActor != null)
{
SOAPElement soapElement = soapFault.addChildElement("faultactor");
soapElement.addTextNode(faultActor);
}
Exception faultCause = (Exception)faultEx.getCause();
Detail detail = faultEx.getDetail();
if (detail != null)
{
soapFault.addChildElement(detail);
}
else if (faultCause != null && (faultCause instanceof RuntimeException) == false)
{
Class javaType = faultCause.getClass();
TypeMapping typeMapping = serContext.getTypeMapping();
OperationMetaData opMetaData = msgContext.getOperationMetaData();
if (opMetaData != null && opMetaData.getFaultMetaData(javaType) != null)
{
FaultMetaData faultMetaData = opMetaData.getFaultMetaData(javaType);
QName xmlName = faultMetaData.getXmlName();
QName xmlType = faultMetaData.getXmlType();