axis2_endpoint_ref_t *AXIS2_CALL sandesha2_msg_ctx_get_reply_to( sandesha2_msg_ctx_t *rm_msg_ctx, const axutil_env_t *env) { return axis2_msg_ctx_get_reply_to(rm_msg_ctx->msg_ctx, env); }
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; }
AXIS2_EXTERN axis2_msg_ctx_t * AXIS2_CALL axis2_engine_create_fault_msg_ctx( axis2_engine_t * engine, const axutil_env_t * env, axis2_msg_ctx_t * processing_context, const axis2_char_t * code_value, const axis2_char_t * reason_text) { axis2_msg_ctx_t *fault_ctx = NULL; axis2_endpoint_ref_t *fault_to = NULL; axis2_endpoint_ref_t *reply_to = NULL; axutil_stream_t *stream = NULL; axiom_soap_envelope_t *envelope = NULL; const axis2_char_t *wsa_action = NULL; const axis2_char_t *msg_id = NULL; axis2_relates_to_t *relates_to = NULL; axis2_char_t *msg_uuid = NULL; axis2_msg_info_headers_t *msg_info_headers = NULL; axis2_bool_t doing_rest = AXIS2_FALSE; AXIS2_PARAM_CHECK(env->error, processing_context, NULL); if(axis2_msg_ctx_get_process_fault(processing_context, env)) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_PROCESSING_FAULT_ALREADY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating fault message contex failed"); return NULL; } fault_ctx = axis2_msg_ctx_create(env, engine->conf_ctx, axis2_msg_ctx_get_transport_in_desc( processing_context, env), axis2_msg_ctx_get_transport_out_desc(processing_context, env)); axis2_msg_ctx_set_process_fault(fault_ctx, env, AXIS2_TRUE); fault_to = axis2_msg_ctx_get_fault_to(processing_context, env); if(fault_to) { const axis2_char_t *address = axis2_endpoint_ref_get_address(fault_to, env); if(!address) { fault_to = NULL; } else if(axutil_strcmp(AXIS2_WSA_NONE_URL, address) == 0 || axutil_strcmp( AXIS2_WSA_NONE_URL_SUBMISSION, address) == 0) { reply_to = axis2_msg_ctx_get_reply_to(processing_context, env); if(reply_to) { axis2_msg_ctx_set_fault_to(fault_ctx, env, reply_to); } else { axis2_msg_ctx_set_fault_to(fault_ctx, env, fault_to); } } else { axis2_msg_ctx_set_fault_to(fault_ctx, env, fault_to); } } stream = axis2_msg_ctx_get_transport_out_stream(processing_context, env); if(stream) { axis2_msg_ctx_set_transport_out_stream(fault_ctx, env, stream); axis2_msg_ctx_reset_transport_out_stream(processing_context, env); } if(!fault_to && !stream) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NOWHERE_TO_SEND_FAULT, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Soap fault target destination not found"); return NULL; } /* Set WSA action */ msg_info_headers = axis2_msg_ctx_get_msg_info_headers(processing_context, env); if(msg_info_headers) { wsa_action = axis2_msg_info_headers_get_action(msg_info_headers, env); if(wsa_action) { /* We have to use the action set by user, cannot use the default always. wsa_action = "http://www.w3.org/2005/08/addressing/fault"; */ axis2_msg_ctx_set_wsa_action(fault_ctx, env, wsa_action); } } /* Set relates to */ msg_id = axis2_msg_ctx_get_msg_id(processing_context, env); /* we can create with default Relates to namespace. Actual namespace based on addressing version will be created in addressing out handler */ relates_to = axis2_relates_to_create(env, msg_id, AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE); axis2_msg_ctx_set_relates_to(fault_ctx, env, relates_to); /* Set msg id */ msg_uuid = axutil_uuid_gen(env); axis2_msg_ctx_set_message_id(fault_ctx, env, msg_uuid); if(msg_uuid) { AXIS2_FREE(env->allocator, msg_uuid); msg_uuid = NULL; } /** Copy the property map from the current message context to the newly created fault message context. */ { axis2_ctx_t *ctx = axis2_msg_ctx_get_base(processing_context, env); axis2_ctx_t *fault_base_ctx = axis2_msg_ctx_get_base(fault_ctx, env); if(ctx && fault_ctx) { axis2_ctx_set_property_map(fault_base_ctx, env, axis2_ctx_get_property_map(ctx, env)); } } axis2_msg_ctx_set_op_ctx(fault_ctx, env, axis2_msg_ctx_get_op_ctx(processing_context, env)); axis2_msg_ctx_set_process_fault(fault_ctx, env, AXIS2_TRUE); axis2_msg_ctx_set_server_side(fault_ctx, env, AXIS2_TRUE); envelope = axis2_msg_ctx_get_fault_soap_envelope(processing_context, env); if(!envelope) { if(axis2_msg_ctx_get_is_soap_11(processing_context, env)) { envelope = axiom_soap_envelope_create_default_soap_fault_envelope(env, code_value, reason_text, AXIOM_SOAP11, NULL, NULL); } else { envelope = axiom_soap_envelope_create_default_soap_fault_envelope(env, code_value, reason_text, AXIOM_SOAP12, NULL, NULL); } if(!envelope) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Creating default soap envelope failed"); return NULL; } } else { axis2_msg_ctx_set_fault_soap_envelope(processing_context, env, NULL); } doing_rest = axis2_msg_ctx_get_doing_rest(processing_context, env); axis2_msg_ctx_set_doing_rest(fault_ctx, env, doing_rest); axis2_msg_ctx_set_soap_envelope(fault_ctx, env, envelope); axis2_msg_ctx_set_out_transport_info(fault_ctx, env, axis2_msg_ctx_get_out_transport_info( processing_context, env)); axis2_msg_ctx_reset_out_transport_info(processing_context, env); return fault_ctx; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL sandesha2_seq_mgr_setup_new_outgoing_sequence( const axutil_env_t *env, axis2_msg_ctx_t *first_app_msg, axis2_char_t *internal_sequence_id, axis2_char_t *spec_version, sandesha2_seq_property_mgr_t *seq_prop_mgr) { axis2_conf_ctx_t *conf_ctx = NULL; axis2_char_t *addr_ns_val = NULL; axutil_property_t *property = NULL; sandesha2_seq_property_bean_t *addr_ns_bean = NULL; axis2_char_t *anon_uri = NULL; axis2_endpoint_ref_t *to_epr = NULL; axis2_char_t *acks_to_str = NULL; sandesha2_seq_property_bean_t *to_bean = NULL; sandesha2_seq_property_bean_t *reply_to_bean = NULL; sandesha2_seq_property_bean_t *acks_to_bean = NULL; sandesha2_seq_property_bean_t *msgs_bean = NULL; axis2_char_t *transport_to = NULL; axis2_endpoint_ref_t *reply_to_epr = NULL; axis2_bool_t is_svr_side = AXIS2_FALSE; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:sandesha2_seq_mgr_setup_new_outgoing_sequence"); AXIS2_PARAM_CHECK(env->error, first_app_msg, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, internal_sequence_id, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, spec_version, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, seq_prop_mgr, AXIS2_FAILURE); conf_ctx = axis2_msg_ctx_get_conf_ctx(first_app_msg, env); property = axis2_msg_ctx_get_property(first_app_msg, env, AXIS2_WSA_VERSION); if(property) { addr_ns_val = axutil_property_get_value(property, env); } if(!addr_ns_val) { axis2_op_ctx_t *op_ctx = NULL; axis2_msg_ctx_t *req_msg_ctx = NULL; op_ctx = axis2_msg_ctx_get_op_ctx(first_app_msg, env); req_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN); if(req_msg_ctx) { property = axis2_msg_ctx_get_property(req_msg_ctx, env, AXIS2_WSA_VERSION); if(property) { addr_ns_val = axutil_property_get_value(property, env); } } } if(!addr_ns_val) { addr_ns_val = AXIS2_WSA_NAMESPACE; } addr_ns_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, addr_ns_val); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, addr_ns_bean); if(addr_ns_bean) { sandesha2_seq_property_bean_free(addr_ns_bean, env); } anon_uri = sandesha2_spec_specific_consts_get_anon_uri(env, addr_ns_val); to_epr = axis2_msg_ctx_get_to(first_app_msg, env); property = axis2_msg_ctx_get_property(first_app_msg, env, SANDESHA2_CLIENT_ACKS_TO); if(property) { acks_to_str = axutil_property_get_value(property, env); } if (to_epr) { to_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, SANDESHA2_SEQ_PROP_TO_EPR, (axis2_char_t*)axis2_endpoint_ref_get_address(to_epr, env)); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, to_bean); sandesha2_seq_property_bean_free(to_bean, env); } is_svr_side = axis2_msg_ctx_get_server_side(first_app_msg, env); if(is_svr_side) { axis2_op_ctx_t *op_ctx = NULL; axis2_msg_ctx_t *req_msg_ctx = NULL; op_ctx = axis2_msg_ctx_get_op_ctx(first_app_msg, env); req_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN); if(!req_msg_ctx) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find the request message from the operation context"); return AXIS2_FAILURE; } reply_to_epr = axis2_msg_ctx_get_to(req_msg_ctx, env); if(reply_to_epr) { const axis2_char_t *temp_epr_addr = axis2_endpoint_ref_get_address(reply_to_epr, env); if(temp_epr_addr) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "temp_epr_address:%s", temp_epr_addr); acks_to_str = (axis2_char_t *) temp_epr_addr; reply_to_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, SANDESHA2_SEQ_PROP_REPLY_TO_EPR, (axis2_char_t*) temp_epr_addr); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, reply_to_bean); sandesha2_seq_property_bean_free(reply_to_bean, env); } } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot get request message from the operation context"); return AXIS2_FAILURE; } } else /* Not server side */ { reply_to_epr = axis2_msg_ctx_get_reply_to(first_app_msg, env); if(reply_to_epr) { const axis2_char_t *temp_epr_addr = axis2_endpoint_ref_get_address(reply_to_epr, env); if(temp_epr_addr) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "temp_epr_address:%s", temp_epr_addr); reply_to_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, SANDESHA2_SEQ_PROP_REPLY_TO_EPR, (axis2_char_t*) temp_epr_addr); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, reply_to_bean); sandesha2_seq_property_bean_free(reply_to_bean, env); } } } if(!acks_to_str) { acks_to_str = anon_uri; } acks_to_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, SANDESHA2_SEQ_PROP_ACKS_TO_EPR, acks_to_str); msgs_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, SANDESHA2_SEQ_PROP_CLIENT_COMPLETED_MESSAGES, ""); if(msgs_bean) { sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, msgs_bean); sandesha2_seq_property_bean_free(msgs_bean, 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); } transport_to = axis2_msg_ctx_get_transport_url(first_app_msg, env); if(transport_to) { sandesha2_seq_property_bean_t *transport_to_bean = NULL; transport_to_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, SANDESHA2_SEQ_PROP_TRANSPORT_TO, transport_to); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, transport_to_bean); } sandesha2_seq_mgr_update_last_activated_time(env, internal_sequence_id, seq_prop_mgr); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:sandesha2_seq_mgr_setup_new_outgoing_sequence"); return AXIS2_SUCCESS; }