axis2_status_t AXIS2_CALL sandesha2_rm_elements_from_soap_envelope( sandesha2_rm_elements_t *rm_elements, const axutil_env_t *env, axiom_soap_envelope_t *soap_envelope, axis2_char_t *action) { axiom_soap_header_t *soap_header = NULL; axiom_soap_body_t *soap_body = NULL; axiom_node_t *header_node = NULL; axiom_element_t *body_element = NULL; axiom_node_t *body_node = NULL; axiom_element_t *header_element = NULL; axiom_node_t *seq_node = NULL; axiom_element_t *seq_ack_element = NULL; axiom_node_t *seq_ack_node = NULL; axiom_node_t *create_seq_node = NULL; axiom_node_t *create_seq_res_node = NULL; axiom_node_t *terminate_seq_node = NULL; axiom_node_t *terminate_seq_res_node = NULL; axiom_node_t *close_seq_node = NULL; axiom_node_t *close_seq_res_node = NULL; axiom_node_t *ack_requested_node = NULL; axiom_node_t *make_conn_node = NULL; axiom_node_t *msg_pending_node = NULL; axutil_qname_t *qname = NULL; axis2_char_t *rm_ns_val = NULL; axis2_char_t *addr_ns_val = NULL; AXIS2_PARAM_CHECK(env->error, soap_envelope, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, action, AXIS2_FAILURE); rm_ns_val = sandesha2_rm_elements_get_rm_ns_val(env, soap_envelope, action); if(!rm_ns_val) return AXIS2_SUCCESS; addr_ns_val = sandesha2_rm_elements_get_addr_ns_val_from_env(env, soap_envelope, action); if(!addr_ns_val) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]Cannot find the addressing version"); return AXIS2_FAILURE; } soap_header = axiom_soap_envelope_get_header(soap_envelope, env); header_node = axiom_soap_header_get_base_node(soap_header, env); header_element = axiom_node_get_data_element(header_node, env); soap_body = axiom_soap_envelope_get_body(soap_envelope, env); body_node = axiom_soap_body_get_base_node(soap_body, env); body_element = axiom_node_get_data_element(body_node, env); qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_SEQ, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(header_element, env, qname, header_node, &seq_node); if(qname) axutil_qname_free(qname, env); if(seq_node) { rm_elements->seq = sandesha2_seq_create(env, rm_ns_val); sandesha2_seq_from_om_node( rm_elements->seq, env, seq_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_SEQ_ACK, rm_ns_val, NULL); seq_ack_element = axiom_element_get_first_child_with_qname(header_element, env, qname, header_node, &seq_ack_node); if(qname) axutil_qname_free(qname, env); if(seq_ack_element) { rm_elements->seq_ack = sandesha2_seq_ack_create(env, rm_ns_val); sandesha2_seq_ack_from_om_node( rm_elements->seq_ack, env, seq_ack_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_CREATE_SEQ, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(body_element, env, qname, body_node, &create_seq_node); if(qname) axutil_qname_free(qname, env); if(create_seq_node) { rm_elements->create_seq = sandesha2_create_seq_create(env, addr_ns_val, rm_ns_val); sandesha2_create_seq_from_om_node( rm_elements->create_seq, env, create_seq_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_CREATE_SEQ_RESPONSE, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(body_element, env, qname, body_node, &create_seq_res_node); if(qname) { axutil_qname_free(qname, env); } if(create_seq_res_node) { rm_elements->create_seq_res = sandesha2_create_seq_res_create(env, rm_ns_val, addr_ns_val); sandesha2_create_seq_res_from_om_node(rm_elements->create_seq_res, env, create_seq_res_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_TERMINATE_SEQ, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(body_element, env, qname, body_node, &terminate_seq_node); if(qname) { axutil_qname_free(qname, env); } if(terminate_seq_node) { rm_elements->terminate_seq = sandesha2_terminate_seq_create(env, rm_ns_val); sandesha2_terminate_seq_from_om_node(rm_elements->terminate_seq, env, terminate_seq_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_TERMINATE_SEQ_RESPONSE, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(body_element, env, qname, body_node, &terminate_seq_res_node); if(qname) { axutil_qname_free(qname, env); } if(terminate_seq_res_node) { rm_elements->terminate_seq_res = sandesha2_terminate_seq_res_create(env, rm_ns_val); sandesha2_terminate_seq_res_from_om_node(rm_elements->terminate_seq_res, env, terminate_seq_res_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_CLOSE_SEQ, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(body_element, env, qname, body_node, &close_seq_node); if(qname) { axutil_qname_free(qname, env); } if(close_seq_node) { rm_elements->close_seq = sandesha2_close_seq_create(env, rm_ns_val); sandesha2_close_seq_from_om_node(rm_elements->close_seq, env, close_seq_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_CLOSE_SEQ_RESPONSE, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(body_element, env, qname, body_node, &close_seq_res_node); if(qname) { axutil_qname_free(qname, env); } if(close_seq_res_node) { rm_elements->close_seq_res = sandesha2_close_seq_res_create(env, rm_ns_val); sandesha2_close_seq_res_from_om_node(rm_elements->close_seq_res, env, close_seq_res_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_MAKE_CONNECTION, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(body_element, env, qname, body_node, &make_conn_node); if(qname) { axutil_qname_free(qname, env); } if(make_conn_node) { rm_elements->make_connection = sandesha2_make_connection_create(env, rm_ns_val); sandesha2_make_connection_from_om_node(rm_elements->make_connection, env, make_conn_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_ACK_REQUESTED, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(header_element, env, qname, header_node, &ack_requested_node); if(qname) axutil_qname_free(qname, env); if(ack_requested_node) { rm_elements->ack_requested = sandesha2_ack_requested_create(env, rm_ns_val); sandesha2_ack_requested_from_om_node( rm_elements->ack_requested, env, ack_requested_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_MESSAGE_PENDING, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(header_element, env, qname, header_node, &msg_pending_node); if(qname) axutil_qname_free(qname, env); if(msg_pending_node) { rm_elements->msg_pending = sandesha2_msg_pending_create(env, rm_ns_val); sandesha2_msg_pending_from_om_node( rm_elements->msg_pending, env, msg_pending_node); } return AXIS2_SUCCESS; }
/** * Adds an ack message to the given application message. * * @param app_msg * @param sequence_id */ axis2_status_t AXIS2_CALL sandesha2_msg_creator_add_ack_msg( const axutil_env_t *env, sandesha2_msg_ctx_t *target_rm_msg_ctx, axis2_char_t *seq_id, sandesha2_seq_property_mgr_t *seq_prop_mgr) { axiom_soap_envelope_t *envelope = NULL; axiom_soap_header_t *soap_header = NULL; axis2_conf_ctx_t *conf_ctx = NULL; axis2_char_t *rm_version = NULL; axis2_char_t *rm_ns_value = NULL; axis2_char_t *msg_no_list = NULL; axis2_char_t *ack_req_action = NULL; axis2_char_t *temp_action = NULL; axutil_string_t *ack_req_soap_action = NULL; axis2_char_t *str_value = NULL; axis2_char_t *uuid = NULL; sandesha2_identifier_t *id = NULL; sandesha2_seq_ack_t *seq_ack = NULL; sandesha2_seq_property_bean_t *seq_bean = NULL; sandesha2_seq_property_bean_t *seq_closed_bean = NULL; axis2_msg_ctx_t *msg_ctx = NULL; axutil_array_list_t *ack_range_list = NULL; int i = 0, size = 0; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_msg_creator_add_ack_msg"); envelope = sandesha2_msg_ctx_get_soap_envelope(target_rm_msg_ctx, env); if(!envelope) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NULL_SOAP_ENVELOPE_IN_MSG_CTX, AXIS2_FAILURE); return AXIS2_FAILURE; } msg_ctx = sandesha2_msg_ctx_get_msg_ctx(target_rm_msg_ctx, env); conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); rm_version = sandesha2_utils_get_rm_version(env, msg_ctx); if(!rm_version) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_RM_VERSION_OF_GIVEN_MSG, AXIS2_FAILURE); return AXIS2_FAILURE; } rm_ns_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, rm_version); seq_ack = sandesha2_seq_ack_create(env, rm_ns_value); id = sandesha2_identifier_create(env, rm_ns_value); sandesha2_identifier_set_identifier(id, env, seq_id); sandesha2_seq_ack_set_identifier(seq_ack, env, id); seq_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, seq_id, SANDESHA2_SEQ_PROP_SERVER_COMPLETED_MESSAGES); if(seq_bean) { msg_no_list = (axis2_char_t *) sandesha2_seq_property_bean_get_value(seq_bean, env); } ack_range_list = sandesha2_utils_get_ack_range_list(env, msg_no_list, rm_ns_value); if(seq_bean) { sandesha2_seq_property_bean_free(seq_bean, env); } if(ack_range_list) { size = axutil_array_list_size(ack_range_list, env); } for(i = 0; i < size; i++) { sandesha2_ack_range_t *ack_range = NULL; ack_range = axutil_array_list_get(ack_range_list, env, i); sandesha2_seq_ack_add_ack_range(seq_ack, env, ack_range); } if(ack_range_list) { axutil_array_list_free(ack_range_list, env); } seq_closed_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, seq_id, SANDESHA2_SEQ_PROP_SEQ_CLOSED); if(seq_closed_bean) { str_value = sandesha2_seq_property_bean_get_value(seq_closed_bean, env); } if(seq_closed_bean && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, str_value)) { axis2_bool_t is_allowed = AXIS2_FALSE; /* sequence is closed. so add the 'Final' part. */ is_allowed = sandesha2_spec_specific_consts_is_ack_final_allowed(env, rm_version); if(is_allowed) { sandesha2_ack_final_t *ack_final = NULL; ack_final = sandesha2_ack_final_create(env,rm_ns_value); sandesha2_seq_ack_set_ack_final(seq_ack, env, ack_final); } } if(seq_closed_bean) { sandesha2_seq_property_bean_free(seq_closed_bean, env); } sandesha2_msg_ctx_set_seq_ack(target_rm_msg_ctx, env, seq_ack); soap_header = axiom_soap_envelope_get_header(envelope, env); sandesha2_seq_ack_to_om_node(seq_ack, env, soap_header); ack_req_action = sandesha2_msg_ctx_get_wsa_action(target_rm_msg_ctx, env); if((!ack_req_action) || (!axutil_strcmp(ack_req_action, ""))) { ack_req_action = sandesha2_spec_specific_consts_get_seq_ack_action(env, rm_version); sandesha2_msg_ctx_set_wsa_action(target_rm_msg_ctx, env, ack_req_action); } temp_action = sandesha2_spec_specific_consts_get_seq_ack_soap_action(env, rm_version); ack_req_soap_action = axutil_string_create(env, temp_action); if(ack_req_soap_action) { sandesha2_msg_ctx_set_soap_action(target_rm_msg_ctx, env, ack_req_soap_action); axutil_string_free(ack_req_soap_action, env); } uuid = axutil_uuid_gen(env); sandesha2_msg_ctx_set_msg_id(target_rm_msg_ctx, env, uuid); if(uuid) { AXIS2_FREE(env->allocator, uuid); } AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Exit:sandesha2_msg_creator_add_ack_msg"); return AXIS2_SUCCESS; }