axis2_status_t AXIS2_CALL sandesha2_out_handler_invoke( struct axis2_handler *handler, const axutil_env_t *env, struct axis2_msg_ctx *msg_ctx) { axutil_property_t *temp_prop = NULL; axis2_conf_ctx_t *conf_ctx = NULL; axis2_conf_t *conf = NULL; axis2_char_t *str_done = NULL; axis2_char_t *dummy_msg_str = NULL; axis2_bool_t dummy_msg = AXIS2_FALSE; axis2_svc_t *svc = NULL; axutil_qname_t *module_qname = NULL; sandesha2_msg_ctx_t *rm_msg_ctx = NULL; sandesha2_msg_processor_t *msg_processor = NULL; int msg_type = -1; AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_out_handler_invoke"); temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_SEQ_PROP_MAKE_CONNECTION_OUT_PATH); if (temp_prop) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] In make connection out path. So return here."); return AXIS2_SUCCESS; temp_prop = NULL; } if(sandesha2_util_is_rstr_msg(env, msg_ctx)) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] A RSTR message. Sandesha don't process."); return AXIS2_SUCCESS; } conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); if(!conf_ctx) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Configuration Context is NULL"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CONF_CTX_NULL, AXIS2_FAILURE); return AXIS2_FAILURE; } svc = axis2_msg_ctx_get_svc(msg_ctx, env); if(!svc) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]Axis2 Service is NULL"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SVC_NULL, AXIS2_FAILURE); return AXIS2_FAILURE; } module_qname = axutil_qname_create(env, SANDESHA2_MODULE, NULL, NULL); if(!axis2_svc_is_module_engaged(svc, env, module_qname)) { if(module_qname) { axutil_qname_free(module_qname, env); } AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]RM is not engaged. So return here"); return AXIS2_SUCCESS; } if(module_qname) { axutil_qname_free(module_qname, env); } temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE); if(temp_prop) { str_done = (axis2_char_t *) axutil_property_get_value(temp_prop, env); } if(str_done && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, str_done)) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]Application Processing Done. So return here."); return AXIS2_SUCCESS; } temp_prop = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE); axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, temp_prop); conf = axis2_conf_ctx_get_conf(conf_ctx, env); if(!sandesha2_permanent_storage_mgr_create_db(env, conf_ctx)) { return AXIS2_FAILURE; } /* Getting rm message */ rm_msg_ctx = sandesha2_msg_init_init_msg(env, msg_ctx); temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_CLIENT_DUMMY_MESSAGE); if(NULL != temp_prop) { dummy_msg_str = (axis2_char_t *) axutil_property_get_value(temp_prop, env); } if(dummy_msg_str && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, dummy_msg_str)) { dummy_msg = AXIS2_TRUE; } temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_SVC_CLIENT_CLOSED); if(temp_prop) { axis2_char_t *spec_version = NULL; axis2_endpoint_ref_t *reply_to = axis2_msg_ctx_get_reply_to(msg_ctx, env); if(reply_to) { axis2_char_t *address = axis2_endpoint_ref_get_address(reply_to, env); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "dam_reply_to_address:%s", address); } spec_version = sandesha2_utils_get_rm_version(env, msg_ctx); if(!axutil_strcmp(SANDESHA2_SPEC_VERSION_1_1, spec_version)) { axis2_char_t *action = NULL; axutil_string_t *str_action = NULL; action = sandesha2_spec_specific_consts_get_terminate_seq_action(env, spec_version); str_action = axutil_string_create(env, action); axis2_msg_ctx_set_soap_action(msg_ctx, env, str_action); axutil_string_free(str_action, env); /*axis2_msg_ctx_set_reply_to(msg_ctx, env, NULL);*/ msg_type = sandesha2_msg_ctx_set_msg_type(rm_msg_ctx, env, SANDESHA2_MSG_TYPE_CLOSE_SEQ); } else if(!axutil_strcmp(SANDESHA2_SPEC_VERSION_1_0, spec_version)) { axutil_property_t *property = NULL; axutil_string_t *str_action = NULL; /*axis2_msg_info_headers_set_action(axis2_msg_ctx_get_msg_info_headers(msg_ctx, env), * env, SANDESHA2_SPEC_2005_02_SOAP_ACTION_LAST_MESSAGE); */ str_action = axutil_string_create(env, SANDESHA2_SPEC_2005_02_SOAP_ACTION_LAST_MESSAGE); axis2_msg_ctx_set_soap_action(msg_ctx, env, str_action); axutil_string_free(str_action, env); property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE); axis2_msg_ctx_set_property(msg_ctx, env, "Sandesha2LastMessage", property); /*axis2_msg_ctx_set_reply_to(msg_ctx, env, NULL);*/ } } msg_type = sandesha2_msg_ctx_get_msg_type(rm_msg_ctx, env); if(msg_type == SANDESHA2_MSG_TYPE_UNKNOWN) { axis2_msg_ctx_t *req_msg_ctx = NULL; axis2_op_ctx_t *op_ctx = NULL; op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env); req_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN); if(req_msg_ctx) /* For the server side */ { sandesha2_msg_ctx_t *req_rm_msg_ctx = NULL; sandesha2_seq_t *seq_part = NULL; req_rm_msg_ctx = sandesha2_msg_init_init_msg(env, req_msg_ctx); seq_part = sandesha2_msg_ctx_get_sequence(req_rm_msg_ctx, env); if(seq_part) { msg_processor = (sandesha2_msg_processor_t *) sandesha2_app_msg_processor_create(env); /* rm intended msg */ } if(req_rm_msg_ctx) sandesha2_msg_ctx_free(req_rm_msg_ctx, env); } else if(!axis2_msg_ctx_get_server_side(msg_ctx, env)) { msg_processor = (sandesha2_msg_processor_t *) sandesha2_app_msg_processor_create(env); } } else { msg_processor = sandesha2_msg_processor_create_msg_processor(env, rm_msg_ctx); } if(msg_processor) { sandesha2_msg_processor_process_out_msg(msg_processor, env, rm_msg_ctx); sandesha2_msg_processor_free(msg_processor, env); } if(AXIS2_SUCCESS != AXIS2_ERROR_GET_STATUS_CODE(env->error)) { /* Message should not be sent in an exception situation */ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Pausing message context"); axis2_msg_ctx_set_paused(msg_ctx, env, AXIS2_TRUE); if(rm_msg_ctx) { sandesha2_msg_ctx_free(rm_msg_ctx, env); } AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Error in processing the message"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_PROCESS_MSG, AXIS2_FAILURE); return AXIS2_FAILURE; } temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE); if(temp_prop) { axutil_property_set_value(temp_prop, env, AXIS2_VALUE_FALSE); } if(rm_msg_ctx) { sandesha2_msg_ctx_free(rm_msg_ctx, env); } AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Exit:sandesha2_out_handler_invoke"); return AXIS2_SUCCESS; }
/** * 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; }