예제 #1
0
static void _fault_to_error(glite_delegation_ctx *ctx, const char *method)
{
    const char **code, **string, **detail;
    struct soap *soap = ctx->soap;

    soap_set_fault(soap);

    if (soap->fault)
    {
        /* Look for a SOAP 1.1 fault */
        if (soap->fault->detail)
            decode_exception(ctx, soap->fault->detail, method);
        /* Look for a SOAP 1.2 fault */
        if (soap->fault->SOAP_ENV__Detail)
            decode_exception(ctx, soap->fault->SOAP_ENV__Detail, method);
    }

    /* If we did not manage to decode the exception, try generic error
    * decoding */
    if (!ctx->error)
    {
        code = soap_faultcode(soap);
        string = soap_faultstring(soap);
        detail = soap_faultdetail(soap);

        /* If the SOAP 1.1 detail is empty, try the SOAP 1.2 detail */
        if (!detail && soap->fault && soap->fault->SOAP_ENV__Detail)
            detail = (const char **)&soap->fault->SOAP_ENV__Detail->__any;

        /* Provide default messages */
        if (!code || !*code)
        {
            code = alloca(sizeof(*code));
            *code = "(SOAP fault code missing)";
        }
        if (!string || !*string)
        {
            string = alloca(sizeof(*string));
            *string = "(SOAP fault string missing)";
        }

        if (detail && *detail)
            glite_delegation_set_error(ctx, "%s: SOAP fault: %s - %s (%s)", method, *code,
                *string, *detail);
        else
            glite_delegation_set_error(ctx, "%s: SOAP fault: %s - %s", method, *code,
                *string);
    }

    soap_end(soap);
}
utf8_string::decode_exception::decode_exception(const decode_exception& e) noexcept
{
	*this = decode_exception(e.m_desc);
}