Ejemplo n.º 1
0
  static bool IsNeedReply(axis2_msg_ctx_t* pMsgCtx, const axutil_env_t* pEnv)
  {
    axis2_op* pAxis2Op = axis2_msg_ctx_get_op(pMsgCtx, pEnv);
    const axis2_char_t* szExchangePattern = axis2_op_get_msg_exchange_pattern(pAxis2Op, pEnv);

    return !(axutil_strcmp(szExchangePattern, AXIS2_MEP_URI_OUT_ONLY) == 0 ||
             axutil_strcmp(szExchangePattern, AXIS2_MEP_URI_ROBUST_OUT_ONLY) == 0);
  }
Ejemplo n.º 2
0
axis2_status_t AXIS2_CALL
axis2_statistics_admin_out_op_count_handler_invoke(struct axis2_handler *handler, 
                        const axutil_env_t *env,
                        struct axis2_msg_ctx *msg_ctx)
{
    axis2_status_t status = AXIS2_SUCCESS;
    service_admin_counter_t *counter = NULL;
    axutil_param_t *param = NULL;
    axis2_op_t *op = NULL;
    axis2_svc_t *svc = NULL;
    const axis2_char_t *svc_name = NULL;
    
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[adminservices] Start:axis2_statistics_admin_out_op_count_handler_invoke");
    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);

    svc = axis2_msg_ctx_get_svc(msg_ctx, env);
    if(svc)
    {
        svc_name = axis2_svc_get_name(svc, env);
    }
    op = axis2_msg_ctx_get_op(msg_ctx, env);
    if(op)
    {
        param = axis2_op_get_param(op, env, AXIS2_OUT_OPERATION_COUNTER);
        if(param)
        {
            counter = axutil_param_get_value(param, env);
            if(counter)
            {
                service_admin_counter_increment(counter, env, msg_ctx);
            }
        }
        else
        {
            axis2_char_t *op_name = NULL;

            op_name = axutil_qname_get_localpart(axis2_op_get_qname(op, env), env);
            axutil_allocator_switch_to_global_pool(env->allocator);
            counter = service_admin_counter_create(env, svc_name, op_name);
            if(counter)
            {
                service_admin_counter_increment(counter, env, msg_ctx);
                param = axutil_param_create(env, AXIS2_OUT_OPERATION_COUNTER, counter);
                if(param)
                {
                    axis2_op_add_param(op, env, param);
                }
            }
            axutil_allocator_switch_to_local_pool(env->allocator);
        }
    }
    
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[adminservices] End:axis2_statistics_admin_out_op_count_handler_invoke");
    
    return status;
}
Ejemplo n.º 3
0
/*
 * This method invokes the right service method 
 */
axiom_node_t* AXIS2_CALL
rm_sample_svc_invoke(
    axis2_svc_skeleton_t *svc_skeleton,
    const axutil_env_t *env,
    axiom_node_t *node,
    axis2_msg_ctx_t *msg_ctx)
{
    axis2_op_t *op = NULL;
    axutil_qname_t *op_qname = NULL;
    axis2_char_t *op_name = NULL;
    
    op = axis2_msg_ctx_get_op(msg_ctx, env);
    if(op)
    {
        op_qname = (axutil_qname_t *)axis2_op_get_qname(op, env);
        if(op_qname)
        {
            op_name = axutil_qname_get_localpart(op_qname, env);
        }

        if(op_name)
        {
			axis2_endpoint_ref_t* to_epr = NULL;
            to_epr = axis2_msg_ctx_get_to(msg_ctx, env);

            if (to_epr)
            {
                const axis2_char_t* to_address = NULL;
                to_address = axis2_endpoint_ref_get_address(to_epr, env);

                if (to_address && strstr(to_address, AXIS2_ANON_SERVICE))
                {
                    axis2_msg_ctx_set_wsa_action(msg_ctx, env, AXIS2_ANON_OUT_IN_OP);
                }
            }

			if (!axutil_strcmp(op_name, "echoString"))
            {
                return rm_sample_svc_echo(env, node);
            }
            if (!axutil_strcmp(op_name, "ping"))
            {
                rm_sample_svc_ping(env, node);
                return NULL;
            }
            if (!axutil_strcmp(op_name, "mtomSample"))
            {
                return rm_sample_svc_mtom(env, node, msg_ctx);
            }
        }
    }

    return NULL;
}
Ejemplo n.º 4
0
/*
 * This method invokes the right service method 
 */
