You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by Jamie <ja...@mweb.co.za> on 2005/05/24 13:52:08 UTC

web service exception causes crash - possible bug in WSDL2Ws?

Hi everyone,

I am using the latest nightly build of Axis C++. My client application 
crashes when an exception is thrown from the server via Axis web 
services. The generated code (see below), attempts to delete memory 
pointed to by detail (fault point is marked below). The contents of 
detail at this point is"<hostname>jamie</hostname>". Any ideas on how to 
fix this? From time to time, my server application throws exceptions.. 
in which case i'd like the client app to behave responsibly.

Thanks in advance for your help.

Jamie


Is this a bug in the code generated by WSDL2Ws?
/*
 * This method wrap the service methodstoreMessage
 */
xsd__boolean TestApp::storeMessage(xsd__base64Binary Value0)
{
    xsd__boolean Ret = false_;
    const char* pcCmplxFaultName;
    pcCmplxFaultName = NULL;
    try
    {    if (AXIS_SUCCESS != m_pCall->initialize(CPP_DOC_PROVIDER)) 
return Ret;
        if (NULL==m_pCall->getTransportProperty("SOAPAction",false))
    {
        m_pCall->setTransportProperty(SOAPACTION_HEADER , "");
    }
    m_pCall->setSOAPVersion(SOAP_VER_1_1);
    m_pCall->setOperation("storeMessage", "url:TestApp");
    includeSecure();
    applyUserPreferences();
    char cPrefixAndParamName0[13];
    sprintf( cPrefixAndParamName0, "%s:in0", 
m_pCall->getNamespacePrefix("url:TestApp"));
    m_pCall->addParameter((void*)&Value0, cPrefixAndParamName0, 
XSD_BASE64BINARY);
    if (AXIS_SUCCESS == m_pCall->invoke())
    {
        if(AXIS_SUCCESS == m_pCall->checkMessage("storeMessageResponse", 
"url:TestApp"))
        {
            xsd__boolean * pReturn = 
m_pCall->getElementAsBoolean("storeMessageReturn", 0);
            if(pReturn)
                Ret = *pReturn;
        }
    }
    m_pCall->unInitialize();
    return Ret;
    }
    catch(AxisException& e)
    {
        int iExceptionCode = e.getExceptionCode();

        if(AXISC_NODE_VALUE_MISMATCH_EXCEPTION != iExceptionCode)
        {
            m_pCall->unInitialize();
            throw;
        }

        ISoapFault* pSoapFault = (ISoapFault*)
            
m_pCall->checkFault("Fault","http://127.0.0.1:8080/TestApp/services/TestAppService" 
);

        if(pSoapFault)
        {
                const char *detail = pSoapFault->getSimpleFaultDetail();
                bool deleteDetail=false;

                if (NULL==detail || 0==strlen(detail))
                {
                    detail=m_pCall->getFaultAsXMLString();
                    if (NULL==detail)
                    {
                        detail="";
                    }
                    else
                    {
                        deleteDetail=true;
                    }
                }

                OtherFaultException ofe(pSoapFault->getFaultcode(),
                    pSoapFault->getFaultstring(), 
pSoapFault->getFaultactor(),
                    detail, iExceptionCode);

                if (deleteDetail && NULL!=detail)
                {
                     delete [] const_cast<char*>(detail);  // 
!!!!!!!!!!!!!! CRASHES HERE !!!!!!!!!!!!!!!!!!!!
                }

                m_pCall->unInitialize();
                delete pSoapFault;
                throw ofe;
        }
        else
        {
            m_pCall->unInitialize();
            delete pSoapFault;
            throw;
        }
    }
}