示例#1
0
axiom_soap_envelope_t *AXIS2_CALL
sandesha2_msg_ctx_get_soap_envelope(
    sandesha2_msg_ctx_t *rm_msg_ctx,
    const axutil_env_t *env)
{
    return axis2_msg_ctx_get_soap_envelope(rm_msg_ctx->msg_ctx, env);
}
axis2_status_t AXIS2_CALL
axutil_log_out_handler_invoke(
    struct axis2_handler * handler,
    const axutil_env_t * env,
    struct axis2_msg_ctx * msg_ctx)
{
    axiom_soap_envelope_t *soap_envelope = NULL;
    axiom_node_t *ret_node = NULL;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);

    AXIS2_LOG_INFO(env->log, "Starting logging out handler .........");

    soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);

    if (soap_envelope)
    {
        ret_node = axiom_soap_envelope_get_base_node(soap_envelope, env);

        if (ret_node)
        {
            axis2_char_t *om_str = NULL;
            om_str = axiom_node_to_string(ret_node, env);
            if (om_str)
            {
                AXIS2_LOG_INFO(env->log, "Output message: %s", om_str);
            }
        }
    }

    return AXIS2_SUCCESS;
}
AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL
axis2_async_result_get_envelope(
    axis2_async_result_t * async_result,
    const axutil_env_t * env)
{
    if (async_result->result)
    {
        return axis2_msg_ctx_get_soap_envelope(async_result->result, env);
    }

    return NULL;
}
示例#4
0
文件: util.c 项目: kasungayan/commons
axiom_soap_envelope_t *
wsdl_util_send_receive_soap_envelope_with_op_client(
    const axutil_env_t* env,
    axis2_svc_client_t* svc_client,
    axis2_options_t* options,
    axis2_char_t* buffer)
{
    axiom_soap_envelope_t *res_envelope = NULL, *req_envelope = NULL;
    axis2_svc_ctx_t *svc_ctx = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_msg_ctx_t *req_msg_ctx = NULL, *res_msg_ctx = NULL;
    axutil_qname_t *op_qname = NULL;
    axis2_op_client_t *op_client = NULL;
    axis2_char_t *soap_version_uri = NULL;

    svc_ctx = axis2_svc_client_get_svc_ctx (svc_client, env);

    conf_ctx = axis2_svc_ctx_get_conf_ctx (svc_ctx, env);

    req_msg_ctx = axis2_msg_ctx_create (env, conf_ctx, NULL, NULL);

    op_qname = axutil_qname_create (env, AXIS2_ANON_OUT_IN_OP, NULL, NULL);

    op_client = axis2_svc_client_create_op_client (svc_client, env, op_qname);

    soap_version_uri = (axis2_char_t *) axis2_options_get_soap_version_uri (options, env);

    req_envelope = wsdl_util_create_soap_envelope_from_buffer (env, buffer, soap_version_uri);
    
    axis2_msg_ctx_set_soap_envelope (req_msg_ctx, env, req_envelope);
    
    axis2_op_client_add_msg_ctx (op_client, env, req_msg_ctx);
    
    axis2_op_client_execute (op_client, env, AXIS2_TRUE);
    
    res_msg_ctx =
       (axis2_msg_ctx_t *)axis2_op_client_get_msg_ctx (op_client, env, AXIS2_WSDL_MESSAGE_LABEL_IN);
    
    if (res_msg_ctx) 
    {        
        res_envelope = axis2_msg_ctx_get_soap_envelope (res_msg_ctx, env);
    } 
    else 
    {
        res_envelope = NULL;
    }
    
    return res_envelope;
}
示例#5
0
axis2_char_t *
wsf_util_get_soap_msg_from_op_client (
    axis2_op_client_t * op_client,
    axutil_env_t * env,
    axis2_wsdl_msg_labels_t msg_label)
{
    if (op_client) {
        axiom_soap_envelope_t *soap_env = NULL;
        const axis2_msg_ctx_t *msg_ctx = NULL;
        axiom_node_t *node = NULL;

        msg_ctx = axis2_op_client_get_msg_ctx (op_client, env, msg_label);
        if (!msg_ctx)
            return NULL;
        soap_env = axis2_msg_ctx_get_soap_envelope (msg_ctx, env);
        if (!soap_env)
            return NULL;
        node = axiom_soap_envelope_get_base_node (soap_env, env);
        return axiom_node_to_string (node, env);
    }
    return NULL;
}
axis2_status_t AXIS2_CALL
axis2_addr_in_handler_invoke(
    struct axis2_handler * handler,
    const axutil_env_t * env,
    struct axis2_msg_ctx * msg_ctx)
{
    axiom_soap_envelope_t *soap_envelope = NULL;
    axiom_soap_header_t *soap_header = NULL;
    axutil_property_t *property = NULL;
    axis2_status_t status = AXIS2_FAILURE;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);

    AXIS2_LOG_INFO(env->log, "Starting addressing in handler");

    soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);

    if (soap_envelope)
    {
        soap_header = axiom_soap_envelope_get_header(soap_envelope, env);
        if (soap_header)
        {
            axutil_array_list_t *addr_headers = NULL;
            axis2_ctx_t *ctx = NULL;
            axis2_char_t *addr_ns_str = NULL;
            axis2_msg_info_headers_t *msg_info_headers =
                axis2_msg_ctx_get_msg_info_headers(msg_ctx, env);

            addr_headers =
                axiom_soap_header_get_header_blocks_with_namespace_uri
                (soap_header, env, AXIS2_WSA_NAMESPACE_SUBMISSION);
            if (addr_headers)
            {
                addr_ns_str =
                    axutil_strdup(env, AXIS2_WSA_NAMESPACE_SUBMISSION);
                /*status =
                    axis2_addr_in_extract_addr_submission_info(env, soap_header,
                                                               &msg_info_headers,
                                                               addr_headers,
                                                               msg_ctx);*/
                status = axis2_addr_in_extract_addr_params(env,
                                             soap_header,
                                             &msg_info_headers,
                                             addr_headers,
                                             AXIS2_WSA_NAMESPACE_SUBMISSION,
                                             msg_ctx);
            }
            else
            {
                addr_headers =
                    axiom_soap_header_get_header_blocks_with_namespace_uri
                    (soap_header, env, AXIS2_WSA_NAMESPACE);
                if (addr_headers)
                {
                    addr_ns_str = axutil_strdup(env, AXIS2_WSA_NAMESPACE);
                    /*status = axis2_addr_in_extract_addr_final_info(env,
                                                                   soap_header,
                                                                   &msg_info_headers,
                                                                   addr_headers,
                                                                   msg_ctx);*/
                    status = axis2_addr_in_extract_addr_params(env,
                                             soap_header,
                                             &msg_info_headers,
                                             addr_headers,
                                             AXIS2_WSA_NAMESPACE, msg_ctx);
                                                                    
                    axis2_addr_in_extract_ref_params(env, soap_header,
                                                     axis2_msg_ctx_get_msg_info_headers
                                                     (msg_ctx, env));

                }
                else
                {
                    /* addressing headers are not present in the SOAP message */
                    AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI,
                                   "No Addressing Headers present in the IN message. Addressing In Handler cannot do anything.");
                    return AXIS2_SUCCESS;   /* no addressing heades means addressing not in use */
                }
            }

            ctx = axis2_msg_ctx_get_base(msg_ctx, env);
            if (ctx)
            {
                property = axutil_property_create(env);
                axutil_property_set_scope(property, env, AXIS2_SCOPE_REQUEST);
                axutil_property_set_value(property, env, addr_ns_str);
                axis2_ctx_set_property(ctx, env, AXIS2_WSA_VERSION, property);
            }

            /* extract service group context, if available */
            axis2_addr_in_extract_svc_grp_ctx_id(env, soap_header, msg_ctx);

            axutil_array_list_free(addr_headers, env);
            return status;
        }
    }

    return AXIS2_SUCCESS;
}
示例#7
0
static axis2_status_t AXIS2_CALL
axis2_msg_recv_receive_impl(
    axis2_msg_recv_t * msg_recv,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx,
    void *callback_recv_param)
{
    axis2_msg_ctx_t *out_msg_ctx = NULL;
    axis2_engine_t *engine = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_op_ctx_t *op_ctx = NULL;
    axis2_svc_ctx_t *svc_ctx = NULL;
    axis2_status_t status = AXIS2_FAILURE;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[axis2]Entry:axis2_msg_recv_receive_impl");
    out_msg_ctx = axis2_core_utils_create_out_msg_ctx(env, msg_ctx);
    if(!out_msg_ctx)
    {
        return AXIS2_FAILURE;
    }
    op_ctx = axis2_msg_ctx_get_op_ctx(out_msg_ctx, env);
    if(!op_ctx)
    {
        axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
        axis2_msg_ctx_free(out_msg_ctx, env);
        return AXIS2_FAILURE;
    }

    status = axis2_op_ctx_add_msg_ctx(op_ctx, env, out_msg_ctx);
    if(!status)
    {
        axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
        axis2_msg_ctx_free(out_msg_ctx, env);
        return status;
    }
    status = axis2_op_ctx_add_msg_ctx(op_ctx, env, msg_ctx);

    if(!status)
    {
        return status;
    }

    status = axis2_msg_recv_invoke_business_logic(msg_recv, env, msg_ctx, out_msg_ctx);
    if(AXIS2_SUCCESS != status)
    {
        axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
        axis2_msg_ctx_free(out_msg_ctx, env);
        return status;
    }
    svc_ctx = axis2_op_ctx_get_parent(op_ctx, env);
    conf_ctx = axis2_svc_ctx_get_conf_ctx(svc_ctx, env);
    engine = axis2_engine_create(env, conf_ctx);
    if(!engine)
    {
        axis2_msg_ctx_free(out_msg_ctx, env);
        return AXIS2_FAILURE;
    }
    if(axis2_msg_ctx_get_soap_envelope(out_msg_ctx, env))
    {
        axiom_soap_envelope_t *soap_envelope = axis2_msg_ctx_get_soap_envelope(out_msg_ctx, env);
        if(soap_envelope)
        {
            axiom_soap_body_t *body = axiom_soap_envelope_get_body(soap_envelope, env);
            if(body)
            {
                /* in case of a SOAP fault, we got to return failure so that
                 transport gets to know that it should send 500 */
                if(axiom_soap_body_has_fault(body, env))
                {
                    status = AXIS2_FAILURE;
                    axis2_msg_ctx_set_fault_soap_envelope(msg_ctx, env, soap_envelope);
                    axis2_msg_ctx_set_soap_envelope(out_msg_ctx, env, NULL);
                }
                else
                {
                    /* if it is two way and not a fault then send through engine.
                     if it is one way we do not need to do an engine send */
                    status = axis2_engine_send(engine, env, out_msg_ctx);
                }
            }
        }
    }
    axis2_engine_free(engine, env);

    /* Reset the out message context to avoid double freeing at http worker. For example if this is
     * not done here both in and out message context will try to free the transport out stream 
     * which will result in memory corruption.
     */
    if(!axis2_msg_ctx_is_paused(out_msg_ctx, env) && !axis2_msg_ctx_is_keep_alive(out_msg_ctx, env))
    {
        axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
    }
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[axis2]Exit:axis2_msg_recv_receive_impl");
    return status;
    (void)callback_recv_param;
}
示例#8
0
AXIS2_EXTERN void AXIS2_CALL
savan_default_publisher_publish(
    savan_publisher_t *publishermod,
    const axutil_env_t *env,
    void *msg_ctx,
    savan_subs_mgr_t *subs_mgr)
{
    savan_default_publisher_t *publishermodimpl = NULL;
    axutil_array_list_t *subs_store = NULL;
    int i = 0, size = 0;
    savan_filter_mod_t *filtermod = NULL;
    const axis2_char_t *path = NULL;
    axiom_node_t *payload = NULL;
    axiom_soap_envelope_t *envelope = NULL;
    axiom_soap_body_t *body = NULL;
    axiom_node_t *body_node = NULL;
    const axis2_char_t *filter = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axutil_property_t *topic_property = NULL;

    publishermodimpl = SAVAN_INTF_TO_IMPL(publishermod);

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Entry:savan_default_publisher_publish");

    topic_property = axis2_msg_ctx_get_property(msg_ctx, env, ELEM_NAME_TOPIC);
    if(topic_property)
    {
        filter = axutil_property_get_value(topic_property, env);
    }
    axutil_allocator_switch_to_global_pool(env->allocator);
    if(subs_mgr)
    {
        subs_store = savan_subs_mgr_retrieve_all_subscribers(subs_mgr, env, filter);
    }

    if (!subs_store)
    {
        axutil_allocator_switch_to_local_pool(env->allocator);
        AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "[savan] Subscriber store is NULL"); 
    }

    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    path = axis2_conf_ctx_get_root_dir(conf_ctx, env);
    if(!path)
    {
        path = AXIS2_GETENV("AXIS2C_HOME");
    }

    envelope =  axis2_msg_ctx_get_soap_envelope((axis2_msg_ctx_t *) msg_ctx, env);
    if (!envelope)
    {
        axutil_allocator_switch_to_local_pool(env->allocator);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] Failed to extract the soap envelop");
    }
    
    body = axiom_soap_envelope_get_body(envelope, env);
    if (!body)
    {
        axutil_allocator_switch_to_local_pool(env->allocator);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] Failed to extract the soap body"); 
    }
    
    body_node = axiom_soap_body_get_base_node(body, env);

    payload = axiom_node_get_first_child(body_node, env);
    size = axutil_array_list_size(subs_store, env);
    for(i = 0; i < size; i++)
    {
        axis2_svc_client_t *svc_client = NULL;
        savan_subscriber_t *sub = NULL;

        sub = (savan_subscriber_t *)axutil_array_list_get(subs_store, env, i);
        if (sub)
        {
            axis2_char_t *id = savan_subscriber_get_id(sub, env);
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Publishing to:%s", id);

            svc_client = axis2_svc_client_create(env, path);
            filtermod = savan_util_get_filter_module(env, publishermodimpl->conf);
            /* Ideally publishing to each subscriber should happen within a thread for each 
             * subscriber. However until Axis2/C provide a good thread pool to handle
             * such tasks I use this sequential publishing to subscribers.
             */
            if(!savan_default_publisher_publish_to_subscriber(publishermod, env, svc_client, sub, 
                        filtermod, payload))
            {
                axis2_endpoint_ref_t *notifyto = savan_subscriber_get_notify_to(sub, env);
                const axis2_char_t *address = NULL;

                if(notifyto)
                {
                    address = axis2_endpoint_ref_get_address(notifyto, env);
                }

                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                        "Publishing to the Data Sink:%s proviced by subscriber:%s Failed. Check "\
                        "whether the Data Sink url is correct", address, id);
            }
            if(svc_client)
            {
                axis2_svc_client_free(svc_client, env);
            }
        }
    }

    axutil_allocator_switch_to_local_pool(env->allocator);

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Exit:savan_default_publisher_publish");
}
示例#9
0
axis2_status_t AXIS2_CALL
wsf_xml_msg_recv_invoke_business_logic_sync(
        axis2_msg_recv_t * msg_recv,
        const axutil_env_t * env,
        axis2_msg_ctx_t * in_msg_ctx,
        axis2_msg_ctx_t * out_msg_ctx)
{

    axis2_op_ctx_t *op_ctx = NULL;
    axis2_op_t *op_desc = NULL;

    axiom_namespace_t *env_ns = NULL;

    int soap_version = AXIOM_SOAP12;
    axis2_status_t status = AXIS2_SUCCESS;
    axis2_bool_t skel_invoked = AXIS2_FALSE;

    const axis2_char_t *style = NULL;
    axis2_char_t *local_name = NULL;
    axis2_char_t *soap_ns = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
    axis2_char_t *operation_name = NULL;
    char *classname = NULL;

    axutil_property_t *svc_info_prop = NULL;
    axutil_property_t *req_info_prop = NULL;
    wsf_svc_info_t *svc_info = NULL;
    wsf_request_info_t *req_info = NULL;

    /** store in_msg_ctx envelope */
    axiom_soap_envelope_t *envelope = NULL;
    axiom_soap_body_t *body = NULL;
    axiom_node_t *in_body_node = NULL;

    /* store out_msg_ctx envelope */
    axiom_soap_envelope_t *default_envelope = NULL;
    axiom_soap_body_t *out_body = NULL;
    axiom_soap_header_t *out_header = NULL;
    axiom_soap_fault_t *out_soap_fault = NULL;

    axiom_node_t *result_node = NULL;

    axiom_node_t *out_body_content_node = NULL;
    axiom_element_t *out_body_content_element = NULL;
    axiom_node_t *out_node = NULL;

    zval **output_headers_zval = NULL;

    TSRMLS_FETCH();

    AXIS2_PARAM_CHECK(env->error, in_msg_ctx, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, out_msg_ctx, AXIS2_FAILURE);

    op_ctx = axis2_msg_ctx_get_op_ctx(in_msg_ctx, env);
    op_desc = axis2_op_ctx_get_op(op_ctx, env);
    style = axis2_op_get_style(op_desc, env);

    envelope = axis2_msg_ctx_get_soap_envelope(in_msg_ctx, env);

    body = axiom_soap_envelope_get_body(envelope, env);

    in_body_node = axiom_soap_body_get_base_node(body, env);


    if (0 == axutil_strcmp(AXIS2_STYLE_DOC, style))
    {
        local_name = wsf_xml_msg_recv_get_method_name(in_msg_ctx, env);
        if (!local_name)
        {
            return AXIS2_FAILURE;
        }
    } else if (0 == axutil_strcmp(AXIS2_STYLE_RPC, style))
    {

        axiom_node_t *op_node = NULL;
        axiom_element_t *op_element = NULL;
        op_node = axiom_node_get_first_child(in_body_node, env);
        if (!op_node)
        {
            return AXIS2_FAILURE;
        }
        op_element = axiom_node_get_data_element(op_node, env);

        if (!op_element)
        {
            return AXIS2_FAILURE;
        }
        local_name = axiom_element_get_localname(op_element, env);
        if (!local_name)
        {
            return AXIS2_FAILURE;
        }
    }

    /** set soap version and soap namespace to local variables */
    if (in_msg_ctx && axis2_msg_ctx_get_is_soap_11(in_msg_ctx, env))
    {
        soap_ns = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; /* default is 1.2 */
        soap_version = AXIOM_SOAP11;
    }

    svc_info_prop = axis2_msg_ctx_get_property(in_msg_ctx, env, WSF_SVC_INFO);
    if (svc_info_prop)
    {
        svc_info = (wsf_svc_info_t *) axutil_property_get_value(svc_info_prop, env);
        if (svc_info)
        {
            operation_name = axutil_hash_get(svc_info->ops_to_functions, local_name,
                    AXIS2_HASH_KEY_STRING);
            if (!operation_name)
            {
                return AXIS2_FAILURE;
            }
        } else
        {
            return AXIS2_FAILURE;
        }
        if (svc_info->ops_to_classes)
        {
            classname = axutil_hash_get(svc_info->ops_to_classes, local_name, AXIS2_HASH_KEY_STRING);
        }
    }

    req_info_prop = axis2_msg_ctx_get_property(in_msg_ctx, env, WSF_REQ_INFO);
    if (req_info_prop)
    {
        req_info = (wsf_request_info_t *) axutil_property_get_value(req_info_prop, env);

        if (axis2_msg_ctx_get_doing_rest(in_msg_ctx, env))
        {
            axis2_op_t *op = NULL;
            axiom_node_t *body_child_node = NULL;
            axiom_element_t *body_child = NULL;
            int i = 0;

            body_child_node = axiom_node_get_first_child(in_body_node, env);

            if (!body_child_node)
            {
                op = axis2_msg_ctx_get_op(in_msg_ctx, env);
                if (op)
                {
                    body_child = axiom_element_create_with_qname(env, NULL,
                            axis2_op_get_qname(op, env), &body_child_node);
                    axiom_soap_body_add_child(body, env, body_child_node);
                }
            }
            if (req_info->param_keys && req_info->param_values)
            {
                int i = 0;
                for (i = 0; i < axutil_array_list_size(req_info->param_keys, env); i++)
                {
                    axiom_node_t *node = NULL;
                    axiom_element_t *element = NULL;

                    axis2_char_t *param_key = NULL;
                    axis2_char_t *param_value = NULL;

                    param_key = axutil_array_list_get(req_info->param_keys, env, i);
                    param_value = axutil_array_list_get(req_info->param_values, env, i);

                    element = axiom_element_create(env, NULL, param_key,
                            NULL, &node);
                    axiom_element_set_text(element, env, param_value, node);
                    axiom_node_add_child(body_child_node, env, node);

                    AXIS2_FREE(env->allocator, param_key);
                    AXIS2_FREE(env->allocator, param_value);
                }
                axutil_array_list_free(req_info->param_keys, env);
                axutil_array_list_free(req_info->param_values, env);
            }
        }
    }

    if (svc_info->ht_op_params)
    {
        zval **tmp;
        char *function_type = NULL;
        if (zend_hash_find(svc_info->ht_op_params,
                operation_name, strlen(operation_name) + 1,
                (void **) & tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_STRING)
        {
            function_type = Z_STRVAL_PP(tmp);

            if (strcmp(function_type, WSF_MIXED) == 0)
            {
                result_node = wsf_xml_msg_recv_invoke_mixed(env, svc_info,
                        in_msg_ctx, out_msg_ctx, operation_name,
                        classname, &output_headers_zval TSRMLS_CC);

            } else if (strcmp(function_type, WSF_WSMESSAGE) == 0)
            {
                result_node = wsf_xml_msg_recv_invoke_wsmsg(env, operation_name,
                        in_msg_ctx, out_msg_ctx, svc_info, classname, req_info->content_type TSRMLS_CC);
            }
        }
    } else
    {
        /* this is where the default value for opParam is set,
           If the wsdl option is set go for the MIXED mode by default */
		if (svc_info->wsdl == NULL || svc_info->omit_wsdl)
        {
            result_node = wsf_xml_msg_recv_invoke_wsmsg(env, operation_name,
                    in_msg_ctx, out_msg_ctx, svc_info, classname, req_info->content_type TSRMLS_CC);
        } else
        {
            result_node = wsf_xml_msg_recv_invoke_mixed(env, svc_info,
                    in_msg_ctx, out_msg_ctx, operation_name,
                    classname, &output_headers_zval TSRMLS_CC);
        }
    }
    if (!result_node)
    {
        status = AXIS2_ERROR_GET_STATUS_CODE(env->error);
    } else
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "Response node is not null");
    }

    if (result_node)
    {
        if (0 == axutil_strcmp(style, AXIS2_STYLE_RPC))
        {
            axiom_namespace_t *ns = NULL;
            axis2_char_t *response_name = NULL;

            response_name = axutil_stracat(env, local_name, "Response");
            ns = axiom_namespace_create(env, "http://soapenc/", "res");
            if (!ns)
            {
                return AXIS2_FAILURE;
            }

            out_body_content_element = axiom_element_create(env, NULL, response_name,
                    ns, &out_body_content_node);
            axiom_node_add_child(out_body_content_node, env, result_node);

        } else
        {
            out_body_content_node = result_node;
        }
    }

    if (axis2_msg_ctx_get_soap_envelope(out_msg_ctx, env))
    {
        /* service implementation has set the envelope, useful when setting a SOAP fault.
           No need to further process */
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "soap fault is set");
        return AXIS2_SUCCESS;
    }

    /* create the soap envelope here */
    env_ns = axiom_namespace_create(env, soap_ns, AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX);
    if (!env_ns)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] error seting the namespces for the "
                AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX);
        return AXIS2_FAILURE;
    }

    default_envelope = axiom_soap_envelope_create(env, env_ns);

    if (!default_envelope)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "failed in creating the response soap envelope");
        return AXIS2_FAILURE;
    }


    out_body = axiom_soap_body_create_with_parent(env, default_envelope);
    if (!out_body)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] failed in creating the response soap body");
        return AXIS2_FAILURE;
    }

    out_header = axiom_soap_header_create_with_parent(env, default_envelope);
    if (!out_header)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "failed in creating the response soap headers");
        return AXIS2_FAILURE;
    }

    if (output_headers_zval)
    {
        axiom_node_t *header_base_node = NULL;

        HashPosition pos;
        zval **param;
        char *header_str;
        axiom_node_t *header_node;

        for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(output_headers_zval), &pos);
                zend_hash_get_current_data_ex(Z_ARRVAL_PP(output_headers_zval),
                (void **) & param, &pos) == SUCCESS;
                zend_hash_move_forward_ex(Z_ARRVAL_PP(output_headers_zval), &pos))
        {

            if (Z_TYPE_PP(param) == IS_STRING)
            {

                header_base_node = axiom_soap_header_get_base_node(out_header, env);

                if (header_base_node)
                {
                    header_str = Z_STRVAL_PP(param);
                    header_node = wsf_util_deserialize_buffer(env, header_str);
                    axiom_node_add_child(header_base_node, env, header_node);
                } else
                {
                    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] failed in retrieving the response soap headers node");
                    return AXIS2_FAILURE;
                }
            }
        }
    }

    out_node = axiom_soap_body_get_base_node(out_body, env);
    if (!out_node)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] failed in retrieving the response soap body node");
        return AXIS2_FAILURE;
    }

    if (status != AXIS2_SUCCESS)
    {
        /* something went wrong, set a SOAP Fault */
        axis2_char_t *fault_value_str =
                AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":" AXIOM_SOAP12_SOAP_FAULT_VALUE_SENDER;

        axis2_char_t *fault_reason_str = NULL;
        axis2_char_t *err_msg = NULL;

        if (!skel_invoked)
            fault_value_str = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":" AXIOM_SOAP12_SOAP_FAULT_VALUE_RECEIVER;
        ;

        err_msg = (char *) AXIS2_ERROR_GET_MESSAGE(env->error);

        if (err_msg)
        {
            fault_reason_str = err_msg;
        } else
        {
            fault_reason_str = "Error occurred while processing SOAP message";
        }

        out_soap_fault = axiom_soap_fault_create_default_fault(env, out_body,
                fault_value_str, fault_reason_str, soap_version);
    }

    if (out_body_content_node)
    {
        axiom_node_add_child(out_node, env, out_body_content_node);
        status = axis2_msg_ctx_set_soap_envelope(out_msg_ctx, env,
                default_envelope);
    } else if (out_soap_fault)
    {
        axis2_msg_ctx_set_soap_envelope(out_msg_ctx, env, default_envelope);
        status = AXIS2_FAILURE; /* if there is a failure we have to return a failure code */
    } else
    {
        /* we should free the memory as the envelope is not used, one way case */
        axiom_soap_envelope_free(default_envelope, env);
        default_envelope = NULL;
    }
    return AXIS2_SUCCESS;
}
示例#10
0
axis2_op_t *AXIS2_CALL
axis2_rest_disp_find_op(
    axis2_msg_ctx_t * msg_ctx,
    const axutil_env_t * env,
    axis2_svc_t * svc)
{
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_op_t *op = NULL;
    axiom_soap_envelope_t *soap_env = NULL;
    axiom_soap_body_t *soap_body = NULL;
    axiom_element_t *body_child = NULL;
    axiom_node_t *body_child_node = NULL;
    axiom_node_t *body_element_node = NULL;
    axis2_bool_t soap_env_exists = AXIS2_TRUE;
    int i = 0;

    axutil_array_list_t *param_keys = NULL;
    axutil_array_list_t *param_values = NULL;

    AXIS2_PARAM_CHECK(env->error, svc, NULL);

    if(!axis2_msg_ctx_get_doing_rest(msg_ctx, env))
        return NULL;

    endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env);

    if(endpoint_ref)
    {
        const axis2_char_t *address = NULL;

        address = axis2_endpoint_ref_get_address(endpoint_ref, env);
        if(address)
        {
            axis2_char_t **url_tokens = NULL;

            url_tokens = axutil_parse_request_url_for_svc_and_op(env, address);

            if(url_tokens)
            {
                if(url_tokens[0])
                {
                    axis2_char_t *location = NULL;

                    location = strstr(address, url_tokens[0]);
                    if(location)
                    {
                        const axis2_char_t *method = NULL;

                        location += strlen(url_tokens[0]);
                        param_keys = axutil_array_list_create(env, 10);
                        if(!param_keys)
                        {
                            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                                "No memory. Cannot create the live rest parameter maps");
                            return NULL;
                        }
                        param_values = axutil_array_list_create(env, 10);

                        if(!param_values)
                        {
                            axutil_array_list_free(param_keys, env);
                            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                                "No memory. Cannot create the live rest parameter maps");
                            return NULL;
                        }
                        method = axis2_msg_ctx_get_rest_http_method(msg_ctx, env);
                        op = axis2_core_utils_get_rest_op_with_method_and_location(svc, env,
                            method, location, param_keys, param_values);
                    }
                }
                if(url_tokens[0])
                    AXIS2_FREE(env->allocator, url_tokens[0]);
                if(url_tokens[1])
                    AXIS2_FREE(env->allocator, url_tokens[1]);
                AXIS2_FREE(env->allocator, url_tokens);
            }
        }
    }

    if(!op)
    {
        if(param_keys)
        {
            for(i = 0; i < axutil_array_list_size(param_keys, env); i++)
            {
                void *value = axutil_array_list_get(param_keys, env, i);
                AXIS2_FREE(env->allocator, value);
            }
            axutil_array_list_free(param_keys, env);
        }
        if(param_values)
        {
            for(i = 0; i < axutil_array_list_size(param_values, env); i++)
            {
                void *value = axutil_array_list_get(param_values, env, i);
                AXIS2_FREE(env->allocator, value);
            }
            axutil_array_list_free(param_values, env);
        }
        return NULL;
    }

    soap_env = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);

    if(!soap_env)
    {
        soap_env_exists = AXIS2_FALSE;
        soap_env = axiom_soap_envelope_create_default_soap_envelope(env, AXIOM_SOAP11);
    }
    if(soap_env)
    {
        soap_body = axiom_soap_envelope_get_body(soap_env, env);
    }
    if(!soap_body)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL, AXIS2_FAILURE);

        if(param_keys)
        {
            for(i = 0; i < axutil_array_list_size(param_keys, env); i++)
            {
                void *value = axutil_array_list_get(param_keys, env, i);
                AXIS2_FREE(env->allocator, value);
            }
            axutil_array_list_free(param_keys, env);
        }
        if(param_values)
        {
            for(i = 0; i < axutil_array_list_size(param_values, env); i++)
            {
                void *value = axutil_array_list_get(param_values, env, i);
                AXIS2_FREE(env->allocator, value);
            }
            axutil_array_list_free(param_values, env);
        }
        return NULL;
    }

    body_element_node = axiom_soap_body_get_base_node(soap_body, env);

    if(body_element_node)
    {
        body_child_node = axiom_node_get_first_child(body_element_node, env);
    }

    if(!body_child_node)
    {
        body_child = axiom_element_create_with_qname(env, NULL, axis2_op_get_qname(op, env),
            &body_child_node);
        axiom_soap_body_add_child(soap_body, env, body_child_node);
    }

    if(param_keys && param_values)
    {
        for(i = 0; i < axutil_array_list_size(param_keys, env); i++)
        {
            axis2_char_t *param_key = NULL;
            axis2_char_t *param_value = NULL;

            axiom_node_t *node = NULL;
            axiom_element_t *element = NULL;

            param_key = axutil_array_list_get(param_keys, env, i);
            param_value = axutil_array_list_get(param_values, env, i);

            element = axiom_element_create(env, NULL, param_key, NULL, &node);
            axiom_element_set_text(element, env, param_value, node);
            axiom_node_add_child(body_child_node, env, node);

            AXIS2_FREE(env->allocator, param_key);
            AXIS2_FREE(env->allocator, param_value);
        }

        axutil_array_list_free(param_keys, env);
        axutil_array_list_free(param_values, env);
    }

    if(!soap_env_exists)
    {
        axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_env);
    }

    return op;
}
示例#11
0
AXIS2_EXTERN axiom_node_t *AXIS2_CALL
axis2_svc_client_send_receive_with_op_qname(
    axis2_svc_client_t * svc_client,
    const axutil_env_t * env,
    const axutil_qname_t * op_qname,
    const axiom_node_t * payload)
{
    axiom_soap_envelope_t *soap_envelope = NULL;
    axiom_soap_body_t *soap_body = NULL;
    axiom_node_t *soap_node = NULL;
    axis2_op_t *op = NULL;
    axutil_param_t *param = NULL;
    axutil_uri_t *action_uri = NULL;
    axis2_char_t *action_str = NULL;
    axis2_bool_t qname_free_flag = AXIS2_FALSE;

    axis2_msg_ctx_t *res_msg_ctx = NULL;
    axis2_msg_ctx_t *msg_ctx = NULL;

    AXIS2_PARAM_CHECK(env->error, svc_client, NULL);

    svc_client->last_response_soap_envelope = NULL;
    svc_client->last_response_has_fault = AXIS2_FALSE;
    svc_client->auth_failed = AXIS2_FALSE;
    svc_client->required_auth_is_http = AXIS2_FALSE;
    if(svc_client->auth_type)
    {
        AXIS2_FREE(env->allocator, svc_client->auth_type);
    }
    svc_client->auth_type = NULL;

    op = axis2_svc_get_op_with_qname(svc_client->svc, env, op_qname);
    if(op)
    {
        param = axis2_op_get_param(op, env, AXIS2_SOAP_ACTION);
        if(param)
        {
            action_uri = (axutil_uri_t *)axutil_param_get_value(param, env);
            action_str = axutil_uri_to_string(action_uri, env, AXIS2_URI_UNP_OMITUSERINFO);
            axis2_options_set_action(svc_client->options, env, action_str);
        }
    }

    if(!op_qname)
    {
        op_qname = axutil_qname_create(env, AXIS2_ANON_OUT_IN_OP, NULL, NULL);
        if(!op_qname)
            return NULL;

        qname_free_flag = AXIS2_TRUE;
    }

    /* If dual channel blocking. We come to this block if the client indicate to use
     * a separate listener but don't provide a callback function to acted upon when
     * response is received in the listener thread. What we do here is we create a callback
     * and call axis2_svc_client_send_receive_non_blocking_with_op_qname with it. */
    if(axis2_options_get_use_separate_listener(svc_client->options, env))
    {
        axis2_callback_t *callback = NULL;
        axis2_msg_ctx_t *msg_ctx = NULL;
        long index = 0;

        /* This means doing a Request-Response invocation using two channels.
         If the transport is a two way transport (e.g. http), only one channel is used
         (e.g. in http cases 202 OK is sent to say no response available).
         Axis2 gets blocked and return when the response is available. */

        callback = axis2_callback_create(env);
        if(!callback)
        {
            return NULL;
        }

        /* Call two channel non blocking invoke to do the work and wait on the callback. We don't 
         * set a callback function for the callback. That functionality is handled here. 
         */
        axis2_svc_client_send_receive_non_blocking_with_op_qname(svc_client, env, op_qname,
            payload, callback);

        index = axis2_options_get_timeout_in_milli_seconds(svc_client->options, env) / 10;

        while(!axis2_callback_get_complete(callback, env))
        {
            if(index-- >= 0)
            {
                AXIS2_USLEEP(10000);
            }
            else
            {
                AXIS2_ERROR_SET(env->error, AXIS2_ERROR_RESPONSE_TIMED_OUT, AXIS2_FAILURE);
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Response time out.");
                return NULL;
            }
        }

        soap_envelope = axis2_callback_get_envelope(callback, env);
        msg_ctx = axis2_callback_get_msg_ctx(callback, env);
        axis2_op_client_add_in_msg_ctx(svc_client->op_client, env, msg_ctx);

        /* start of hack to get rid of memory leak */
        /*msg_ctx = axis2_msg_ctx_create(env, axis2_svc_ctx_get_conf_ctx(svc_client-> svc_ctx, env),
            NULL, NULL);
        if(!msg_ctx)
            return NULL;

        axis2_op_client_add_in_msg_ctx(svc_client->op_client, env, msg_ctx);

        axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope);*/
        /* end of hack to get rid of memory leak */

        /* process the result of the invocation */
        if(!soap_envelope)
        {
            if(axis2_callback_get_error(callback, env) != AXIS2_ERROR_NONE)
            {
                AXIS2_ERROR_SET(env->error, axis2_callback_get_error(callback, env), AXIS2_FAILURE);
                return NULL;
            }
        }
    }
    else
    {
        msg_ctx = axis2_msg_ctx_create(env, axis2_svc_ctx_get_conf_ctx(svc_client->svc_ctx, env),
            NULL, NULL);
        if(!msg_ctx)
            return NULL;

        if(!axis2_svc_client_fill_soap_envelope(env, svc_client, msg_ctx, payload))
        {
            return NULL;
        }

        if(!axis2_svc_client_create_op_client(svc_client, env, op_qname))
        {
            return NULL;
        }

        axis2_op_client_add_msg_ctx(svc_client->op_client, env, msg_ctx);
        axis2_op_client_execute(svc_client->op_client, env, AXIS2_TRUE);
        axis2_svc_client_set_http_info(svc_client, env, msg_ctx);
        svc_client->auth_failed = axis2_msg_ctx_get_auth_failed(msg_ctx, env);
        svc_client->required_auth_is_http = axis2_msg_ctx_get_required_auth_is_http(msg_ctx, env);
        if(axis2_msg_ctx_get_auth_type(msg_ctx, env))
        {
            svc_client->auth_type = axutil_strdup(env, axis2_msg_ctx_get_auth_type(msg_ctx, env));
        }
        res_msg_ctx = (axis2_msg_ctx_t *)axis2_op_client_get_msg_ctx(svc_client-> op_client, env,
            AXIS2_WSDL_MESSAGE_LABEL_IN);

        if(res_msg_ctx)
        {
            soap_envelope = axis2_msg_ctx_get_soap_envelope(res_msg_ctx, env);
        }
        else
        {
            axis2_op_client_add_msg_ctx(svc_client->op_client, env, res_msg_ctx);
            /* set in msg_ctx to be NULL to reset */
        }
    }

    if(qname_free_flag)
    {
        axutil_qname_free((axutil_qname_t *)op_qname, env);
    }

    if(!soap_envelope)
    {
        return NULL;
    }
    svc_client->last_response_soap_envelope = soap_envelope;

    soap_body = axiom_soap_envelope_get_body(soap_envelope, env);

    if(!soap_body)
    {
        axiom_node_t *node = axiom_soap_envelope_get_base_node(soap_envelope, env);
        if(node)
        {
            axiom_element_t *envelope_element = (axiom_element_t *)axiom_node_get_data_element(
                node, env);
            axiom_util_get_first_child_element_with_localname(envelope_element, env, node,
                AXIOM_SOAP_BODY_LOCAL_NAME, &soap_node);
            if(soap_node)
            {
                return axiom_node_get_first_element(soap_node, env);
            }
        }
        return NULL;
    }

    if(axis2_msg_ctx_get_doing_rest(res_msg_ctx, env))
    {
        /* All HTTP 4xx and 5xx status codes are treated as errors */
        if(axis2_msg_ctx_get_status_code(res_msg_ctx, env) >= 400)
        {
            svc_client->last_response_has_fault = AXIS2_TRUE;
        }
        else
        {
            svc_client->last_response_has_fault = AXIS2_FALSE;
        }
    }
    else
    {
        svc_client->last_response_has_fault = axiom_soap_body_has_fault(soap_body, env);
    }

    if(AXIOM_SOAP11 == axiom_soap_envelope_get_soap_version(soap_envelope, env))
    {
        axiom_soap_body_convert_fault_to_soap11(soap_body, env);
    }

    soap_node = axiom_soap_body_get_base_node(soap_body, env);
    if(!soap_node)
    {
        return NULL;
    }
    return axiom_node_get_first_element(soap_node, env);
}
示例#12
0
axis2_status_t
axis2_engine_check_must_understand_headers(
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axiom_soap_envelope_t *soap_envelope = NULL;
    axiom_soap_header_t *soap_header = NULL;
    axutil_hash_t *header_block_ht = NULL;
    axutil_hash_index_t *hash_index = NULL;

    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);

    soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
    if(!soap_envelope)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Soap envelope not found in message context");
        return AXIS2_FAILURE;
    }

    soap_header = axiom_soap_envelope_get_header(soap_envelope, env);
    if(!soap_header)
        return AXIS2_SUCCESS;

    header_block_ht = axiom_soap_header_get_all_header_blocks(soap_header, env);
    if(!header_block_ht)
        return AXIS2_SUCCESS;

    for(hash_index = axutil_hash_first(header_block_ht, env); hash_index; hash_index
        = axutil_hash_next(env, hash_index))
    {
        void *hb = NULL;
        axiom_soap_header_block_t *header_block = NULL;
        axis2_char_t *role = NULL;

        axutil_hash_this(hash_index, NULL, NULL, &hb);
        header_block = (axiom_soap_header_block_t *)hb;

        if(header_block)
        {
            if(axiom_soap_header_block_is_processed(header_block, env)
                || !axiom_soap_header_block_get_must_understand(header_block, env))
            {
                continue;
            }

            /* If this header block is not targeted to me then its not my
             problem. Currently this code only supports the "next" role; we
             need to fix this to allow the engine/service to be in one or more
             additional roles and then to check that any headers targeted for
             that role too have been dealt with. */
            role = axiom_soap_header_block_get_role(header_block, env);

            if(axis2_msg_ctx_get_is_soap_11(msg_ctx, env) != AXIS2_TRUE)
            {
                /* SOAP 1.2 */
                if(!role || axutil_strcmp(role, AXIOM_SOAP12_SOAP_ROLE_NEXT) != 0)
                {
                    axiom_soap_envelope_t *temp_env =
                        axiom_soap_envelope_create_default_soap_fault_envelope(env,
                            "soapenv:MustUnderstand", "Header not understood", AXIOM_SOAP12, NULL,
                            NULL);
                    axis2_msg_ctx_set_fault_soap_envelope(msg_ctx, env, temp_env);
                    axis2_msg_ctx_set_wsa_action(msg_ctx, env,
                        "http://www.w3.org/2005/08/addressing/fault");
                    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Must understand soap fault occured");
                    return AXIS2_FAILURE;
                }
            }
            else
            {
                /* SOAP 1.1 */
                if(!role || axutil_strcmp(role, AXIOM_SOAP11_SOAP_ACTOR_NEXT) != 0)
                {
                    axiom_soap_envelope_t *temp_env =
                        axiom_soap_envelope_create_default_soap_fault_envelope(env,
                            "soapenv:MustUnderstand", "Header not understood", AXIOM_SOAP11, NULL,
                            NULL);
                    axis2_msg_ctx_set_fault_soap_envelope(msg_ctx, env, temp_env);
                    axis2_msg_ctx_set_wsa_action(msg_ctx, env,
                        "http://www.w3.org/2005/08/addressing/fault");
                    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Must understand soap fault occured");
                    return AXIS2_FAILURE;
                }

            }

        }
    }

    return AXIS2_SUCCESS;
}
示例#13
0
axis2_status_t AXIS2_CALL
sandesha2_msg_ctx_add_soap_envelope(
    sandesha2_msg_ctx_t *rm_msg_ctx,
    const axutil_env_t *env)
{
    int soap_ver = AXIOM_SOAP11;
    axiom_soap_envelope_t *soap_envelope = NULL;

    if(!axis2_msg_ctx_get_is_soap_11(rm_msg_ctx->msg_ctx, env))
    {
        soap_ver = AXIOM_SOAP12;
    }

    soap_envelope = axis2_msg_ctx_get_soap_envelope(rm_msg_ctx->msg_ctx, env);
    if(!soap_envelope)
    {
        soap_envelope = axiom_soap_envelope_create_default_soap_envelope(env, soap_ver);
        axis2_msg_ctx_set_soap_envelope(rm_msg_ctx->msg_ctx, env, soap_envelope);
    }

    if(rm_msg_ctx->close_seq)
    {
        sandesha2_close_seq_to_soap_envelope(rm_msg_ctx->close_seq, env,
                                             soap_envelope);
    }

    if(rm_msg_ctx->close_seq_res)
    {
        sandesha2_close_seq_res_to_soap_envelope(rm_msg_ctx->close_seq_res, env, soap_envelope);
    }
    if(rm_msg_ctx->create_seq)
    {
        sandesha2_create_seq_to_soap_envelope(rm_msg_ctx->create_seq, env, soap_envelope);
    }
    if(rm_msg_ctx->create_seq_res)
    {
        sandesha2_create_seq_res_to_soap_envelope(rm_msg_ctx->create_seq_res, env, soap_envelope);
    }
    if(rm_msg_ctx->make_connection)
    {
        sandesha2_make_connection_to_soap_envelope(rm_msg_ctx->make_connection, env, soap_envelope);
    }
    if(rm_msg_ctx->msg_pending)
    {
        sandesha2_msg_pending_to_soap_envelope(rm_msg_ctx->msg_pending, env, soap_envelope);
    }
    if(rm_msg_ctx->seq_ack)
    {
        sandesha2_seq_ack_to_soap_envelope(rm_msg_ctx->seq_ack, env, soap_envelope);
    }
    if(rm_msg_ctx->seq)
    {
        sandesha2_seq_to_soap_envelope(rm_msg_ctx->seq, env, soap_envelope);
    }
    if(rm_msg_ctx->terminate_seq)
    {
        sandesha2_terminate_seq_to_soap_envelope(rm_msg_ctx->terminate_seq, env, soap_envelope);
    }
    if(rm_msg_ctx->terminate_seq_res)
    {
        sandesha2_terminate_seq_res_to_soap_envelope(rm_msg_ctx->terminate_seq_res, env, soap_envelope);
    }
    return AXIS2_SUCCESS;
}
示例#14
0
axis2_status_t AXIS2_CALL
axis2_addr_out_handler_invoke(
    struct axis2_handler * handler,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axis2_char_t *addr_ver_from_msg_ctx = NULL;
    const axis2_char_t *addr_ns = NULL;
    axis2_msg_info_headers_t *msg_info_headers = NULL;
    axis2_ctx_t *ctx = NULL;
    axiom_soap_envelope_t *soap_envelope = NULL;
    axiom_soap_header_t *soap_header = NULL;
    axiom_node_t *soap_header_node = NULL;
    axiom_element_t *soap_header_ele = NULL;
    axis2_endpoint_ref_t *epr_to = NULL;
    axis2_endpoint_ref_t *epr_reply_to = NULL;
    axis2_endpoint_ref_t *epr_from = NULL;
    axis2_endpoint_ref_t *epr_fault_to = NULL;
    axutil_property_t *property = NULL;
    const axis2_char_t *wsa_action = NULL;
	axis2_bool_t set_must_understand = AXIS2_FALSE;
	axutil_property_t *must_understand_prop;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);

    AXIS2_LOG_INFO(env->log, "Starting addressing out handler");

    soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
    if(!soap_envelope)
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No SOAP envelope. Stop processing addressing");
        return AXIS2_SUCCESS; /* Can happen in case of ONE-WAY services/clients */
    }

    msg_info_headers = axis2_msg_ctx_get_msg_info_headers(msg_ctx, env);

    if(msg_info_headers)
    {
        wsa_action = axis2_msg_info_headers_get_action(msg_info_headers, env);
    }
    else
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No addressing in use");
        return AXIS2_SUCCESS; /* No addressing in use */
    }

    if(!wsa_action || !*wsa_action)
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No action present. Stop processing addressing");
        return AXIS2_SUCCESS; /* If no action present, assume no addressing in use */
    }


    ctx = axis2_msg_ctx_get_base(msg_ctx, env);
    property = axis2_ctx_get_property(ctx, env, AXIS2_WSA_VERSION);

    if(property)
    {
        addr_ver_from_msg_ctx = axutil_property_get_value(property, env);
        property = NULL;
    }

	must_understand_prop = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_ADDR_ADD_MUST_UNDERSTAND_TO_ADDR_HEADERS);
	if(must_understand_prop)
	{
		axis2_char_t *value = axutil_property_get_value(must_understand_prop, env);
		if(axutil_strcmp(value, AXIS2_VALUE_TRUE) == 0)
			set_must_understand = AXIS2_TRUE;
	}

    /* Setting version 1.0 as the default addressing namespace */
    addr_ns = AXIS2_WSA_NAMESPACE;

    if(addr_ver_from_msg_ctx)
    {
        if(!axutil_strcmp(AXIS2_WSA_NAMESPACE_SUBMISSION, addr_ver_from_msg_ctx))
        {
            addr_ns = AXIS2_WSA_NAMESPACE_SUBMISSION;
        }
    }
    else if(axis2_msg_ctx_get_op_ctx(msg_ctx, env))
    {
        axis2_op_ctx_t *op_ctx = NULL;
        axis2_msg_ctx_t *in_msg_ctx = NULL;
        op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);

        if(op_ctx)
        {
            in_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN);
        }

        if(in_msg_ctx)
        {
            axis2_ctx_t *in_ctx = NULL;
            in_ctx = axis2_msg_ctx_get_base(in_msg_ctx, env);

            property = axis2_ctx_get_property(in_ctx, env, AXIS2_WSA_VERSION);
            if(property)
            {
                addr_ns = axutil_property_get_value(property, env);
                property = NULL;
            }

            if(!addr_ns || !*addr_ns)
            {
                addr_ns = AXIS2_WSA_NAMESPACE;
            }
        }
    }

    soap_header = axiom_soap_envelope_get_header(soap_envelope, env);
    if(!soap_header)
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No SOAP header. Stop processing addressing");
        return AXIS2_SUCCESS; /* No SOAP header, so no point proceeding */
    }
    else
    {
        /* By this time, we definitely have some addressing information to be sent. This is because,
         * we have tested at the start of this whether msg_info_headers are null or not.
         * So rather than declaring addressing namespace in each and every addressing header, lets
         * define that in the Header itself.
         */
        const axis2_char_t *action = NULL;
        const axis2_char_t *address = NULL;
        const axis2_char_t *svc_group_context_id = NULL;
        const axis2_char_t *message_id = NULL;
        axis2_relates_to_t *relates_to = NULL;
        axiom_node_t *relates_to_header_node = NULL;
        axiom_element_t *relates_to_header_ele = NULL;
        axiom_namespace_t *addressing_namespace = NULL;

        soap_header_node = axiom_soap_header_get_base_node(soap_header, env);
        soap_header_ele = (axiom_element_t *)axiom_node_get_data_element(soap_header_node, env);

        addressing_namespace = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);

        axiom_element_declare_namespace(soap_header_ele, env, soap_header_node,
            addressing_namespace);

        epr_to = axis2_msg_info_headers_get_to(msg_info_headers, env);

        if(epr_to)
        {
            axiom_soap_body_t *body = axiom_soap_envelope_get_body(soap_envelope, env);

            if(body)
            {
                /* In case of a SOAP fault, we got to send the response to
                 the adress specified by FaultTo */
                if(axiom_soap_body_has_fault(body, env))
                {
                    axis2_endpoint_ref_t *epr_fault_to = axis2_msg_info_headers_get_fault_to(
                        msg_info_headers, env);
                    if(epr_fault_to)
                    {
                        const axis2_char_t *fault_to_address = axis2_endpoint_ref_get_address(
                            epr_fault_to, env);
                        if(fault_to_address)
                        {
                            if(axutil_strcmp(AXIS2_WSA_NONE_URL, fault_to_address)
                                && axutil_strcmp(AXIS2_WSA_NONE_URL_SUBMISSION, fault_to_address))
                            {
                                axis2_endpoint_ref_set_address(epr_to, env, fault_to_address);
                            }
                        }
                    }
                }
            }

            address = axis2_endpoint_ref_get_address(epr_to, env);
            if(address && *address)
            {
                axiom_node_t *to_header_block_node = NULL;
                axiom_soap_header_block_t *to_header_block = NULL;
                axutil_array_list_t *ref_param_list = NULL;
                int size = 0;

                to_header_block = axiom_soap_header_add_header_block(soap_header, env,
                    AXIS2_WSA_TO, addressing_namespace);
				if(set_must_understand == AXIS2_TRUE)
				{
					axiom_soap_header_block_set_must_understand_with_bool(to_header_block, env, AXIS2_TRUE);
				}
				to_header_block_node = axiom_soap_header_block_get_base_node(to_header_block, env);
                if(to_header_block_node)
                {
                    axiom_element_t *to_header_block_element = NULL;
                    to_header_block_element = (axiom_element_t *)axiom_node_get_data_element(
                        to_header_block_node, env);
                    if(to_header_block_element)
                    {
                        axiom_element_set_text(to_header_block_element, env, address,
                            to_header_block_node);
                    }
                }

                ref_param_list = axis2_endpoint_ref_get_ref_param_list(epr_to, env);

                size = axutil_array_list_size(ref_param_list, env);
                if(ref_param_list && size > 0)
                {
                    axiom_soap_header_block_t *reference_header_block = NULL;
                    axiom_node_t *reference_node = NULL;
                    int i = 0;

                    for(i = 0; i < size; i++)
                    {
                        axiom_node_t *temp_node = NULL;

                        temp_node = (axiom_node_t *)axutil_array_list_get(ref_param_list, env, i);
                        if(temp_node)
                        {
                            axiom_element_t *temp_ele = NULL;

                            temp_ele = axiom_node_get_data_element(temp_node, env);
                            if(temp_ele)
                            {
                                reference_header_block = axiom_soap_header_add_header_block(
                                    soap_header, env, axiom_element_get_localname(temp_ele, env),
                                    axiom_element_get_namespace(temp_ele, env, temp_node));
								if(set_must_understand)
								{
									axiom_soap_header_block_set_must_understand_with_bool(reference_header_block, env, AXIS2_TRUE);
								}

                                reference_node = axiom_soap_header_block_get_base_node(
                                    reference_header_block, env);
                                if(reference_node)
                                {
                                    axiom_element_t *reference_ele = NULL;
                                    reference_ele = (axiom_element_t *)axiom_node_get_data_element(
                                        reference_node, env);

                                    if(reference_ele)
                                    {
                                        axiom_namespace_t *addr_ns_obj = NULL;
                                        axiom_attribute_t *reference_attr = NULL;

                                        addr_ns_obj = axiom_namespace_create(env, addr_ns,
                                            AXIS2_WSA_DEFAULT_PREFIX);
                                        reference_attr = axiom_attribute_create(env,
                                        /*"isReferenceParameter"*/
                                        AXIS2_WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE, "true",
                                            addr_ns_obj);
                                        axiom_element_add_attribute(reference_ele, env,
                                            reference_attr, reference_node);
                                        axiom_element_set_text(reference_ele, env,
                                            axiom_element_get_text(temp_ele, env, temp_node),
                                            reference_node);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }/* if(epr_to) */

		axiom_namespace_free(addressing_namespace, env);

        action = axis2_msg_info_headers_get_action(msg_info_headers, env);
        if(action && *action)
        {
            axis2_addr_out_handler_process_string_info(env, action, AXIS2_WSA_ACTION, &soap_header,
				addr_ns, set_must_understand);
        }

        epr_reply_to = axis2_msg_info_headers_get_reply_to(msg_info_headers, env);
        if(!epr_reply_to)
        {
            const axis2_char_t *anonymous_uri = NULL;
            axis2_bool_t anonymous = axis2_msg_info_headers_get_reply_to_anonymous(
                msg_info_headers, env);
            axis2_bool_t none = axis2_msg_info_headers_get_reply_to_none(msg_info_headers, env);
            if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION))
            {
                if(none)
                {
                    anonymous_uri = AXIS2_WSA_NONE_URL_SUBMISSION;
                }
                else if(anonymous)
                {
                    anonymous_uri = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION;
                }
            }
            else
            {
                if(none)
                {
                    anonymous_uri = AXIS2_WSA_NONE_URL;
                }
                else if(anonymous)
                {
                    anonymous_uri = AXIS2_WSA_ANONYMOUS_URL;
                }
            }

            if(anonymous_uri)
            {
                epr_reply_to = axis2_endpoint_ref_create(env, anonymous_uri);
            }

            if(epr_reply_to)
            {
                axis2_msg_info_headers_set_reply_to(msg_info_headers, env, epr_reply_to);
            }
        }

        /* add the service group id as a reference parameter */
        svc_group_context_id = axutil_string_get_buffer(axis2_msg_ctx_get_svc_grp_ctx_id(msg_ctx,
            env), env);

        axis2_addr_out_handler_add_to_soap_header(env, epr_reply_to, AXIS2_WSA_REPLY_TO,
            soap_header, addr_ns);

        epr_from = axis2_msg_info_headers_get_from(msg_info_headers, env);

        if(epr_from)
        {
            axis2_addr_out_handler_add_to_soap_header(env, epr_from, AXIS2_WSA_FROM, soap_header,
                addr_ns);

        }

        epr_fault_to = axis2_msg_info_headers_get_fault_to(msg_info_headers, env);
        if(!epr_fault_to)
        {
            const axis2_char_t *anonymous_uri = NULL;
            axis2_bool_t anonymous = axis2_msg_info_headers_get_fault_to_anonymous(
                msg_info_headers, env);
            axis2_bool_t none = axis2_msg_info_headers_get_fault_to_none(msg_info_headers, env);
            if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION))
            {
                if(none)
                {
                    anonymous_uri = AXIS2_WSA_NONE_URL_SUBMISSION;
                }
                else if(anonymous)
                {
                    anonymous_uri = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION;
                }
            }
            else
            {
                if(none)
                    anonymous_uri = AXIS2_WSA_NONE_URL;
                else if(anonymous)
                    anonymous_uri = AXIS2_WSA_ANONYMOUS_URL;
            }

            if(anonymous_uri)
            {
                epr_fault_to = axis2_endpoint_ref_create(env, anonymous_uri);
            }
        }

        if(epr_fault_to)
        {
            /* optional */
            axis2_addr_out_handler_add_to_soap_header(env, epr_fault_to, AXIS2_WSA_FAULT_TO,
                soap_header, addr_ns);
        }

        message_id = axis2_msg_info_headers_get_message_id(msg_info_headers, env);

        if(message_id)
        {
            axis2_addr_out_handler_process_string_info(env, message_id, AXIS2_WSA_MESSAGE_ID,
				&soap_header, addr_ns, set_must_understand);
        }

        relates_to = axis2_msg_info_headers_get_relates_to(msg_info_headers, env);

        if(relates_to)
        {
            const axis2_char_t *value = NULL;
            value = axis2_relates_to_get_value(relates_to, env);
            relates_to_header_node = axis2_addr_out_handler_process_string_info(env, value,
				AXIS2_WSA_RELATES_TO, &soap_header, addr_ns, set_must_understand);
        }

        if(relates_to_header_node)
        {
            const axis2_char_t *relationship_type = NULL;
            relationship_type = axis2_relates_to_get_relationship_type(relates_to, env);
            if(relationship_type && *relationship_type)
            {
                axiom_attribute_t *om_attr = NULL;
                axiom_namespace_t *addr_ns_obj = NULL;
                axiom_namespace_t *dec_ns = NULL;
                relates_to_header_ele = (axiom_element_t *)axiom_node_get_data_element(
                    relates_to_header_node, env);
                if(relates_to_header_ele)
                {
                    dec_ns = axiom_element_find_declared_namespace(relates_to_header_ele, env,
                        addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
                    if(dec_ns)
                    {
                        addr_ns_obj = dec_ns;
                    }
                    else
                    {
                        addr_ns_obj
                            = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
                    }

                    if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION))
                    {
                        om_attr = axiom_attribute_create(env,
                            AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE,
                            AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE_SUBMISSION,
                            addr_ns_obj);
                    }
                    else
                    {
                        om_attr = axiom_attribute_create(env,
                            AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE,
                            AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE, addr_ns_obj);
                    }

                    axiom_element_add_attribute(relates_to_header_ele, env, om_attr,
                        relates_to_header_node);

                    dec_ns = axiom_element_find_declared_namespace(relates_to_header_ele, env,
                        addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
                    if(!dec_ns)
                    {
                        dec_ns = axiom_element_find_namespace(relates_to_header_ele, env,
                            relates_to_header_node, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
                        if(dec_ns)
                        {
                            axiom_namespace_free(addr_ns_obj, env);
                            addr_ns_obj = NULL;
                            axiom_attribute_set_namespace(om_attr, env, dec_ns);
                        }
                    }
                }

            }
        }
    }
    return AXIS2_SUCCESS;
}
示例#15
0
文件: util.c 项目: AdrianRys/wsf
axis2_status_t
wsclient_soap_out (const axutil_env_t *env,
				   axis2_svc_client_t *svc_client, int soap_out)
{
	axis2_op_client_t *op_client;
	axis2_msg_ctx_t *msg_ctx;
	axiom_soap_envelope_t *soap_envelope = NULL;
	axiom_xml_writer_t *writer;
	axiom_output_t *om_output = NULL;
	axis2_char_t *buffer;
	axis2_status_t status = 0;
	op_client = axis2_svc_client_get_op_client(svc_client, env);
	if (op_client)
	{

		if (soap_out)
			msg_ctx = (axis2_msg_ctx_t *)
				axis2_op_client_get_msg_ctx (op_client,
											 env, 
											 AXIS2_WSDL_MESSAGE_LABEL_IN);
		else
			msg_ctx = (axis2_msg_ctx_t *)
				axis2_op_client_get_msg_ctx (op_client,
											 env, 
											 AXIS2_WSDL_MESSAGE_LABEL_OUT);

		if (msg_ctx)
			soap_envelope = axis2_msg_ctx_get_soap_envelope (msg_ctx,
															 env);
		else
			return AXIS2_FAILURE;

		writer = axiom_xml_writer_create_for_memory (env,
													 NULL,
													 AXIS2_TRUE,
													 0,
													 AXIS2_XML_PARSER_TYPE_BUFFER);

		if (writer)
			om_output = axiom_output_create(env, writer);
		else
			return AXIS2_FAILURE;

		if (soap_envelope && om_output)
			status =  axiom_soap_envelope_serialize(soap_envelope,
													env, 
													om_output, 
													0);
		else
			return AXIS2_FAILURE;

		if (status == AXIS2_SUCCESS)
		{
			buffer = (axis2_char_t *)
				axiom_xml_writer_get_xml (writer,
										  env);
			if (buffer)
			{
				printf ("%s", buffer);
				AXIS2_FREE (env->allocator, buffer);
			}
		}
		else
			return AXIS2_FAILURE;
	}
	return AXIS2_SUCCESS;
}
示例#16
0
axis2_status_t __euca_authenticate(const axutil_env_t *env,axis2_msg_ctx_t *out_msg_ctx, axis2_op_ctx_t *op_ctx)
{
  //***** First get the message context before doing anything dumb w/ a NULL pointer *****/
  axis2_msg_ctx_t *msg_ctx = NULL; //<--- incoming msg context, it is NULL, see?
  msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN);  

  //***** Print everything from the security results, just for testing now *****//
  rampart_context_t *rampart_context = NULL;
  axutil_property_t *property = NULL;

  property = axis2_msg_ctx_get_property(msg_ctx, env, RAMPART_CONTEXT);
  if(property)
  {
     rampart_context = (rampart_context_t *)axutil_property_get_value(property, env);
     //     AXIS2_LOG_CRITICAL(env->log,AXIS2_LOG_SI," ======== PRINTING PROCESSED WSSEC TOKENS ======== ");
     rampart_print_security_processed_results_set(env,msg_ctx);
  }

  //***** Extract Security Node from header from enveloper from msg_ctx *****//
  axiom_soap_envelope_t *soap_envelope = NULL;
  axiom_soap_header_t *soap_header = NULL;
  axiom_node_t *sec_node = NULL;


  soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
  if(!soap_envelope) NO_U_FAIL("SOAP envelope cannot be found."); 
  soap_header = axiom_soap_envelope_get_header(soap_envelope, env);
  if (!soap_header) NO_U_FAIL("SOAP header cannot be found.");
  sec_node = rampart_get_security_header(env, msg_ctx, soap_header); // <---- here it is!
  if(!sec_node)NO_U_FAIL("No node wsse:Security -- required: ws-security");

  //***** Find the wsse:Reference to the BinarySecurityToken *****//
  //** Path is: Security/
  //** *sec_node must be non-NULL, kkthx **//
  axiom_node_t *sig_node = NULL;
  axiom_node_t *key_info_node = NULL;
  axiom_node_t *sec_token_ref_node = NULL;
  /** the ds:Signature node **/
  sig_node = oxs_axiom_get_first_child_node_by_name(env,sec_node, OXS_NODE_SIGNATURE, OXS_DSIG_NS, OXS_DS );
  if(!sig_node)NO_U_FAIL("No node ds:Signature -- required: signature");
  /** the ds:KeyInfo **/
  key_info_node = oxs_axiom_get_first_child_node_by_name(env, sig_node, OXS_NODE_KEY_INFO, OXS_DSIG_NS, NULL );
  if(!key_info_node)NO_U_FAIL("No node ds:KeyInfo -- required: signature key");
  /** the wsse:SecurityTokenReference **/ 
  sec_token_ref_node = oxs_axiom_get_first_child_node_by_name(env, key_info_node,OXS_NODE_SECURITY_TOKEN_REFRENCE, OXS_WSSE_XMLNS, NULL);
  if(!sec_token_ref_node)NO_U_FAIL("No node wsse:SecurityTokenReference -- required: signing token");
  //** in theory this is the branching point for supporting all kinds of tokens -- we only do BST Direct Reference **/

  //***** Find the wsse:Reference to the BinarySecurityToken *****//
  //** *sec_token_ref_node must be non-NULL **/
  axis2_char_t *ref = NULL;
  axis2_char_t *ref_id = NULL;
  axiom_node_t *token_ref_node = NULL;
  axiom_node_t *bst_node = NULL;
  /** the wsse:Reference node **/
  token_ref_node = oxs_axiom_get_first_child_node_by_name(env, sec_token_ref_node,OXS_NODE_REFERENCE, OXS_WSSE_XMLNS, NULL);
  /** pull out the name of the BST node **/
  ref = oxs_token_get_reference(env, token_ref_node);
  ref_id = axutil_string_substring_starting_at(axutil_strdup(env, ref), 1);
  /** get the wsse:BinarySecurityToken used to sign the message **/
  bst_node = oxs_axiom_get_node_by_id(env, sec_node, "Id", ref_id, OXS_WSU_XMLNS);
  if(!bst_node){oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_ELEMENT_FAILED, "Error retrieving elementwith ID=%s", ref_id);NO_U_FAIL("Cant find the required node");}


  //***** Find the wsse:Reference to the BinarySecurityToken *****//
  //** *bst_node must be non-NULL **/
  axis2_char_t *data = NULL;
  oxs_x509_cert_t *_cert = NULL;
  oxs_x509_cert_t *recv_cert = NULL;
  axis2_char_t *file_name = NULL;
  axis2_char_t *recv_x509_buf = NULL;
  axis2_char_t *msg_x509_buf = NULL;

  /** pull out the data from the BST **/
  data = oxs_axiom_get_node_content(env, bst_node);
  /** create an oxs_X509_cert **/
  _cert = oxs_key_mgr_load_x509_cert_from_string(env, data);
  if(_cert)
  {
    //***** FINALLY -- we have the certificate used to sign the message.  authenticate it HERE *****//
    msg_x509_buf = oxs_x509_cert_get_data(_cert,env);
    if(!msg_x509_buf)NO_U_FAIL("OMG WHAT NOW?!");
    /*
    recv_x509_buf = (axis2_char_t *)rampart_context_get_receiver_certificate(rampart_context, env);
    if(recv_x509_buf)
        recv_cert = oxs_key_mgr_load_x509_cert_from_string(env, recv_x509_buf);
    else
    {
        file_name = rampart_context_get_receiver_certificate_file(rampart_context, env);
        if(!file_name) NO_U_FAIL("Policy for the service is incorrect -- ReceiverCertificate is not set!!");
	if (check_file(file_name)) NO_U_FAIL("No cert file ($EUCALYPTUS/var/lib/eucalyptus/keys/cloud-cert.pem) found, failing");
        recv_cert = oxs_key_mgr_load_x509_cert_from_pem_file(env, file_name);
    }
    */

    file_name = rampart_context_get_receiver_certificate_file(rampart_context, env);
    if(!file_name) NO_U_FAIL("Policy for the service is incorrect -- ReceiverCertificate is not set!!");
    if (check_file(file_name)) NO_U_FAIL("No cert file ($EUCALYPTUS/var/lib/eucalyptus/keys/cloud-cert.pem) found, failing");
    recv_cert = oxs_key_mgr_load_x509_cert_from_pem_file(env, file_name);

    if (recv_cert) {
      recv_x509_buf = oxs_x509_cert_get_data(recv_cert,env);
    } else {
      NO_U_FAIL("could not populate receiver cert");
    }

    if( axutil_strcmp(recv_x509_buf,msg_x509_buf)!=0){
      AXIS2_LOG_CRITICAL(env->log,AXIS2_LOG_SI," --------- Received x509 certificate value ---------" );
      AXIS2_LOG_CRITICAL(env->log,AXIS2_LOG_SI, msg_x509_buf );
      AXIS2_LOG_CRITICAL(env->log,AXIS2_LOG_SI," --------- Local x509 certificate value! ---------" );
      AXIS2_LOG_CRITICAL(env->log,AXIS2_LOG_SI, recv_x509_buf );
      AXIS2_LOG_CRITICAL(env->log,AXIS2_LOG_SI," ---------------------------------------------------" );
      NO_U_FAIL("The certificate specified is invalid!");
    }
  }
  else 
  {
    oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_DEFAULT, "Cannot load certificate from string =%s", data); 
    NO_U_FAIL("Failed to build certificate from BinarySecurityToken");
  }
  oxs_x509_cert_free(_cert, env);
  oxs_x509_cert_free(recv_cert, env);
  return AXIS2_SUCCESS;

}
static axis2_status_t AXIS2_CALL
axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync(
    axis2_msg_recv_t * msg_recv,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx,
    axis2_msg_ctx_t * new_msg_ctx)
{
    axis2_svc_skeleton_t *svc_obj = NULL;
    axis2_op_ctx_t *op_ctx = NULL;
    axis2_op_t *op_desc = NULL;
    const axis2_char_t *style = NULL;
    axiom_node_t *om_node = NULL;
    axiom_element_t *om_element = NULL;
    axis2_char_t *local_name = NULL;
    axiom_node_t *result_node = NULL;
    axiom_node_t *body_content_node = NULL;
    axiom_element_t *body_content_element = NULL;
    axiom_soap_envelope_t *default_envelope = NULL;
    axiom_soap_body_t *out_body = NULL;
    axiom_soap_header_t *out_header = NULL;
    axiom_soap_fault_t *soap_fault = NULL;
    axiom_node_t *out_node = NULL;
    axis2_status_t status = AXIS2_SUCCESS;
    axis2_bool_t skel_invoked = AXIS2_FALSE;
    const axis2_char_t *soap_ns = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
    int soap_version = AXIOM_SOAP12;
    axiom_namespace_t *env_ns = NULL;
    axiom_node_t *fault_node = NULL;
    axiom_soap_fault_detail_t *fault_detail;
    axis2_bool_t is_fault = AXIS2_FALSE;

    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, new_msg_ctx, AXIS2_FAILURE);

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
        "[axis2]Entry:axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync");

    /* get the implementation class for the Web Service */
    svc_obj = axis2_msg_recv_make_new_svc_obj(msg_recv, env, msg_ctx);

    if(!svc_obj)
    {
        const axis2_char_t *svc_name = NULL;
        axis2_svc_t *svc = axis2_msg_ctx_get_svc(msg_ctx, env);

        if(svc)
        {
            svc_name = axis2_svc_get_name(svc, env);
        }
        else
        {
            svc_name = "unknown";
        }

        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
            "Impl object for service '%s' not set in message receiver. %d :: %s", svc_name,
            env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error));

        status = AXIS2_FAILURE;
    }
    else
    {
        op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
        op_desc = axis2_op_ctx_get_op(op_ctx, env);

        style = axis2_op_get_style(op_desc, env);
        if(0 == axutil_strcmp(AXIS2_STYLE_DOC, style))
        {
            axiom_soap_envelope_t *envelope = NULL;
            axiom_soap_body_t *body = NULL;

            envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
            body = axiom_soap_envelope_get_body(envelope, env);
            om_node = axiom_soap_body_get_base_node(body, env);
            om_element = axiom_node_get_data_element(om_node, env);
            om_node = axiom_node_get_first_element(om_node, env);
        }
        else if(0 == axutil_strcmp(AXIS2_STYLE_RPC, style))
        {
            axiom_soap_envelope_t *envelope = NULL;
            axiom_soap_body_t *body = NULL;
            axiom_node_t *op_node = NULL;
            axiom_element_t *op_element = NULL;

            envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
            body = axiom_soap_envelope_get_body(envelope, env);
            op_node = axiom_soap_body_get_base_node(body, env);
            op_element = axiom_node_get_data_element(op_node, env);
            if(op_element)
            {
                local_name = axiom_element_get_localname(op_element, env);
                if(local_name)
                {
                    axutil_array_list_t *function_arr = NULL;
                    int i = 0;
                    int size = 0;
                    axis2_bool_t matches = AXIS2_FALSE;

                    function_arr = svc_obj->func_array;
                    if(function_arr)
                    {
                        size = axutil_array_list_size(function_arr, env);
                    }

                    for(i = 0; i < size; i++)
                    {
                        axis2_char_t *function_name = NULL;

                        function_name = (axis2_char_t *)axutil_array_list_get(function_arr, env, i);
                        if(!axutil_strcmp(function_name, local_name))
                        {
                            matches = AXIS2_TRUE;

                        }
                    }

                    if(matches)
                    {
                        om_node = axiom_node_get_first_child(op_node, env);
                        om_element = axiom_node_get_data_element(om_node, env);
                    }
                    else
                    {
                        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_OM_ELEMENT_MISMATCH, AXIS2_FAILURE);
                        status = AXIS2_FAILURE;
                    }
                }
                else
                {
                    AXIS2_ERROR_SET(env->error, AXIS2_ERROR_OM_ELEMENT_INVALID_STATE, AXIS2_FAILURE);
                    status = AXIS2_FAILURE;
                }
            }
            else
            {
                AXIS2_ERROR_SET(env->error, AXIS2_ERROR_RPC_NEED_MATCHING_CHILD, AXIS2_FAILURE);
                status = AXIS2_FAILURE;
            }
        }
        else
        {
            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_UNKNOWN_STYLE, AXIS2_FAILURE);
            status = AXIS2_FAILURE;
        }

        if(status == AXIS2_SUCCESS)
        {
            skel_invoked = AXIS2_TRUE;
            result_node = AXIS2_SVC_SKELETON_INVOKE(svc_obj, env, om_node, new_msg_ctx);
        }

        if(result_node)
        {
            if(0 == axutil_strcmp(style, AXIS2_STYLE_RPC))
            {
                axiom_namespace_t *ns = NULL;
                axis2_char_t *res_name = NULL;

                res_name = axutil_stracat(env, local_name, "Response");
                ns = axiom_namespace_create(env, "http://soapenc/", "res");
                if(!ns)
                {
                    status = AXIS2_FAILURE;
                }
                else
                {
                    body_content_element = axiom_element_create(env, NULL, res_name, ns,
                        &body_content_node);
                    axiom_node_add_child(body_content_node, env, result_node);
                }
            }
            else
            {
                body_content_node = result_node;
            }
        }
        else
        {
            axis2_char_t *mep = (axis2_char_t *)axis2_op_get_msg_exchange_pattern(op_desc, env);
            if(axutil_strcmp(mep, AXIS2_MEP_URI_IN_ONLY) && axutil_strcmp(mep,
				AXIS2_MEP_URI_ROBUST_IN_ONLY) && axutil_strcmp(mep, AXIS2_MEP_URI_IN_ONLY_WSDL2) &&						axutil_strcmp(mep, AXIS2_MEP_URI_ROBUST_IN_ONLY_WSDL2))
            {
                status = AXIS2_ERROR_GET_STATUS_CODE(env->error);
                if(status == AXIS2_SUCCESS)
                {
                    axis2_msg_ctx_set_no_content(new_msg_ctx, env, AXIS2_TRUE);
                }
                else
                {
                    axis2_msg_ctx_set_status_code(msg_ctx, env, axis2_msg_ctx_get_status_code(
                        new_msg_ctx, env));
                }
                /* The new_msg_ctx is passed to the service. The status code must
                 * be taken from here and set to the old message context which is
                 * used by the worker when the request processing fails.
                 */
                if(svc_obj->ops->on_fault)
                {
                    fault_node = AXIS2_SVC_SKELETON_ON_FAULT(svc_obj, env, om_node);
                }
                is_fault = AXIS2_TRUE;
            }
            else
            {
                /* If we have a in only message result node is NULL. We create fault only if
                 * an error is set
                 */
                status = AXIS2_ERROR_GET_STATUS_CODE(env->error);
                if(status == AXIS2_SUCCESS)
                {
                    axis2_msg_ctx_set_no_content(new_msg_ctx, env, AXIS2_TRUE);
                }
                else
                {
                    axis2_msg_ctx_set_status_code(msg_ctx, env, axis2_msg_ctx_get_status_code(
                        new_msg_ctx, env));
					if((!axutil_strcmp(mep, AXIS2_MEP_URI_ROBUST_IN_ONLY)) || 
						(!axutil_strcmp(mep, AXIS2_MEP_URI_ROBUST_IN_ONLY_WSDL2)))
                    {
                        /* The new_msg_ctx is passed to the service. The status code must
                         * be taken from here and set to the old message context which is
                         * used by the worker when the request processing fails.
                         */
                        if(svc_obj->ops->on_fault)
                        {
                            fault_node = AXIS2_SVC_SKELETON_ON_FAULT(svc_obj, env, om_node);
                        }
                        is_fault = AXIS2_TRUE;
                    }
                }
            }
        }
    }

    if(msg_ctx && axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
    {
        soap_ns = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; /* default is 1.2 */
        soap_version = AXIOM_SOAP11;
    }

    if(axis2_msg_ctx_get_soap_envelope(new_msg_ctx, env))
    {
        /* service implementation has set the envelope,
         useful when setting a SOAP fault.
         No need to further process */
        return AXIS2_SUCCESS;
    }

    /* create the soap envelope here */
    env_ns = axiom_namespace_create(env, soap_ns, "soapenv");
    if(!env_ns)
    {
        return AXIS2_FAILURE;
    }

    default_envelope = axiom_soap_envelope_create(env, env_ns);
	axiom_namespace_free(env_ns, env);

    if(!default_envelope)
    {
        return AXIS2_FAILURE;
    }

    out_header = axiom_soap_header_create_with_parent(env, default_envelope);
    if(!out_header)
    {
        return AXIS2_FAILURE;
    }

    out_body = axiom_soap_body_create_with_parent(env, default_envelope);
    if(!out_body)
    {
        return AXIS2_FAILURE;
    }

    out_node = axiom_soap_body_get_base_node(out_body, env);
    if(!out_node)
    {
        return AXIS2_FAILURE;
    }

    if(status != AXIS2_SUCCESS || is_fault)
    {
        /* something went wrong. set a SOAP Fault */
        const axis2_char_t *fault_value_str = "soapenv:Sender";
        const axis2_char_t *fault_reason_str = NULL;
        const axis2_char_t *err_msg = NULL;

        if(!skel_invoked)
        {
            if(axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
            {
fault_value_str            =
            AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
            AXIOM_SOAP11_FAULT_CODE_RECEIVER;
        }
        else
        {
            fault_value_str =
            AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
            AXIOM_SOAP12_SOAP_FAULT_VALUE_RECEIVER;
        }
    }

    err_msg = AXIS2_ERROR_GET_MESSAGE(env->error);
    if (err_msg && axutil_strcmp(err_msg, ""))
    {
        if(!axutil_strcmp(err_msg, "No Error"))
        {
            fault_reason_str = "An error has occurred, but could not determine exact details";
        }
        else
        {
            fault_reason_str = err_msg;
        }
    }
    else
    {
        fault_reason_str = "An error has occurred, but could not determine exact details";
    }

    soap_fault = axiom_soap_fault_create_default_fault(env, out_body, fault_value_str,
        fault_reason_str, soap_version);

    if (fault_node)
    {
        axiom_node_t *fault_detail_node = NULL;
        axis2_char_t *om_str = NULL;

        fault_detail = axiom_soap_fault_detail_create_with_parent(env, soap_fault);
        fault_detail_node = axiom_soap_fault_detail_get_base_node(fault_detail, env);

        om_str = axiom_node_to_string(fault_detail_node, env);
        if (om_str)
        {
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "fault_detail:%s", om_str);
            AXIS2_FREE(env->allocator, om_str);
        }

        axiom_soap_fault_detail_add_detail_entry(fault_detail, env, fault_node);
    }
}

if (body_content_node)
{
    axiom_node_add_child(out_node, env, body_content_node);
    status = axis2_msg_ctx_set_soap_envelope(new_msg_ctx, env, default_envelope);
}
else if (soap_fault)
{
    axis2_msg_ctx_set_soap_envelope(new_msg_ctx, env, default_envelope);
    status = AXIS2_SUCCESS;
}
else
{
    /* we should free the memory as the envelope is not used, one way case */
    axiom_soap_envelope_free(default_envelope, env);
    default_envelope = NULL;
}

AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
    "[axis2]Exit:axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync");