axiom_node_t* AXIS2_CALL
savan_subs_mgr_svc_invoke(
    axis2_svc_skeleton_t *svc_skeleton,
    const axutil_env_t *env,
    axiom_node_t *node,
    axis2_msg_ctx_t *msg_ctx)
{
    /* Invoke the business logic.
     * Depending on the function name invoke the correct impl method.
     */
    axis2_op_t *op = NULL;
    axutil_qname_t *op_qname = NULL;
    axis2_char_t *op_name = NULL;
    
    op = axis2_msg_ctx_get_op(msg_ctx, env);
    if(op)
    {
        op_qname = (axutil_qname_t *)axis2_op_get_qname(op, env);
        if(op_qname)
            op_name = axutil_qname_get_localpart(op_qname, env);
        if(op_name)
        {
            if (axutil_strcmp(op_name, "add_subscriber") == 0)
                return savan_subs_mgr_svc_add_subscriber(env, node, msg_ctx);
            if (axutil_strcmp(op_name, "remove_subscriber") == 0)
                return savan_subs_mgr_svc_remove_subscriber(env, node, msg_ctx);
            if (axutil_strcmp(op_name, "get_subscriber") == 0)
                return savan_subs_mgr_svc_get_subscriber(env, node, msg_ctx);
            if (axutil_strcmp(op_name, "get_subscriber_list") == 0)
                return savan_subs_mgr_svc_get_subscriber_list(env, node, msg_ctx);
            if (axutil_strcmp(op_name, "get_topic_list") == 0)
                return savan_subs_mgr_svc_get_topic_list(env, node, msg_ctx);
            /*if (axutil_strcmp(op_name, "add_topic") == 0)
                return savan_subs_mgr_svc_add_topic(env, node, msg_ctx);*/
        }
    }
    return NULL;
}
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
0
/**
 * Create a new create_seq_msg
 * @param env
 * @param application_rm_msg
 * @param internal_seq_id
 * @param acks_to
 * @param seq_prop_mgr
 * @return sandesha2_msg_ctx_t
 */
