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; }
axis2_status_t axis2_amqp_process_request( const axutil_env_t* env, axis2_amqp_request_processor_resource_pack_t* request_resource_pack) { axiom_xml_reader_t* xml_reader = NULL; axiom_stax_builder_t* stax_builder = NULL; axiom_soap_builder_t* soap_builder = NULL; axis2_transport_out_desc_t* out_desc = NULL; axis2_transport_in_desc_t* in_desc = NULL; axis2_msg_ctx_t* msg_ctx = NULL; axiom_soap_envelope_t* soap_envelope = NULL; axis2_engine_t* engine = NULL; const axis2_char_t* soap_ns_uri = NULL; axis2_bool_t is_soap_11 = AXIS2_FALSE; axis2_char_t *soap_body_str = NULL; int soap_body_len = 0; axis2_bool_t is_mtom = AXIS2_FALSE; axis2_status_t status = AXIS2_FAILURE; axutil_hash_t *binary_data_map = NULL; axiom_soap_body_t *soap_body = NULL; axutil_property_t* reply_to_property = NULL; /* Create msg_ctx */ if(!request_resource_pack->conf_ctx) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Conf Context not Available"); return AXIS2_FAILURE; } out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf( request_resource_pack->conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_AMQP); if(!out_desc) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport Out Descriptor not Found"); return AXIS2_FAILURE; } in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(request_resource_pack->conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_AMQP); if(!in_desc) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport In Descriptor not Found"); return AXIS2_FAILURE; } /* Create msg_ctx */ msg_ctx = axis2_msg_ctx_create(env, request_resource_pack->conf_ctx, in_desc, out_desc); axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE); /* Handle MTOM */ if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED)) { axis2_char_t* mime_boundary = axis2_amqp_util_get_value_from_content_type(env, request_resource_pack->content_type, AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY); if(mime_boundary) { axiom_mime_parser_t *mime_parser = NULL; int soap_body_len = 0; axutil_param_t *buffer_size_param = NULL; axutil_param_t *max_buffers_param = NULL; axutil_param_t *attachment_dir_param = NULL; axis2_char_t *value_size = NULL; axis2_char_t *value_num = NULL; axis2_char_t *value_dir = NULL; int size = 0; int num = 0; mime_parser = axiom_mime_parser_create(env); buffer_size_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_BUFFER_SIZE); if(buffer_size_param) { value_size = (axis2_char_t*)axutil_param_get_value(buffer_size_param, env); if(value_size) { size = atoi(value_size); axiom_mime_parser_set_buffer_size(mime_parser, env, size); } } max_buffers_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_MAX_BUFFERS); if(max_buffers_param) { value_num = (axis2_char_t*)axutil_param_get_value(max_buffers_param, env); if(value_num) { num = atoi(value_num); axiom_mime_parser_set_max_buffers(mime_parser, env, num); } } /* If this paramter is there mime_parser will cached the attachment * using to the directory for large attachments. */ attachment_dir_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_ATTACHMENT_DIR); if(attachment_dir_param) { value_dir = (axis2_char_t*)axutil_param_get_value(attachment_dir_param, env); if(value_dir) { axiom_mime_parser_set_attachment_dir(mime_parser, env, value_dir); } } if(mime_parser) { axis2_callback_info_t *callback_ctx = NULL; axutil_stream_t *stream = NULL; callback_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_callback_info_t)); stream = axutil_stream_create_basic(env); if(stream) { axutil_stream_write(stream, env, request_resource_pack->request_content, request_resource_pack->content_length); callback_ctx->env = env; callback_ctx->in_stream = stream; callback_ctx->content_length = request_resource_pack->content_length; callback_ctx->unread_len = request_resource_pack->content_length; callback_ctx->chunked_stream = NULL; } /*binary_data_map = axiom_mime_parser_parse(mime_parser, env, axis2_amqp_util_on_data_request, (void*)callback_ctx, mime_boundary);*/ if(!binary_data_map) { return AXIS2_FAILURE; } soap_body_str = axiom_mime_parser_get_soap_body_str(mime_parser, env); soap_body_len = axiom_mime_parser_get_soap_body_len(mime_parser, env); axutil_stream_free(stream, env); AXIS2_FREE(env->allocator, callback_ctx); axiom_mime_parser_free(mime_parser, env); } AXIS2_FREE(env->allocator, mime_boundary); } is_mtom = AXIS2_TRUE; } else { soap_body_str = request_resource_pack->request_content; soap_body_len = request_resource_pack->content_length; } soap_body_len = axutil_strlen(soap_body_str); xml_reader = axiom_xml_reader_create_for_memory(env, soap_body_str, soap_body_len, NULL, AXIS2_XML_PARSER_TYPE_BUFFER); if(!xml_reader) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Reader"); return AXIS2_FAILURE; } stax_builder = axiom_stax_builder_create(env, xml_reader); if(!stax_builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create StAX Builder"); return AXIS2_FAILURE; } soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; if(request_resource_pack->content_type) { if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML)) { is_soap_11 = AXIS2_TRUE; soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; } /*if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_APPL_SOAP)) { is_soap_11 = AXIS2_FALSE; soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; } else if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML)) { is_soap_11 = AXIS2_TRUE; soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; }*/ } soap_builder = axiom_soap_builder_create(env, stax_builder, soap_ns_uri); if(!soap_builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create SOAP Builder"); return AXIS2_FAILURE; } if(binary_data_map) { axiom_soap_builder_set_mime_body_parts(soap_builder, env, binary_data_map); } soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env); axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope); soap_body = axiom_soap_envelope_get_body(soap_envelope, env); if(!soap_body) { return AXIS2_FAILURE; } /* SOAPAction */ if(request_resource_pack->soap_action) { axis2_msg_ctx_set_soap_action(msg_ctx, env, axutil_string_create(env, request_resource_pack->soap_action)); } /* SOAP version */ axis2_msg_ctx_set_is_soap_11(msg_ctx, env, is_soap_11); /* Set ReplyTo in the msg_ctx as a property. This is used by the server when * 1. WS-A is not in use * 2. ReplyTo is an anonymous EPR - Sandesha2/Dual-channel */ reply_to_property = axutil_property_create_with_args(env, AXIS2_SCOPE_REQUEST, 0, 0, (void*)request_resource_pack->reply_to); axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO, reply_to_property); engine = axis2_engine_create(env, request_resource_pack->conf_ctx); if(AXIS2_TRUE == axiom_soap_body_has_fault(soap_body, env)) { status = axis2_engine_receive_fault(engine, env, msg_ctx); } else { status = axis2_engine_receive(engine, env, msg_ctx); } if(engine) { axis2_engine_free(engine, env); } if(soap_body_str && is_mtom) { AXIS2_FREE(env->allocator, soap_body_str); } return status; }
AXIS2_EXTERN axis2_bool_t AXIS2_CALL axis2_tcp_worker_process_request( axis2_tcp_worker_t * tcp_worker, const axutil_env_t * env, axis2_simple_tcp_svr_conn_t * svr_conn, axis2_char_t * simple_request) { axis2_conf_ctx_t *conf_ctx = NULL; axis2_transport_out_desc_t *out_desc = NULL; axis2_transport_in_desc_t *in_desc = NULL; axis2_msg_ctx_t *msg_ctx = NULL; axiom_xml_reader_t *reader = NULL; axiom_stax_builder_t *builder = NULL; axiom_soap_builder_t *soap_builder = NULL; axiom_soap_envelope_t *soap_envelope = NULL; axis2_engine_t *engine = NULL; axis2_status_t status = AXIS2_FALSE; axutil_stream_t *svr_stream = NULL; axis2_char_t *buffer = NULL; int len = 0; int write = -1; axutil_stream_t *out_stream = NULL; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "start:axis2_tcp_worker_process_request"); reader = axiom_xml_reader_create_for_memory(env, simple_request, axutil_strlen(simple_request), NULL, AXIS2_XML_PARSER_TYPE_BUFFER); if(!reader) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create XML reader"); return AXIS2_FAILURE; } builder = axiom_stax_builder_create(env, reader); if(!builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create Stax builder"); return AXIS2_FAILURE; } soap_builder= axiom_soap_builder_create(env, builder, NULL); if(!soap_builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create SOAP builder"); return AXIS2_FAILURE; } conf_ctx = tcp_worker->conf_ctx; if(!conf_ctx) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "conf ctx not available"); return AXIS2_FAILURE; } out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf(conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_TCP); if(!out_desc) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport out not set"); return AXIS2_FAILURE; } in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_TCP); msg_ctx = axis2_msg_ctx_create(env, conf_ctx, in_desc, out_desc); axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE); out_stream = axutil_stream_create_basic(env); axis2_msg_ctx_set_transport_out_stream(msg_ctx, env, out_stream); soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env); axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope); engine = axis2_engine_create(env, conf_ctx); status = axis2_engine_receive(engine, env, msg_ctx); svr_stream = axis2_simple_tcp_svr_conn_get_stream(svr_conn, env); buffer = out_stream->buffer; len = out_stream->len; buffer[len] = 0; if(svr_stream && buffer) { write = axutil_stream_write(svr_stream, env, buffer, len + 1); if(write < 0) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "stream write failed"); return AXIS2_FAILURE; } AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "stream wrote:%s", buffer); } AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "end:axis2_tcp_worker_process_request"); 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_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_terminate_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 *terminate_msg_ctx = NULL; sandesha2_terminate_seq_t *term_seq = NULL; axis2_char_t *rmd_sequence_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_create_seq_mgr_t *create_seq_mgr = NULL; sandesha2_sender_mgr_t *sender_mgr = NULL; sandesha2_next_msg_mgr_t *next_msg_mgr = NULL; sandesha2_msg_ctx_t *fault_ctx = NULL; axis2_char_t *spec_version = NULL; axis2_char_t *dbname = NULL; sandesha2_seq_ack_t *seq_ack = NULL; axis2_op_ctx_t *op_ctx = NULL; /*sandesha2_seq_property_bean_t *term_rcvd_bean = NULL;*/ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Entry:sandesha2_terminate_seq_msg_processor_process_in_msg"); AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE); terminate_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env); if(axis2_msg_ctx_get_server_side(terminate_msg_ctx, env)) { axis2_msg_ctx_t **msg_ctx_map = NULL; op_ctx = axis2_msg_ctx_get_op_ctx(terminate_msg_ctx, env); msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env); msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN] = terminate_msg_ctx; } term_seq = sandesha2_msg_ctx_get_terminate_seq(rm_msg_ctx, env); if(!term_seq) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Terminate Sequence part is not available"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING, AXIS2_FAILURE); return AXIS2_FAILURE; } rmd_sequence_id = sandesha2_identifier_get_identifier(sandesha2_terminate_seq_get_identifier( term_seq, env), env); if(!rmd_sequence_id || 0 == axutil_strlen(rmd_sequence_id)) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Invalid sequence id"); return AXIS2_FAILURE; } conf_ctx = axis2_msg_ctx_get_conf_ctx(terminate_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); next_msg_mgr = sandesha2_permanent_next_msg_mgr_create(env, dbname); fault_ctx = sandesha2_fault_mgr_check_for_unknown_seq(env, rm_msg_ctx, rmd_sequence_id, seq_prop_mgr, create_seq_mgr, next_msg_mgr); if(fault_ctx) { axis2_engine_t *engine = NULL; engine = axis2_engine_create(env, conf_ctx); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Send fault occurred"); axis2_engine_send_fault(engine, env, sandesha2_msg_ctx_get_msg_ctx(fault_ctx, env)); sandesha2_msg_ctx_free(fault_ctx, env); if(engine) { axis2_engine_free(engine, env); } axis2_msg_ctx_set_paused(terminate_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(sender_mgr) { sandesha2_sender_mgr_free(sender_mgr, env); } if(next_msg_mgr) { sandesha2_next_msg_mgr_free(next_msg_mgr, env); } if(storage_mgr) { sandesha2_storage_mgr_free(storage_mgr, env); } return AXIS2_SUCCESS; } /*term_rcvd_bean = sandesha2_seq_property_bean_create(env); sandesha2_seq_property_bean_set_seq_id(term_rcvd_bean, env, rmd_sequence_id); sandesha2_seq_property_bean_set_name(term_rcvd_bean, env, SANDESHA2_SEQ_PROP_TERMINATE_RECEIVED); sandesha2_seq_property_bean_set_value(term_rcvd_bean, env, AXIS2_VALUE_TRUE); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, term_rcvd_bean);*/ spec_version = sandesha2_msg_ctx_get_rm_spec_ver(rm_msg_ctx, env); if(sandesha2_spec_specific_consts_is_term_seq_res_reqd(env, spec_version)) { sandesha2_terminate_seq_msg_processor_add_terminate_seq_res(env, rm_msg_ctx, rmd_sequence_id, seq_prop_mgr); } seq_ack = sandesha2_msg_ctx_get_seq_ack(rm_msg_ctx, env); /* If we have received a sequence acknowldegment with the incoming terminate message then we may * decide to send the terminate sequence message. */ if(seq_ack) { axis2_char_t *internal_sequence_id = NULL; axis2_char_t *rms_sequence_id = NULL; axis2_char_t *last_out_msg_no_str = NULL; long highest_out_msg_no = 0; sandesha2_seq_property_bean_t *terminated_bean = NULL; /* If there is a sequence acknowledgement element present in the sequence we will check * whether the sequence is completed. If so send a terminate sequence message. */ rms_sequence_id = sandesha2_identifier_get_identifier(sandesha2_seq_ack_get_identifier( seq_ack, env), env); internal_sequence_id = sandesha2_utils_get_seq_property(env, rms_sequence_id, SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_INTERNAL_SEQUENCE_ID, seq_prop_mgr); terminated_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_sequence_id, SANDESHA2_SEQ_PROP_TERMINATE_ADDED); if(terminated_bean) { axis2_char_t *value = sandesha2_seq_property_bean_get_value(terminated_bean, env); if(value && !axutil_strcmp(AXIS2_VALUE_TRUE, value)) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Terminate sequence message was added previously"); } sandesha2_seq_property_bean_free(terminated_bean, env); } else { /* Retrieve the message number of the RM 1.0 last message */ last_out_msg_no_str = sandesha2_utils_get_seq_property(env, internal_sequence_id, SANDESHA2_SEQ_PROP_LAST_OUT_MESSAGE_NO, seq_prop_mgr); if(last_out_msg_no_str) { highest_out_msg_no = atol(last_out_msg_no_str); if(last_out_msg_no_str) { AXIS2_FREE(env->allocator, last_out_msg_no_str); } } else { highest_out_msg_no = sandesha2_app_msg_processor_get_prev_msg_no(env, internal_sequence_id, seq_prop_mgr); } if(highest_out_msg_no > 0) { axis2_bool_t completed = AXIS2_FALSE; axutil_array_list_t *ack_range_list = NULL; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] highest_out_msg_no:%ld", highest_out_msg_no); ack_range_list = sandesha2_seq_ack_get_ack_range_list(seq_ack, env); completed = sandesha2_ack_mgr_verify_seq_completion(env, ack_range_list, highest_out_msg_no); if(completed) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Sequence %s is completed. So adding terminate msg", rms_sequence_id); sandesha2_terminate_mgr_send_terminate_seq_msg(env, rm_msg_ctx, rms_sequence_id, internal_sequence_id, storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr); } } if(internal_sequence_id) { AXIS2_FREE(env->allocator, internal_sequence_id); } } } else { sandesha2_terminate_seq_msg_processor_setup_highest_msg_nums(env, conf_ctx, storage_mgr, rmd_sequence_id, rm_msg_ctx, seq_prop_mgr, create_seq_mgr, sender_mgr); } /*sandesha2_terminate_mgr_clean_recv_side_after_terminate_msg(env, conf_ctx, rmd_sequence_id, storage_mgr, seq_prop_mgr, next_msg_mgr);*/ /*transmit_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id, SANDESHA2_SEQ_PROP_SEQ_TERMINATED, AXIS2_VALUE_TRUE); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, transmit_bean); sandesha2_seq_mgr_update_last_activated_time(env, rmd_sequence_id, storage_mgr); */ /* We have no intention to pass this message beyond Sandesha2/C handler. So pause the message * context */ sandesha2_msg_ctx_set_paused(rm_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(sender_mgr) { sandesha2_sender_mgr_free(sender_mgr, env); } if(next_msg_mgr) { sandesha2_next_msg_mgr_free(next_msg_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_in_msg"); return AXIS2_SUCCESS; }
/* Process a request. If the request has a response the response structure will be populated */ AXIS2_EXTERN axis2_bool_t AXIS2_CALL axis2_udp_receiver_process_request( const axutil_env_t * env, axis2_conf_ctx_t *conf_ctx, axis2_udp_request_t * request, axis2_udp_response_t * responce) { axis2_transport_out_desc_t *out_desc = NULL; axis2_transport_in_desc_t *in_desc = NULL; axis2_msg_ctx_t *msg_ctx = NULL; axiom_xml_reader_t *reader = NULL; axiom_stax_builder_t *builder = NULL; axiom_soap_builder_t *soap_builder = NULL; axiom_soap_envelope_t *soap_envelope = NULL; axis2_engine_t *engine = NULL; axis2_status_t status = AXIS2_FALSE; axutil_stream_t *out_stream = NULL; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "start:axis2_udp_worker_process_request"); if (!conf_ctx) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "conf ctx not available"); return AXIS2_FAILURE; } reader = axiom_xml_reader_create_for_memory(env, request->buff, request->buf_size, NULL, AXIS2_XML_PARSER_TYPE_BUFFER); if (!reader) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create XML reader"); return AXIS2_FAILURE; } builder = axiom_stax_builder_create(env, reader); if (!builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create Stax builder"); return AXIS2_FAILURE; } soap_builder = axiom_soap_builder_create(env, builder, AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI); if (!soap_builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create SOAP builder"); return AXIS2_FAILURE; } out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf(conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_UDP); if (!out_desc) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport out not set"); return AXIS2_FAILURE; } in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_UDP); msg_ctx = axis2_msg_ctx_create(env, conf_ctx, in_desc, out_desc); axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE); out_stream = axutil_stream_create_basic(env); axis2_msg_ctx_set_transport_out_stream(msg_ctx, env, out_stream); soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env); axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope); if (request->svc) { axis2_msg_ctx_set_svc(msg_ctx, env, request->svc); } if (request->op) { axis2_msg_ctx_set_op(msg_ctx, env, request->op); } engine = axis2_engine_create(env, conf_ctx); status = axis2_engine_receive(engine, env, msg_ctx); responce->buff = axutil_stream_get_buffer(out_stream, env); responce->buf_size = axutil_stream_get_len(out_stream, env); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "end:axis2_udp_worker_process_request"); 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; }