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; }
static axis2_status_t AXIS2_CALL sandesha2_terminate_seq_msg_processor_add_terminate_seq_res( const axutil_env_t *env, sandesha2_msg_ctx_t *rm_msg_ctx, axis2_char_t *seq_id, sandesha2_seq_property_mgr_t *seq_prop_mgr) { axis2_msg_ctx_t *msg_ctx = NULL; axis2_msg_ctx_t *out_msg_ctx = NULL; sandesha2_msg_ctx_t *out_rm_msg = NULL; sandesha2_msg_ctx_t *ack_rm_msg = NULL; sandesha2_seq_ack_t *seq_ack = NULL; axutil_property_t *property = NULL; axis2_engine_t *engine = NULL; axis2_op_ctx_t *op_ctx = NULL; axis2_endpoint_ref_t *to_epr = NULL; /*axis2_transport_out_desc_t *orig_trans_out = NULL; axis2_transport_out_desc_t *trans_out = NULL; sandesha2_sender_bean_t *term_res_bean = NULL; axis2_char_t *key = NULL; sandesha2_sender_mgr_t *retrans_mgr = NULL;*/ AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, seq_id, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, seq_prop_mgr, AXIS2_FAILURE); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_terminate_seq_msg_processor_add_terminate_seq_res"); msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env); out_msg_ctx = sandesha2_utils_create_out_msg_ctx(env, msg_ctx); out_rm_msg = sandesha2_msg_creator_create_terminate_seq_res_msg(env, rm_msg_ctx, out_msg_ctx, seq_prop_mgr); if(!out_rm_msg) { return AXIS2_FAILURE; } ack_rm_msg = sandesha2_ack_mgr_generate_ack_msg(env, rm_msg_ctx, seq_id, seq_prop_mgr); if(ack_rm_msg) { seq_ack = sandesha2_msg_ctx_get_seq_ack(ack_rm_msg, env); sandesha2_msg_ctx_set_seq_ack(out_rm_msg, env, seq_ack); } sandesha2_msg_ctx_add_soap_envelope(out_rm_msg, env); sandesha2_msg_ctx_set_flow(out_rm_msg, env, AXIS2_OUT_FLOW); property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE); axis2_msg_ctx_set_property(out_msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, property); /* test code */ /* to_epr = axis2_msg_ctx_get_to(out_msg_ctx, env); if(to_epr && !sandesha2_utils_is_anon_uri(env, axis2_endpoint_ref_get_address(to_epr, env))) { axis2_msg_ctx_t *tsr_msg_ctx = axis2_core_utils_create_out_msg_ctx(env, msg_ctx); orig_trans_out = axis2_msg_ctx_get_transport_out_desc(tsr_msg_ctx, env); property = axutil_property_create_with_args(env, 0, 0, 0, orig_trans_out); axis2_msg_ctx_set_property(tsr_msg_ctx, env, SANDESHA2_ORIGINAL_TRANSPORT_OUT_DESC, property); trans_out = sandesha2_utils_get_transport_out(env); axis2_msg_ctx_set_transport_out_desc(tsr_msg_ctx, env, trans_out); key = axutil_uuid_gen(env); term_res_bean = sandesha2_sender_bean_create(env); sandesha2_sender_bean_set_msg_ctx_ref_key(term_res_bean, env, key); property = axutil_property_create_with_args(env, 0, 0, 0, key); axis2_msg_ctx_set_property(tsr_msg_ctx, env, SANDESHA2_MESSAGE_STORE_KEY, property); sandesha2_storage_mgr_store_msg_ctx(storage_mgr, env, key, tsr_msg_ctx); */ /* TODO: refine the terminate delay */ /* sandesha2_sender_bean_set_time_to_send(term_res_bean, env, sandesha2_utils_get_current_time_in_millis(env) + SANDESHA2_TERMINATE_DELAY); sandesha2_sender_bean_set_msg_id(term_res_bean, env, (axis2_char_t *) axis2_msg_ctx_get_msg_id(tsr_msg_ctx, env)); sandesha2_sender_bean_set_send(term_res_bean, 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_QUALIFIED_FOR_SENDING, property); sandesha2_sender_bean_set_resend(term_res_bean, env, AXIS2_FALSE); retrans_mgr = sandesha2_storage_mgr_get_retrans_mgr(storage_mgr, env); sandesha2_sender_mgr_insert(retrans_mgr, env, term_res_bean); }*/ /* end test code */ engine = axis2_engine_create(env, axis2_msg_ctx_get_conf_ctx(msg_ctx, env)); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]axis2_engine_send"); axis2_engine_send(engine, env, out_msg_ctx); op_ctx = axis2_msg_ctx_get_op_ctx(out_msg_ctx, env); if(to_epr) { if(sandesha2_utils_is_anon_uri(env, axis2_endpoint_ref_get_address(to_epr, env))) { axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_TRUE); } else { axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_FALSE); } } else { axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_TRUE); } if(engine) { axis2_engine_free(engine, env); } if(out_rm_msg) { sandesha2_msg_ctx_free(out_rm_msg, env); } AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Exit:sandesha2_terminate_seq_msg_processor_add_terminate_seq_res"); return AXIS2_SUCCESS; }
static axis2_status_t AXIS2_CALL sandesha2_create_seq_msg_processor_process_in_msg ( sandesha2_msg_processor_t *msg_processor, const axutil_env_t *env, sandesha2_msg_ctx_t *rm_msg_ctx) { axis2_msg_ctx_t *create_seq_msg_ctx = NULL; sandesha2_create_seq_t *create_seq_part = NULL; axis2_conf_ctx_t *conf_ctx = NULL; sandesha2_msg_ctx_t *fault_rm_msg_ctx = NULL; axis2_msg_ctx_t *out_msg_ctx = NULL; sandesha2_seq_property_mgr_t *seq_prop_mgr = NULL; sandesha2_next_msg_mgr_t *next_msg_mgr = NULL; axutil_property_t *property = NULL; axis2_char_t *incoming_sequence_id = NULL; sandesha2_msg_ctx_t *rm_create_seq_res_msg_ctx = NULL; sandesha2_create_seq_res_t *create_seq_res_part = NULL; sandesha2_seq_offer_t *seq_offer = NULL; axis2_endpoint_ref_t *acks_to_epr = NULL; sandesha2_acks_to_t *acks_to = NULL; sandesha2_seq_property_bean_t *acks_to_bean = NULL; sandesha2_seq_property_bean_t *acks_to_ref_param_bean = NULL; axutil_array_list_t *ref_param_list = NULL; axis2_char_t *ref_param_list_str = NULL; sandesha2_seq_property_bean_t *to_bean = NULL; axis2_engine_t *engine = NULL; axis2_char_t *addr_ns_uri = NULL; axis2_char_t *anon_uri = NULL; axis2_char_t *to_addr = NULL; axis2_op_ctx_t *op_ctx = NULL; axis2_char_t *dbname = NULL; sandesha2_create_seq_mgr_t *create_seq_mgr = NULL; axis2_msg_ctx_t **msg_ctx_map = NULL; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Start:sandesha2_create_seq_msg_processor_process_in_msg"); AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE); create_seq_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env); op_ctx = axis2_msg_ctx_get_op_ctx(create_seq_msg_ctx, env); msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env); msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN] = create_seq_msg_ctx; create_seq_part = sandesha2_msg_ctx_get_create_seq(rm_msg_ctx, env); if(!create_seq_part) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] create_seq_part is NULL"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING, AXIS2_FAILURE); return AXIS2_FAILURE; } conf_ctx = axis2_msg_ctx_get_conf_ctx(create_seq_msg_ctx, env); dbname = sandesha2_util_get_dbname(env, conf_ctx); seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname); create_seq_mgr = sandesha2_permanent_create_seq_mgr_create(env, dbname); next_msg_mgr = sandesha2_permanent_next_msg_mgr_create(env, dbname); /*fault_rm_msg_ctx = sandesha2_fault_mgr_check_for_create_seq_refused(env, rm_msg_ctx, seq_prop_mgr);*/ fault_rm_msg_ctx = sandesha2_fault_mgr_check_for_create_seq_refused(env, rm_msg_ctx, seq_prop_mgr); if(fault_rm_msg_ctx) { axis2_engine_t *engine = NULL; AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] A fault occurred"); engine = axis2_engine_create(env, conf_ctx); axis2_engine_send_fault(engine, env, sandesha2_msg_ctx_get_msg_ctx(fault_rm_msg_ctx, env)); if(fault_rm_msg_ctx) { sandesha2_msg_ctx_free(fault_rm_msg_ctx, env); } if(engine) { axis2_engine_free(engine, env); engine = NULL; } axis2_msg_ctx_set_paused(create_seq_msg_ctx, env, AXIS2_TRUE); 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(next_msg_mgr) { sandesha2_next_msg_mgr_free(next_msg_mgr, env); } return AXIS2_SUCCESS; } out_msg_ctx = sandesha2_utils_create_out_msg_ctx(env, create_seq_msg_ctx); incoming_sequence_id = sandesha2_seq_mgr_setup_new_incoming_sequence(env, rm_msg_ctx, seq_prop_mgr, next_msg_mgr); rm_create_seq_res_msg_ctx = sandesha2_msg_creator_create_create_seq_res_msg(env, rm_msg_ctx, out_msg_ctx, incoming_sequence_id, seq_prop_mgr); axis2_msg_ctx_set_flow(out_msg_ctx, env, AXIS2_OUT_FLOW); if(!rm_create_seq_res_msg_ctx) { if(incoming_sequence_id) { AXIS2_FREE(env->allocator, incoming_sequence_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(next_msg_mgr) { sandesha2_next_msg_mgr_free(next_msg_mgr, env); } return AXIS2_FAILURE; } property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE); /* For making sure that this won't be processed again */ sandesha2_msg_ctx_set_property(rm_create_seq_res_msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, property); create_seq_res_part = sandesha2_msg_ctx_get_create_seq_res(rm_create_seq_res_msg_ctx, env); seq_offer = sandesha2_create_seq_get_seq_offer(create_seq_part, env); /* Offer processing */ if(seq_offer) { sandesha2_accept_t *accept = NULL; axis2_char_t *outgoing_sequence_id = NULL; axis2_bool_t offer_accepted = AXIS2_FALSE; if(create_seq_res_part) { accept = sandesha2_create_seq_res_get_accept(create_seq_res_part, env); } if(!accept) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Accept part has not genereated for a message with offer"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING, AXIS2_FAILURE); if(rm_create_seq_res_msg_ctx) { sandesha2_msg_ctx_free(rm_create_seq_res_msg_ctx, env); } if(incoming_sequence_id) { AXIS2_FREE(env->allocator, incoming_sequence_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(next_msg_mgr) { sandesha2_next_msg_mgr_free(next_msg_mgr, env); } return AXIS2_FAILURE; } outgoing_sequence_id = sandesha2_identifier_get_identifier(sandesha2_seq_offer_get_identifier( seq_offer, env), env); /* Check whether offered sequence id is valid or create sequence bean already created */ offer_accepted = sandesha2_create_seq_msg_processor_offer_accepted(env, outgoing_sequence_id, rm_msg_ctx, create_seq_mgr); if(offer_accepted) { /*sandesha2_create_seq_bean_t *create_seq_bean = NULL;*/ axis2_char_t *outgoing_internal_sequence_id = NULL; sandesha2_seq_property_bean_t *outgoing_sequence_bean = NULL; sandesha2_seq_property_bean_t *outgoing_internal_sequence_bean = NULL; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Offer Accepted"); /* * If previously a create sequence message has arrived with an offer then there is * a create sequence bean already created in the database. Free it. Also free * outgoing_internal_sequence_bean, and outgoing_sequence_bean. */ sandesha2_create_seq_msg_processor_create_seq_msg_already_received(env, outgoing_sequence_id, rm_msg_ctx, create_seq_mgr, seq_prop_mgr); /* Note that outgoing_internal_sequence_id is derived from incoming_sequence_id. This * is server side. So it should be noted that in server side * incoming_internal_sequence_id and outgoing_internal_sequence_id are same */ outgoing_internal_sequence_id = sandesha2_utils_get_internal_sequence_id(env, incoming_sequence_id); /*create_seq_bean = sandesha2_create_seq_bean_create(env); sandesha2_create_seq_bean_set_outgoing_sequence_id(create_seq_bean, env, outgoing_sequence_id); sandesha2_create_seq_bean_set_internal_sequence_id(create_seq_bean, env, outgoing_internal_sequence_id); sandesha2_create_seq_bean_set_create_seq_msg_id(create_seq_bean, env, axutil_uuid_gen(env)); sandesha2_create_seq_mgr_insert(create_seq_mgr, env, create_seq_bean);*/ outgoing_sequence_bean = sandesha2_seq_property_bean_create(env); if(outgoing_sequence_bean) { sandesha2_seq_property_bean_set_name(outgoing_sequence_bean, env, SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_SEQUENCE_ID); sandesha2_seq_property_bean_set_seq_id(outgoing_sequence_bean, env, outgoing_internal_sequence_id); sandesha2_seq_property_bean_set_value(outgoing_sequence_bean, env, outgoing_sequence_id); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] incoming_sequence_id:%s", incoming_sequence_id); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, outgoing_sequence_bean); sandesha2_seq_property_bean_free(outgoing_sequence_bean, env); } outgoing_internal_sequence_bean = sandesha2_seq_property_bean_create(env); if(outgoing_internal_sequence_bean) { sandesha2_seq_property_bean_set_name(outgoing_internal_sequence_bean, env, SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_INTERNAL_SEQUENCE_ID); sandesha2_seq_property_bean_set_seq_id(outgoing_internal_sequence_bean, env, outgoing_sequence_id); sandesha2_seq_property_bean_set_value(outgoing_internal_sequence_bean, env, outgoing_internal_sequence_id); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, outgoing_internal_sequence_bean); sandesha2_seq_property_bean_free(outgoing_internal_sequence_bean, env); } if(outgoing_internal_sequence_id) { AXIS2_FREE(env->allocator, outgoing_internal_sequence_id); } } else { sandesha2_msg_ctx_add_soap_envelope(rm_create_seq_res_msg_ctx, env); } } acks_to = sandesha2_create_seq_get_acks_to(create_seq_part, env); acks_to_epr = sandesha2_address_get_epr(sandesha2_acks_to_get_address(acks_to, env), env); if(!acks_to_epr || !axis2_endpoint_ref_get_address(acks_to_epr, env)) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]Acks to is null"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_INVALID_EPR, AXIS2_FAILURE); if(rm_create_seq_res_msg_ctx) { sandesha2_msg_ctx_free(rm_create_seq_res_msg_ctx, env); } if(incoming_sequence_id) { AXIS2_FREE(env->allocator, incoming_sequence_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(next_msg_mgr) { sandesha2_next_msg_mgr_free(next_msg_mgr, env); } return AXIS2_FAILURE; } acks_to_bean = sandesha2_seq_property_bean_create_with_data(env, incoming_sequence_id, SANDESHA2_SEQ_PROP_ACKS_TO_EPR, (axis2_char_t*)axis2_endpoint_ref_get_address( acks_to_epr, env)); if(acks_to_bean) { sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, acks_to_bean); sandesha2_seq_property_bean_free(acks_to_bean, env); } ref_param_list = sandesha2_acks_to_get_ref_param_list(acks_to, env); if(ref_param_list) { ref_param_list_str = sandesha2_util_get_string_from_node_list(env, ref_param_list); acks_to_ref_param_bean = sandesha2_seq_property_bean_create_with_data(env, incoming_sequence_id, SANDESHA2_SEQ_PROP_ACKS_TO_REF_PARAM, ref_param_list_str); if(ref_param_list_str) { AXIS2_FREE(env->allocator, ref_param_list_str); } if(acks_to_ref_param_bean) { sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, acks_to_ref_param_bean); sandesha2_seq_property_bean_free(acks_to_ref_param_bean, env); } } axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_TRUE); sandesha2_seq_mgr_update_last_activated_time(env, incoming_sequence_id, seq_prop_mgr); engine = axis2_engine_create(env, conf_ctx); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]axis2_engine_send"); axis2_engine_send(engine, env, out_msg_ctx); if(engine) { axis2_engine_free(engine, env); } if(out_msg_ctx) { axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx); /*axis2_msg_ctx_reset_transport_out_stream(out_msg_ctx, env);*/ axis2_msg_ctx_free(out_msg_ctx, env); } if(rm_create_seq_res_msg_ctx) { sandesha2_msg_ctx_free(rm_create_seq_res_msg_ctx, env); } to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, incoming_sequence_id, SANDESHA2_SEQ_PROP_TO_EPR); if(!to_bean) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] wsa:To is not set"); if(incoming_sequence_id) { AXIS2_FREE(env->allocator, incoming_sequence_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(next_msg_mgr) { sandesha2_next_msg_mgr_free(next_msg_mgr, env); } return AXIS2_FAILURE; } to_addr = sandesha2_seq_property_bean_get_value(to_bean, env); addr_ns_uri = sandesha2_utils_get_seq_property(env, incoming_sequence_id, SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, seq_prop_mgr); anon_uri = sandesha2_spec_specific_consts_get_anon_uri(env, addr_ns_uri); if(addr_ns_uri) { AXIS2_FREE(env->allocator, addr_ns_uri); } if(sandesha2_utils_is_anon_uri(env, to_addr)) { axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_TRUE); } else { axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_FALSE); } sandesha2_seq_property_bean_free(to_bean, env); /* Pausing the flow here so that it won't go to a message receiver which is not set for this flow */ sandesha2_msg_ctx_set_paused(rm_msg_ctx, env, AXIS2_TRUE); if(incoming_sequence_id) { AXIS2_FREE(env->allocator, incoming_sequence_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(next_msg_mgr) { sandesha2_next_msg_mgr_free(next_msg_mgr, env); } AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Exit: sandesha2_create_seq_msg_processor_process_in_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; }