sandesha2_msg_ctx_t *AXIS2_CALL
sandesha2_msg_creator_create_create_seq_msg(
    const axutil_env_t *env,
    sandesha2_msg_ctx_t *application_rm_msg, 
    axis2_char_t *internal_seq_id,
    axis2_char_t *acks_to,
    sandesha2_seq_property_mgr_t *seq_prop_mgr)
{
    axis2_msg_ctx_t *application_msg_ctx = NULL;
    axis2_msg_ctx_t *create_seq_msg_ctx = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_op_t *app_msg_op_desc = NULL;
    axis2_op_ctx_t *op_ctx = NULL;
    axis2_char_t *create_seq_msg_id = NULL;
    axis2_char_t *rm_version = NULL;
    axis2_char_t *rm_ns_value = NULL;
    axis2_char_t *addressing_ns_value = NULL;
    axis2_char_t *anonymous_uri = NULL;
    axis2_char_t *temp_value = NULL;
    axis2_char_t *temp_action = NULL;
    axutil_string_t *temp_soap_action = NULL;
    axis2_endpoint_ref_t *to_epr = NULL;
    axis2_endpoint_ref_t *temp_to = NULL;
    axis2_endpoint_ref_t *acks_to_epr = NULL;
    axis2_endpoint_ref_t *temp_reply_to = NULL;
    sandesha2_create_seq_t *create_seq_part = NULL;
    sandesha2_seq_property_bean_t *reply_to_bean = NULL;
    sandesha2_seq_property_bean_t *to_bean = NULL;
    sandesha2_msg_ctx_t *create_seq_rm_msg = NULL;
    sandesha2_address_t *temp_address = NULL;
    sandesha2_acks_to_t *temp_acks_to = NULL;
    axutil_property_t *property = NULL;
    const axis2_char_t *reply_to_address = NULL;

    application_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(application_rm_msg, env);
    if(!application_msg_ctx)
    {
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_APPLICATION_MSG_NULL, AXIS2_FAILURE);
        return NULL;
    }

    conf_ctx = axis2_msg_ctx_get_conf_ctx(application_msg_ctx, env);
    if(!conf_ctx)
    {
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CONF_CTX_NULL, AXIS2_FAILURE);
        return NULL;
    }

    /* Creating by copying common contents.
     */
    create_seq_msg_ctx = sandesha2_utils_create_new_related_msg_ctx(env, application_rm_msg);

    sandesha2_msg_creator_init_creation(env, application_msg_ctx, create_seq_msg_ctx);

    create_seq_msg_id = axutil_uuid_gen(env);
    axis2_msg_ctx_set_message_id(create_seq_msg_ctx, env, create_seq_msg_id);
    AXIS2_FREE(env->allocator, create_seq_msg_id);

    app_msg_op_desc = axis2_msg_ctx_get_op(application_msg_ctx, env);

    property = axis2_msg_ctx_get_property(application_msg_ctx, env, AXIS2_TARGET_EPR);
    if(property)
    {
        temp_to = axutil_property_get_value(property, env);
        to_epr = axis2_endpoint_ref_create(env, axis2_endpoint_ref_get_address(temp_to, env));
    }

    if (!to_epr)
    {
        temp_to = sandesha2_msg_ctx_get_to(application_rm_msg, env); 
        if (temp_to)
        {
            to_epr = axis2_endpoint_ref_create(env, axis2_endpoint_ref_get_address(temp_to, env));
        }
    }

    if (to_epr)
    {
        axis2_msg_ctx_set_to(create_seq_msg_ctx, env, to_epr);
        to_epr = NULL;
    }
    
    temp_reply_to = sandesha2_msg_ctx_get_reply_to(application_rm_msg, env); 
    if(temp_reply_to)
    {
        axis2_endpoint_ref_t *reply_to_epr = NULL;

        reply_to_address = axis2_endpoint_ref_get_address(temp_reply_to, env);
        reply_to_epr = axis2_endpoint_ref_create(env, reply_to_address);
        if(reply_to_epr)
        {
            axis2_msg_ctx_set_reply_to(create_seq_msg_ctx, env, reply_to_epr);
        }
    }

    create_seq_rm_msg = sandesha2_msg_ctx_create(env, create_seq_msg_ctx);

        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "create_seq_internal_seq_id:%s", internal_seq_id);
    rm_version = sandesha2_utils_get_rm_version(env, application_msg_ctx);

    if(!rm_version)
    {
        AXIS2_ERROR_SET(env->error, 
                SANDESHA2_ERROR_CANNOT_FIND_RM_VERSION_OF_GIVEN_MSG, AXIS2_FAILURE);
        return NULL;
    }

    rm_ns_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, rm_version);

    addressing_ns_value = sandesha2_utils_get_seq_property(env, internal_seq_id, 
        SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, seq_prop_mgr);

    create_seq_part = sandesha2_create_seq_create(env, addressing_ns_value, rm_ns_value);
    if(!create_seq_part)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] creating create sequence message failed");
        return NULL;
    }

    /* Adding sequence offer if present */
    op_ctx = axis2_msg_ctx_get_op_ctx(application_msg_ctx, env);
    if(op_ctx)
    {
        axis2_op_t *operation = NULL;
        int mep = -1;
        axis2_char_t *offered_seq_id = NULL;
        /*axutil_property_t *property = NULL;
        axis2_ctx_t *ctx = NULL;

        ctx = axis2_msg_ctx_get_base(application_msg_ctx, env);
        property = axis2_ctx_get_property(ctx, env, SANDESHA2_CLIENT_OFFERED_SEQ_ID);
        if(property)
        {
            offered_seq_id = axutil_property_get_value(property, env);
        }*/
        operation = axis2_op_ctx_get_op(op_ctx, env);
        mep = axis2_op_get_axis_specific_mep_const(operation, env);
        if(mep == AXIS2_MEP_CONSTANT_OUT_IN)
        {
            offered_seq_id = axutil_uuid_gen(env);
        }

        /*if(offered_seq_id && 0 != axutil_strcmp("", offered_seq_id))*/
        if(offered_seq_id)
        {
            sandesha2_seq_offer_t *offer_part = NULL;
            sandesha2_identifier_t *identifier = NULL;
            sandesha2_endpoint_t *endpoint = NULL;

            offer_part = sandesha2_seq_offer_create(env, rm_ns_value, addressing_ns_value);
            identifier = sandesha2_identifier_create(env, rm_ns_value);
            sandesha2_identifier_set_identifier(identifier, env, offered_seq_id);
            sandesha2_seq_offer_set_identifier(offer_part, env, identifier);

            if(!axutil_strcmp(SANDESHA2_SPEC_VERSION_1_1, rm_version))
            {
                axis2_endpoint_ref_t *reply_to_epr = NULL;
                sandesha2_address_t *address = NULL;

                reply_to_epr = axis2_endpoint_ref_create(env, reply_to_address);
                address = sandesha2_address_create(env, addressing_ns_value, reply_to_epr);
                endpoint = sandesha2_endpoint_create(env, address, rm_ns_value, 
                        addressing_ns_value);

                sandesha2_seq_offer_set_endpoint(offer_part, env, endpoint);
            }

            sandesha2_create_seq_set_seq_offer(create_seq_part, env, offer_part);
        }
    }

    reply_to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_seq_id, 
            SANDESHA2_SEQ_PROP_REPLY_TO_EPR);

    to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_seq_id, 
            SANDESHA2_SEQ_PROP_TO_EPR);
    if (to_bean)
    {
        temp_value = sandesha2_seq_property_bean_get_value(to_bean, env);
    
        if (temp_value)
        {
            to_epr = axis2_endpoint_ref_create(env, temp_value);
        }

        sandesha2_seq_property_bean_free(to_bean, env);
    }

    anonymous_uri = sandesha2_spec_specific_consts_get_anon_uri(env, addressing_ns_value);
    if(reply_to_bean)
    {
        axis2_endpoint_ref_t *reply_to_epr = NULL;

        temp_value = sandesha2_seq_property_bean_get_value(reply_to_bean, env);
        if(temp_value)
        {
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "dam_reply_to:%s", temp_value);
            reply_to_epr = axis2_endpoint_ref_create(env, temp_value);
            acks_to = axutil_strdup(env, temp_value);
        }

        if(reply_to_epr)
        {
            sandesha2_msg_ctx_set_reply_to(create_seq_rm_msg, env, reply_to_epr);
        }
        
        sandesha2_seq_property_bean_free(reply_to_bean, env);
    }
    
    if(!acks_to || !axutil_strcmp("", acks_to))
    {
        acks_to = axutil_strdup(env, anonymous_uri);
    }

    acks_to_epr = axis2_endpoint_ref_create(env, acks_to);

    temp_to = sandesha2_msg_ctx_get_to(create_seq_rm_msg, env);
    if(!temp_to && to_epr)
    {
        sandesha2_msg_ctx_set_to(create_seq_rm_msg, env, to_epr);
    }
    else
    {
        axis2_endpoint_ref_free(to_epr, env);
    }


    temp_address = sandesha2_address_create(env, addressing_ns_value, acks_to_epr);
    temp_acks_to = sandesha2_acks_to_create(env, temp_address, rm_ns_value, addressing_ns_value);

    if(addressing_ns_value)
    {
        AXIS2_FREE(env->allocator, addressing_ns_value);
    }

    sandesha2_create_seq_set_acks_to(create_seq_part, env,  temp_acks_to);
    sandesha2_msg_ctx_set_create_seq(create_seq_rm_msg, env, create_seq_part);
    sandesha2_msg_ctx_add_soap_envelope(create_seq_rm_msg, env);
    temp_action = sandesha2_spec_specific_consts_get_create_seq_action(env, rm_version);

    sandesha2_msg_ctx_set_wsa_action(create_seq_rm_msg, env, temp_action);

    temp_soap_action = axutil_string_create(env, temp_action);
    if(temp_soap_action)
    {
        sandesha2_msg_ctx_set_soap_action(create_seq_rm_msg, env, temp_soap_action);
        axutil_string_free(temp_soap_action, env);
    }

    /*sandesha2_msg_creator_finalize_creation(env, application_msg_ctx, create_seq_msg_ctx);*/

    return create_seq_rm_msg;
}
/**
 * This function is invoked in RM 1.1 where client explicitly send the
 * terminate sequence message
 */
