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; }
/** * Create a new create_terminate_seq_msg * @param env * @param ref_rm_msg * @param seq_id * @param internal_seq_id * @param seq_prop_mgr * @return */ sandesha2_msg_ctx_t *AXIS2_CALL sandesha2_msg_creator_create_terminate_seq_msg( const axutil_env_t *env, sandesha2_msg_ctx_t *ref_rm_msg, axis2_char_t *seq_id, axis2_char_t *internal_seq_id, sandesha2_seq_property_mgr_t *seq_prop_mgr) { axis2_msg_ctx_t *ref_msg_ctx = NULL; axis2_msg_ctx_t *terminate_seq_msg_ctx = NULL; axis2_conf_ctx_t *conf_ctx = NULL; axis2_char_t *terminate_seq_msg_id = NULL; axis2_char_t *temp_msg_id = NULL; axis2_char_t *rm_version = NULL; axis2_char_t *rm_ns_value = NULL; axis2_bool_t is_seq_res_reqd = AXIS2_FALSE; axiom_soap_envelope_t *temp_envelope = NULL; sandesha2_msg_ctx_t *terminate_rm_msg = NULL; sandesha2_terminate_seq_t *terminate_seq = NULL; int soap_version = -1; sandesha2_identifier_t *identifier = NULL; sandesha2_last_msg_number_t *last_msg_number = NULL; sandesha2_seq_property_bean_t *last_out_msg_no_bean = NULL; ref_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(ref_rm_msg, env); /*axis2_msg_ctx_set_keep_alive(ref_msg_ctx, env, AXIS2_TRUE);*/ if(!ref_msg_ctx) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_NULL_MSG_CTX, AXIS2_FAILURE); return NULL; } conf_ctx = axis2_msg_ctx_get_conf_ctx(ref_msg_ctx, env); if(!conf_ctx) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CONF_CTX_NULL, AXIS2_FAILURE); return NULL; } terminate_seq_msg_ctx = sandesha2_utils_create_new_related_msg_ctx(env, ref_rm_msg); terminate_seq_msg_id = (axis2_char_t*)axis2_msg_ctx_get_msg_id( terminate_seq_msg_ctx, env); rm_version = sandesha2_utils_get_rm_version(env, ref_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); sandesha2_msg_creator_init_creation(env, ref_msg_ctx, terminate_seq_msg_ctx); is_seq_res_reqd = sandesha2_spec_specific_consts_is_term_seq_res_reqd(env, rm_version); if(!is_seq_res_reqd) { axis2_msg_ctx_set_property(terminate_seq_msg_ctx, env, AXIS2_TRANSPORT_IN, NULL); } terminate_rm_msg = sandesha2_msg_init_init_msg(env, terminate_seq_msg_ctx); if(!terminate_rm_msg) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_NULL_MSG_CTX, AXIS2_FAILURE); return NULL; } temp_msg_id = axutil_uuid_gen(env); axis2_msg_ctx_set_message_id(terminate_seq_msg_ctx, env, temp_msg_id); AXIS2_FREE(env->allocator, temp_msg_id); temp_envelope = sandesha2_msg_ctx_get_soap_envelope(ref_rm_msg, env); soap_version = sandesha2_utils_get_soap_version(env, temp_envelope); terminate_seq = sandesha2_terminate_seq_create(env, rm_ns_value); identifier = sandesha2_identifier_create(env, rm_ns_value); sandesha2_identifier_set_identifier(identifier, env, seq_id); sandesha2_terminate_seq_set_identifier(terminate_seq, env, identifier); sandesha2_msg_ctx_set_terminate_seq(terminate_rm_msg, env, terminate_seq); if(is_seq_res_reqd) { last_out_msg_no_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_seq_id, SANDESHA2_SEQ_PROP_LAST_OUT_MESSAGE_NUMBER); } if(last_out_msg_no_bean) { axis2_char_t *msg_no_str = NULL; long last_msg_num = -1; msg_no_str = sandesha2_seq_property_bean_get_value(last_out_msg_no_bean, env); if(msg_no_str) { last_msg_num = atol(msg_no_str); } last_msg_number = sandesha2_last_msg_number_create(env, rm_ns_value); if(last_msg_number) { sandesha2_last_msg_number_set_last_msg_number(last_msg_number, env, last_msg_num); sandesha2_terminate_seq_set_last_msg_number(terminate_seq, env, last_msg_number); } sandesha2_seq_property_bean_free(last_out_msg_no_bean, env); } sandesha2_msg_creator_finalize_creation(env, ref_msg_ctx, terminate_seq_msg_ctx); axis2_msg_ctx_set_property(terminate_seq_msg_ctx, env, AXIS2_TRANSPORT_IN, NULL); return terminate_rm_msg; }
sandesha2_msg_ctx_t *AXIS2_CALL sandesha2_msg_creator_create_make_connection_msg( const axutil_env_t *env, sandesha2_msg_ctx_t *ref_rm_msg_ctx, axis2_char_t *make_conn_seq_id, const axis2_char_t *internal_seq_id, axis2_char_t *make_conn_anon_uri, sandesha2_seq_property_mgr_t *seq_prop_mgr) { axis2_msg_ctx_t *ref_msg_ctx = NULL; axis2_msg_ctx_t *make_conn_msg_ctx = NULL; axis2_char_t *rm_ns_value = NULL; axis2_char_t *mc_ns_value = NULL; axis2_char_t *wsa_action = NULL; sandesha2_make_connection_t *make_conn = NULL; sandesha2_msg_ctx_t *make_conn_rm_msg_ctx = NULL; rm_ns_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, SANDESHA2_SPEC_VERSION_1_1); mc_ns_value = MAKE_CONNECTION_SPEC_2007_02_NS_URI; if(ref_rm_msg_ctx) { ref_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(ref_rm_msg_ctx, env); } make_conn_msg_ctx = sandesha2_utils_create_new_related_msg_ctx(env, ref_rm_msg_ctx); if(make_conn_msg_ctx) { make_conn_rm_msg_ctx = sandesha2_msg_init_init_msg(env, make_conn_msg_ctx); } /* This if block is an hack to add the addressing handlers to the outflow. * Check whether this is not a hack */ /*if(ref_msg_ctx) { axis2_op_t *op = axis2_msg_ctx_get_op(ref_msg_ctx, env); axis2_op_t *make_conn_op = axis2_msg_ctx_get_op(make_conn_msg_ctx, env); axutil_array_list_t *out_flow = axis2_op_get_out_flow(op, env); axutil_array_list_t *in_flow = axis2_op_get_in_flow(op, env); int size = axutil_array_list_size(out_flow, env); if(size > 0) { int i = 0; axutil_array_list_t *new_flow = axutil_array_list_create(env, 0); for(i = 0; i < size; i++) { const axis2_phase_t *phase = axutil_array_list_get(out_flow, env, i); const axis2_char_t *phase_name = axis2_phase_get_name(phase, env); if(0 == axutil_strcmp(phase_name, AXIS2_PHASE_MESSAGE_OUT)) { axutil_array_list_add(new_flow, env, phase); } } axis2_op_set_out_flow(make_conn_op, env, new_flow); } size = axutil_array_list_size(in_flow, env); if(size > 0) { int i = 0; axutil_array_list_t *new_flow = axutil_array_list_create(env, 0); for(i = 0; i < size; i++) { const axis2_phase_t *phase = axutil_array_list_get(in_flow, env, i); const axis2_char_t *phase_name = axis2_phase_get_name(phase, env); if(0 == axutil_strcmp(phase_name, "RMPhase")) { axutil_array_list_add(new_flow, env, phase); } } axis2_op_set_in_flow(make_conn_op, env, new_flow); } }*/ make_conn = sandesha2_make_connection_create(env, mc_ns_value); if(make_conn_seq_id) { sandesha2_identifier_t *identifier = sandesha2_identifier_create(env, rm_ns_value); if(identifier) sandesha2_identifier_set_identifier(identifier, env, make_conn_seq_id); if(make_conn) sandesha2_make_connection_set_identifier(make_conn, env, identifier); } if(make_conn_anon_uri) { sandesha2_mc_address_t *address = NULL; axis2_endpoint_ref_t *epr = NULL; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] make_conn_anon_uri:%s", make_conn_anon_uri); address = sandesha2_mc_address_create(env, mc_ns_value, NULL); epr = axis2_endpoint_ref_create(env, make_conn_anon_uri); if(address) { sandesha2_mc_address_set_epr(address, env, epr); } if(make_conn) { sandesha2_make_connection_set_address(make_conn, env, address); } } if(make_conn_msg_ctx) { axis2_endpoint_ref_t *to = NULL; axis2_endpoint_ref_t *reply_to = NULL; axis2_char_t *address = NULL; axutil_string_t *soap_action = NULL; /* Setting the addressing properties */ to = axis2_msg_ctx_get_to(ref_msg_ctx, env); address = (axis2_char_t *) axis2_endpoint_ref_get_address((const axis2_endpoint_ref_t *) to, env); to = axis2_endpoint_ref_create(env, address); axis2_msg_ctx_set_to(make_conn_msg_ctx, env, to); reply_to = axis2_endpoint_ref_create(env, AXIS2_WSA_ANONYMOUS_URL); axis2_msg_ctx_set_reply_to(make_conn_msg_ctx, env, reply_to); wsa_action = sandesha2_spec_specific_consts_get_make_connection_action(env, SANDESHA2_SPEC_VERSION_1_1); axis2_msg_ctx_set_wsa_action(make_conn_msg_ctx, env, wsa_action); soap_action = axutil_string_create(env, wsa_action); axis2_msg_ctx_set_soap_action(make_conn_msg_ctx, env, soap_action); axis2_msg_ctx_set_message_id(make_conn_msg_ctx, env, axutil_uuid_gen(env)); sandesha2_msg_ctx_set_make_connection(make_conn_rm_msg_ctx, env, make_conn); /* Generating the soap envelope */ sandesha2_msg_ctx_add_soap_envelope(make_conn_rm_msg_ctx, env); return make_conn_rm_msg_ctx; } return NULL; }
/** * Create a new create_seq_response message. * @param env axis2 environment struct * @param create_seq_msg * @param out_msg * @param new_seq_id * @param seq_prop_mgr * @return sandesha2_msg_ctx_t */ sandesha2_msg_ctx_t * sandesha2_msg_creator_create_create_seq_res_msg( const axutil_env_t *env, sandesha2_msg_ctx_t *create_seq_msg, axis2_msg_ctx_t *out_msg, axis2_char_t *new_seq_id, sandesha2_seq_property_mgr_t *seq_prop_mgr) { axis2_conf_ctx_t *conf_ctx = NULL; axis2_msg_ctx_t *temp_msg_ctx = NULL; axis2_char_t *rm_version = NULL; axis2_char_t *rm_ns_value = NULL; axis2_char_t *addressing_ns_value = NULL; axis2_char_t *new_msg_id = NULL; axis2_char_t *temp_action = NULL; axutil_string_t *soap_action = NULL; axiom_soap_envelope_t *envelope = NULL; axiom_soap_envelope_t *temp_envelope = NULL; axiom_soap_body_t *temp_soap_body = NULL; axiom_node_t *temp_om_node = NULL; sandesha2_create_seq_res_t *create_seq_res = NULL; sandesha2_identifier_t *identifier = NULL; sandesha2_seq_offer_t *offer = NULL; sandesha2_msg_ctx_t *create_seq_res_rm_msg_ctx = NULL; sandesha2_create_seq_t *cs = NULL; int soap_version = -1; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_msg_creator_create_create_seq_res_msg"); temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); conf_ctx = axis2_msg_ctx_get_conf_ctx(temp_msg_ctx, env); cs = sandesha2_msg_ctx_get_create_seq(create_seq_msg, env); rm_version = sandesha2_utils_get_rm_version(env, temp_msg_ctx); if(!rm_version) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find rm version of given message"); 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, new_seq_id, SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, seq_prop_mgr); if(!addressing_ns_value) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find addressing namespace value"); return NULL; } create_seq_res = sandesha2_create_seq_res_create(env, rm_ns_value, addressing_ns_value); identifier = sandesha2_identifier_create(env, rm_ns_value); sandesha2_identifier_set_identifier(identifier, env, new_seq_id); sandesha2_create_seq_res_set_identifier(create_seq_res, env, identifier); offer = sandesha2_create_seq_get_seq_offer(cs, env); if(offer) { axis2_char_t *out_seq_id = NULL; sandesha2_identifier_t *temp_identifier = NULL; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Offer present"); temp_identifier = sandesha2_seq_offer_get_identifier(offer, env); out_seq_id = sandesha2_identifier_get_identifier(temp_identifier, env); if(out_seq_id && axutil_strcmp("", out_seq_id)) { sandesha2_accept_t *accept = NULL; axis2_endpoint_ref_t *acks_to_epr = NULL; sandesha2_acks_to_t *acks_to = NULL; sandesha2_address_t *address = NULL; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] out_seq_id present"); accept = sandesha2_accept_create(env, rm_ns_value, addressing_ns_value); if(accept) { axis2_endpoint_ref_t *temp_to_epr = NULL; acks_to_epr = sandesha2_msg_ctx_get_to(create_seq_msg, env); if(acks_to_epr) { temp_to_epr = sandesha2_util_endpoint_ref_clone(env, acks_to_epr); } address = sandesha2_address_create(env, addressing_ns_value, temp_to_epr); acks_to = sandesha2_acks_to_create(env, address, rm_ns_value, addressing_ns_value); sandesha2_accept_set_acks_to(accept, env, acks_to); sandesha2_create_seq_res_set_accept(create_seq_res, env, accept); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Could not create accept element"); return NULL; } } } temp_envelope = sandesha2_msg_ctx_get_soap_envelope(create_seq_msg, env); soap_version = sandesha2_utils_get_soap_version(env, temp_envelope); envelope = axiom_soap_envelope_create_default_soap_envelope(env, soap_version); temp_soap_body = axiom_soap_envelope_get_body(envelope, env); temp_om_node = axiom_soap_body_get_base_node(temp_soap_body, env); sandesha2_create_seq_res_to_om_node(create_seq_res, env, temp_om_node); temp_action = sandesha2_spec_specific_consts_get_create_seq_res_action(env, rm_version); axis2_msg_ctx_set_wsa_action(out_msg, env, temp_action); soap_action = axutil_string_create(env, temp_action); /*if(soap_action) { axis2_msg_ctx_set_soap_action(out_msg, env, soap_action); axutil_string_free(soap_action, env); }*/ if(addressing_ns_value) { AXIS2_FREE(env->allocator, addressing_ns_value); } new_msg_id = axutil_uuid_gen(env); if(new_msg_id) { axis2_msg_ctx_set_message_id(out_msg, env, new_msg_id); AXIS2_FREE(env->allocator, new_msg_id); } axis2_msg_ctx_set_soap_envelope(out_msg, env, envelope); temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); sandesha2_msg_creator_init_creation(env, temp_msg_ctx, out_msg); create_seq_res_rm_msg_ctx = sandesha2_msg_init_init_msg(env, out_msg); sandesha2_msg_ctx_set_create_seq_res(create_seq_res_rm_msg_ctx, env, create_seq_res); temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); sandesha2_msg_creator_finalize_creation(env, temp_msg_ctx, out_msg); axis2_msg_ctx_set_server_side(temp_msg_ctx, env, AXIS2_TRUE); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Exit:sandesha2_msg_creator_create_create_seq_res_msg"); return create_seq_res_rm_msg_ctx; }
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; }