void Call::processSoapFault()

in src/engine/client/Call.cpp [1237:1347]


void Call::processSoapFault(AxisException *e, 
                            void *exceptionHandlerFp)
{
    logEntryEngine("Call::processSoapFault")

    AXIS_EXCEPTION_HANDLER_FUNCT excFp = (AXIS_EXCEPTION_HANDLER_FUNCT)exceptionHandlerFp;
    ISoapFault* pSoapFault             = NULL;
    
    if (AXISC_NODE_VALUE_MISMATCH_EXCEPTION == e->getExceptionCode())
    {
        try
        {
            pSoapFault = (ISoapFault*) this->checkFault("Fault", m_pSoapFaultNamespace);
        }
        catch (AxisException& e1)
        {
            // Just fall through since we are already dealing with some exception.
            pSoapFault = NULL;
        }
    }

    if(pSoapFault)
    {
        void *pFaultDetail = NULL;
        bool faultIsDefined = false;
        bool isFaultDetailXMLString = false;
        FaultInformation_t *fi;
        const char* pcCmplxFaultName = pSoapFault->getCmplxFaultObjectName();

        // See if fault is defined        
        list<void *>::iterator it = m_soapFaults.begin();
        while (it != m_soapFaults.end())
        {
            fi = (FaultInformation_t *)*it;
            if (strcmp(fi->m_faultName, pcCmplxFaultName) == 0)
            {
                faultIsDefined = true;
                break;
            }
            it++;
        }
        
        if (faultIsDefined)
        {
            try
            {
               pFaultDetail = pSoapFault->getCmplxFaultObject(fi->m_deserializerFp,
                                                              fi->m_createFp,
                                                              fi->m_deleteFp,
                                                              fi->m_faultName,
                                                              0);
            }
            catch (AxisException& e1)
            {
                // Just fall through since we are already dealing with some exception.
                pFaultDetail = NULL;
            }
        }
        else
        {
            pFaultDetail = (void *)pSoapFault->getSimpleFaultDetail();
            
            if (NULL==pFaultDetail || 0==strlen((char *)pFaultDetail))
            {
                pFaultDetail = (void *)this->getFaultAsXMLString();

                if (NULL==pFaultDetail)
                    pFaultDetail = (void *)"";
                else
                    isFaultDetailXMLString=true;
            }
        }
        
        // Generate an appropriate error message
        std::string faultExcMsg = "AxisSoapException: SOAP fault occurred: \n";
        faultExcMsg += "faultcode  : ";
        faultExcMsg += pSoapFault->getFaultcode();
        faultExcMsg += "\n";
        faultExcMsg += "faultstring: ";
        faultExcMsg += pSoapFault->getFaultstring();
        faultExcMsg += "\n";
        faultExcMsg += "faultactor : ";
        faultExcMsg += pSoapFault->getFaultactor();
        faultExcMsg += "\n";

        // Ensure error code is set correctly for certain fault codes
        const AxisChar* faultCode = pSoapFault->getFaultcode();
        int faultExcCode = e->getExceptionCode();
        if (faultCode)
        {
            if (strcmp(faultCode, "VersionMismatch") == 0)
                faultExcCode = SOAP_VERSION_MISMATCH;
            else if (strcmp(faultCode, "MustUnderstand") == 0)
                faultExcCode = SOAP_MUST_UNDERSTAND;
        }

        excFp(faultExcCode, faultExcMsg.c_str(), pSoapFault, pFaultDetail);
        
        if (faultIsDefined)
        {
            AXIS_OBJECT_DELETE_FUNCT deleteFp = (AXIS_OBJECT_DELETE_FUNCT)fi->m_deleteFp;
            deleteFp(pFaultDetail, 0);
        }
        else if (isFaultDetailXMLString)
            delete [] (char *)pFaultDetail;
    }
    else
        excFp(e->getExceptionCode(), e->what(), NULL, NULL);
    
    logExit()
}