return status;
}
static axis2_status_t AXIS2_CALL 
sandesha2_ack_req_msg_processor_process_in_msg (
    sandesha2_msg_processor_t *msg_processor,
    const axutil_env_t *env,
    sandesha2_msg_ctx_t *rm_msg_ctx)
{
    sandesha2_ack_requested_t *ack_requested = NULL;
    axis2_msg_ctx_t *msg_ctx = NULL;
    axis2_char_t *seq_id = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    sandesha2_storage_mgr_t *storage_mgr = NULL;
    sandesha2_seq_property_mgr_t *seq_prop_mgr = NULL;
    sandesha2_seq_property_bean_t *acks_to_bean = NULL;
    axis2_endpoint_ref_t *acks_to = NULL;
    axis2_char_t *acks_to_str = NULL;
    axis2_op_t *ack_op = NULL;
    axis2_op_t *rm_msg_op = NULL;
    axis2_msg_ctx_t *ack_msg_ctx = NULL;
    axutil_property_t *property = NULL;
    sandesha2_msg_ctx_t *ack_rm_msg = NULL;
    axiom_soap_envelope_t *envelope = NULL;
    axis2_char_t *wsa_version = NULL;
    axis2_char_t *dbname = NULL;
    
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
        "[sandesha2]Entry:sandesha2_ack_req_msg_processor_process_in_msg");
    AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE);
    
    ack_requested = sandesha2_msg_ctx_get_ack_requested(rm_msg_ctx, env);
    if(!ack_requested)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
            "[sandesha2]Ack requested part is missing");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING,
            AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }
    sandesha2_ack_requested_set_must_understand(ack_requested, env, AXIS2_FALSE);
    sandesha2_msg_ctx_add_soap_envelope(rm_msg_ctx, env);
    
    msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env);
    seq_id = sandesha2_identifier_get_identifier(
        sandesha2_ack_requested_get_identifier(ack_requested, env), env);
    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    dbname = sandesha2_util_get_dbname(env, conf_ctx);
    storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname);
    if(!storage_mgr)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Could not create storage manager.");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_COULD_NOT_CREATE_STORAGE_MANAGER, 
                AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }
    seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
    acks_to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, seq_id,
        SANDESHA2_SEQ_PROP_ACKS_TO_EPR);
    acks_to_str = sandesha2_seq_property_bean_get_value(acks_to_bean, env);
    
    if(!acks_to_str)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]acks_to_str"\
            " seqeunce property is not set correctly");
        if(seq_prop_mgr)
            sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
        if(storage_mgr)
            sandesha2_storage_mgr_free(storage_mgr, env);
        return AXIS2_FAILURE;
    }
    acks_to = axis2_endpoint_ref_create(env, acks_to_str);
    ack_op = axis2_op_create(env);
    axis2_op_set_msg_exchange_pattern(ack_op, env, AXIS2_MEP_URI_IN_ONLY);
    rm_msg_op = axis2_msg_ctx_get_op(msg_ctx, env);
    if(rm_msg_op)
    {
        axutil_array_list_t *out_flow = NULL;
        axutil_array_list_t *new_out_flow = NULL;
        axutil_array_list_t *out_fault_flow = NULL;
        axutil_array_list_t *new_out_fault_flow = NULL;
        out_flow = axis2_op_get_out_flow(rm_msg_op, env);
        new_out_flow = axis2_phases_info_copy_flow(env, out_flow);
        out_fault_flow = axis2_op_get_out_flow(rm_msg_op, env);
        new_out_fault_flow = axis2_phases_info_copy_flow(env, out_fault_flow);
        if(new_out_flow)
            axis2_op_set_out_flow(ack_op, env, new_out_flow);
        if(new_out_fault_flow)
            axis2_op_set_fault_out_flow(ack_op, env, new_out_fault_flow);
    }

    ack_msg_ctx = sandesha2_utils_create_new_related_msg_ctx(env, rm_msg_ctx);

    property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
    axis2_msg_ctx_set_property(ack_msg_ctx, env, 
        SANDESHA2_APPLICATION_PROCESSING_DONE, property);
    ack_rm_msg = sandesha2_msg_init_init_msg(env, ack_msg_ctx);
    sandesha2_msg_ctx_set_rm_ns_val(ack_rm_msg, env, 
        sandesha2_msg_ctx_get_rm_ns_val(rm_msg_ctx, env));
    axis2_msg_ctx_set_message_id(ack_msg_ctx, env, axutil_uuid_gen(env));
    
    envelope = axiom_soap_envelope_create_default_soap_envelope(env, 
        sandesha2_utils_get_soap_version(env, 
        axis2_msg_ctx_get_soap_envelope(msg_ctx, env)));
    axis2_msg_ctx_set_soap_envelope(ack_msg_ctx, env, envelope);
    axis2_msg_ctx_set_to(ack_msg_ctx, env, acks_to);
    axis2_msg_ctx_set_reply_to(ack_msg_ctx, env, axis2_msg_ctx_get_to(msg_ctx, 
        env));
    sandesha2_msg_creator_add_ack_msg(env, ack_rm_msg, seq_id, seq_prop_mgr);
    axis2_msg_ctx_set_server_side(ack_msg_ctx, env, AXIS2_TRUE);
    
    property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_WSA_VERSION);
    if(property)
        wsa_version = axutil_property_get_value(property, env);
    
    property = axutil_property_create_with_args(env, 0, 0, 0, wsa_version);
    if(property)
    {
        axis2_msg_ctx_set_property(ack_msg_ctx, env, AXIS2_WSA_VERSION, property);
        property = NULL;
    }
    
    if(sandesha2_utils_is_anon_uri(env, acks_to_str))
    {
        axis2_engine_t *engine = NULL;
        axis2_op_ctx_t *op_ctx = NULL;
        
        if(!axis2_msg_ctx_get_op(msg_ctx, env))
        {
            axis2_op_t *operation = NULL;
            axis2_op_ctx_t *op_ctx = NULL;
            
            operation = axis2_op_create(env);
            axis2_op_set_msg_exchange_pattern(operation, env, 
                AXIS2_MEP_URI_IN_OUT);
            op_ctx = axis2_op_ctx_create(env, operation, NULL);
            axis2_msg_ctx_set_op(msg_ctx, env, operation);
            axis2_msg_ctx_set_op_ctx(msg_ctx, env, op_ctx);            
        }
        op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
        axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_TRUE);
        
        property = axutil_property_create_with_args(env, 0, 0, 0, 
            AXIS2_VALUE_TRUE);
        axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_ACK_WRITTEN, 
            property);
        
        engine = axis2_engine_create(env, conf_ctx);
        if(AXIS2_FAILURE == axis2_engine_send(engine, env, ack_msg_ctx))
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                "[sandesha2]ack sending failed");
            AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SENDING_ACK, 
                AXIS2_FAILURE);
            if(engine)
            {
                axis2_engine_free(engine, env);
                engine = NULL;
            }
            if(seq_prop_mgr)
                sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
            if(storage_mgr)
                sandesha2_storage_mgr_free(storage_mgr, env);
            return AXIS2_FAILURE;
        }        
        if(engine)
        {
            axis2_engine_free(engine, env);
            engine = NULL;
        }
    }
    else
    {
        sandesha2_sender_mgr_t *sender_mgr = NULL;
        axis2_char_t *key = NULL;
        sandesha2_sender_bean_t *ack_bean = NULL;
        sandesha2_sender_bean_t *find_bean = NULL;
        sandesha2_property_bean_t *prop_bean = NULL;
        long ack_interval = 0;
        long time_to_send = 0;
        axutil_array_list_t *found_list = NULL;
        axis2_msg_ctx_t *msg_ctx = NULL;
        axis2_engine_t *engine = NULL;
        axis2_transport_out_desc_t *transport_out = NULL;
        axis2_svc_t *svc = NULL;
        
        sender_mgr = sandesha2_permanent_sender_mgr_create(env, dbname);
        key = axutil_uuid_gen(env);
        ack_bean = sandesha2_sender_bean_create(env);
        sandesha2_sender_bean_set_msg_ctx_ref_key(ack_bean, env, key);
        sandesha2_sender_bean_set_msg_id(ack_bean, env, 
            (axis2_char_t*)axis2_msg_ctx_get_msg_id(ack_msg_ctx, env));
        sandesha2_sender_bean_set_resend(ack_bean, env, AXIS2_FALSE);
        sandesha2_sender_bean_set_seq_id(ack_bean, env, seq_id);
        sandesha2_sender_bean_set_send(ack_bean, env, AXIS2_TRUE);
        sandesha2_sender_bean_set_msg_type(ack_bean, env, SANDESHA2_MSG_TYPE_ACK);
                        
        property = axutil_property_create_with_args(env, 0, 0, 0, 
            AXIS2_VALUE_FALSE);
        axis2_msg_ctx_set_property(ack_msg_ctx, env, 
            SANDESHA2_QUALIFIED_FOR_SENDING, property);
        
        /* Avoid retrieving property bean from operation until it is availbale */
        /*prop_bean = sandesha2_utils_get_property_bean_from_op(env, 
            axis2_msg_ctx_get_op(msg_ctx, env));*/
    
        svc = axis2_msg_ctx_get_svc(ack_msg_ctx, env);
        if(!svc)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                "[sandesha2][ack_req_msg_processor.c] service is NULL");
            return AXIS2_FAILURE;
        }

        prop_bean = sandesha2_utils_get_property_bean(env, svc);
        if(!prop_bean)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                "[sandesha2][ack_req_msg_processor.c] Property bean is NULL");
            return AXIS2_FAILURE;
        }

        /*prop_bean = sandesha2_utils_get_property_bean(env, 
            axis2_conf_ctx_get_conf(conf_ctx, env));*/
        prop_bean = sandesha2_utils_get_property_bean(env, svc);    
        ack_interval = sandesha2_property_bean_get_ack_interval(prop_bean, env);
        time_to_send = sandesha2_utils_get_current_time_in_millis(env) +
            ack_interval;
                        
        find_bean = sandesha2_sender_bean_create(env);
        sandesha2_sender_bean_set_resend(find_bean, env, AXIS2_FALSE);
        sandesha2_sender_bean_set_send(find_bean, env, AXIS2_TRUE);
        sandesha2_sender_bean_set_msg_type(find_bean, env, 
            SANDESHA2_MSG_TYPE_ACK);
                        
        found_list = sandesha2_sender_mgr_find_by_sender_bean(sender_mgr, env, 
            find_bean);
        if(find_bean)
            sandesha2_sender_bean_free(find_bean, env);
        if(found_list)
        {
            int i = 0;
            for(i = 0; i < axutil_array_list_size(found_list, env); i++)
            {
                axis2_char_t *msg_stored_key = NULL;
                sandesha2_sender_bean_t *old_ack_bean = NULL;
                old_ack_bean = axutil_array_list_get(found_list, env, i);
                time_to_send = sandesha2_sender_bean_get_time_to_send(
                    old_ack_bean, env);
                /*char *msg_id = sandesha2_sender_bean_get_msg_id(old_ack_bean, env);*/
                sandesha2_sender_mgr_remove(sender_mgr, env, 
                    sandesha2_sender_bean_get_msg_id(old_ack_bean, env));
                /* Removing the message from the storage */
                msg_stored_key = sandesha2_sender_bean_get_msg_ctx_ref_key(
                    old_ack_bean, env);
                sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, 
                    msg_stored_key, conf_ctx, -1);
            }
        }
        sandesha2_sender_bean_set_time_to_send(ack_bean, env, time_to_send); 
        /*axis2_msg_ctx_set_keep_alive(ack_msg_ctx, env, AXIS2_TRUE);*/
        sandesha2_storage_mgr_store_msg_ctx(storage_mgr, env, key, ack_msg_ctx, AXIS2_FALSE);
        sandesha2_sender_mgr_insert(sender_mgr, env, ack_bean);
        
        transport_out = axis2_msg_ctx_get_transport_out_desc(ack_msg_ctx, env);
        property = axutil_property_create_with_args(env, 0, 0,
            axis2_transport_out_desc_free_void_arg, transport_out);
        axis2_msg_ctx_set_property(ack_msg_ctx, env, 
            SANDESHA2_ORIGINAL_TRANSPORT_OUT_DESC, property);
        
        property = axutil_property_create_with_args(env, 0, 0, 0, 
            AXIS2_VALUE_TRUE);
        axis2_msg_ctx_set_property(ack_msg_ctx, env, 
            SANDESHA2_SET_SEND_TO_TRUE, property);
        
        property = axutil_property_create_with_args(env, 0, 0, 0, key);
        axis2_msg_ctx_set_property(ack_msg_ctx, env, 
            SANDESHA2_MESSAGE_STORE_KEY, property);
                        
        axis2_msg_ctx_set_transport_out_desc(ack_msg_ctx, env, 
            sandesha2_utils_get_transport_out(env));
        engine = axis2_engine_create(env, conf_ctx);
        if(AXIS2_FAILURE == axis2_engine_send(engine, env, ack_msg_ctx))
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                "[sandesha2]ack sending failed");
            AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SENDING_ACK, 
                AXIS2_FAILURE);
            if(engine)
                axis2_engine_free(engine, env);
            if(seq_prop_mgr)
                sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
            if(sender_mgr)
                sandesha2_sender_mgr_free(sender_mgr, env);
            if(storage_mgr)
                sandesha2_storage_mgr_free(storage_mgr, env);
            return AXIS2_FAILURE;
        }
        if(engine)
            axis2_engine_free(engine, env);
        sandesha2_utils_start_sender_for_seq(env, conf_ctx, seq_id, AXIS2_FALSE);
        axis2_msg_ctx_set_paused(msg_ctx, env, AXIS2_TRUE);
        if(sender_mgr)
            sandesha2_sender_mgr_free(sender_mgr, env);
    }
    if(seq_prop_mgr)
        sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
    if(storage_mgr)
        sandesha2_storage_mgr_free(storage_mgr, env);
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
        "[sandesha2]Exit:sandesha2_ack_req_msg_processor_process_in_msg");
    return AXIS2_SUCCESS;
}