static axis2_status_t AXIS2_CALL
sandesha2_terminate_seq_msg_processor_process_out_msg(
    sandesha2_msg_processor_t *msg_processor,
    const axutil_env_t *env,
    sandesha2_msg_ctx_t *rm_msg_ctx)
{
    axis2_msg_ctx_t *msg_ctx = 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_create_seq_mgr_t *create_seq_mgr = NULL;
    sandesha2_sender_mgr_t *sender_mgr = NULL;
    axis2_char_t *to_address = NULL;
    axis2_char_t *seq_key = NULL;
    axis2_char_t *int_seq_id = NULL;
    axis2_char_t *out_seq_id = NULL;
    axutil_property_t *property = NULL;
    axis2_char_t *terminated = NULL;
    axis2_op_t *old_op = NULL;
    axis2_op_t *out_in_op = NULL;
    axutil_qname_t *qname = NULL;
    sandesha2_terminate_seq_t *term_seq_part = NULL;
    axis2_char_t *rm_version = NULL;
    axis2_char_t *transport_to = NULL;
    sandesha2_seq_property_bean_t *term_added = NULL;
    axis2_char_t *temp_action = NULL;
    axutil_string_t *soap_action = NULL;
    axis2_char_t *dbname = NULL;

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

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
                    "[sandesha2]Entry:sandesha2_terminate_seq_msg_processor_process_out_msg.");

    msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, 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);
    create_seq_mgr = sandesha2_permanent_create_seq_mgr_create(env, dbname);
    sender_mgr = sandesha2_permanent_sender_mgr_create(env, dbname);
    to_address = (axis2_char_t*)axis2_endpoint_ref_get_address(axis2_msg_ctx_get_to(msg_ctx, env),
                 env);

    property = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_CLIENT_SEQ_KEY);
    if(property)
    {
        seq_key = axutil_property_get_value(property, env);
    }

    int_seq_id = sandesha2_utils_get_client_internal_sequence_id(env, to_address, seq_key);
    out_seq_id = sandesha2_utils_get_seq_property(env, int_seq_id,
                 SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_SEQUENCE_ID, seq_prop_mgr);

    if(!out_seq_id)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "[sandesha2]seq_id was not found. Cannot send the terminate message");

        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_SEQ_ID, AXIS2_FAILURE);
        if(seq_prop_mgr)
        {
            sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
        }

        if(create_seq_mgr)
        {
            sandesha2_create_seq_mgr_free(create_seq_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;
    }

    terminated = sandesha2_utils_get_seq_property(env, int_seq_id,
                 SANDESHA2_SEQ_PROP_TERMINATE_ADDED, seq_prop_mgr);
    old_op = axis2_msg_ctx_get_op(msg_ctx, env);

    qname = axutil_qname_create(env, "temp", NULL, NULL);
    out_in_op = axis2_op_create_with_qname(env, qname);
    if(qname)
    {
        axutil_qname_free(qname, env);
    }

    axis2_op_set_msg_exchange_pattern(out_in_op, env, AXIS2_MEP_URI_OUT_IN);
    axis2_op_set_in_flow(out_in_op, env, axis2_op_get_in_flow(old_op, env));

    if(terminated && !axutil_strcmp(terminated, AXIS2_VALUE_TRUE))
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Terminate was added previously");
        if(terminated)
        {
            AXIS2_FREE(env->allocator, terminated);
        }

        if(out_seq_id)
        {
            AXIS2_FREE(env->allocator, out_seq_id);
        }

        if(seq_prop_mgr)
        {
            sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
        }

        if(create_seq_mgr)
        {
            sandesha2_create_seq_mgr_free(create_seq_mgr, env);
        }

        if(sender_mgr)
        {
            sandesha2_sender_mgr_free(sender_mgr, env);
        }

        if(storage_mgr)
        {
            sandesha2_storage_mgr_free(storage_mgr, env);
        }

        return AXIS2_SUCCESS;
    }

    if(terminated)
    {
        AXIS2_FREE(env->allocator, terminated);
    }

    term_seq_part = sandesha2_msg_ctx_get_terminate_seq(rm_msg_ctx, env);
    sandesha2_identifier_set_identifier(sandesha2_terminate_seq_get_identifier(term_seq_part, env),
                                        env, out_seq_id);

    sandesha2_msg_ctx_set_flow(rm_msg_ctx, env, AXIS2_OUT_FLOW);
    property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
    axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, property);
    axis2_msg_ctx_set_to(msg_ctx, env, axis2_endpoint_ref_create(env, to_address));
    rm_version = sandesha2_utils_get_rm_version(env, msg_ctx);
    if(!rm_version)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "[sandesha2] Cant find the rm_version of the given message");

        if(out_seq_id)
        {
            AXIS2_FREE(env->allocator, out_seq_id);
        }

        if(seq_prop_mgr)
        {
            sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
        }

        if(create_seq_mgr)
        {
            sandesha2_create_seq_mgr_free(create_seq_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;
    }

    axis2_msg_ctx_set_wsa_action(msg_ctx, env,
                                 sandesha2_spec_specific_consts_get_terminate_seq_action(env, rm_version));

    temp_action = sandesha2_spec_specific_consts_get_terminate_seq_soap_action(env, rm_version);

    soap_action = axutil_string_create(env, temp_action);
    axis2_msg_ctx_set_soap_action(msg_ctx, env, soap_action);
    transport_to = sandesha2_utils_get_seq_property(env, int_seq_id,
                   SANDESHA2_SEQ_PROP_TRANSPORT_TO, seq_prop_mgr);

    if(transport_to)
    {
        axis2_msg_ctx_set_transport_url(msg_ctx, env, transport_to);
        AXIS2_FREE(env->allocator, transport_to);
    }

    if(!sandesha2_util_is_ack_already_piggybacked(env, rm_msg_ctx))
    {
        sandesha2_ack_mgr_piggyback_acks_if_present(env, out_seq_id, rm_msg_ctx, storage_mgr,
                seq_prop_mgr, sender_mgr);
    }

    term_added = sandesha2_seq_property_bean_create(env);
    sandesha2_seq_property_bean_set_name(term_added, env, SANDESHA2_SEQ_PROP_TERMINATE_ADDED);
    sandesha2_seq_property_bean_set_seq_id(term_added, env, int_seq_id);
    if(out_seq_id)
    {
        AXIS2_FREE(env->allocator, out_seq_id);
    }

    sandesha2_seq_property_bean_set_value(term_added, env, AXIS2_VALUE_TRUE);
    sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, term_added);

    if(seq_prop_mgr)
    {
        sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
    }

    if(create_seq_mgr)
    {
        sandesha2_create_seq_mgr_free(create_seq_mgr, env);
    }

    if(sender_mgr)
    {
        sandesha2_sender_mgr_free(sender_mgr, env);
    }

    if(storage_mgr)
    {
        sandesha2_storage_mgr_free(storage_mgr, env);
    }

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
                    "[sandesha2] Exit:sandesha2_terminate_seq_msg_processor_process_out_msg");

    return AXIS2_SUCCESS;
}
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;
}