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; }
/** * Create a new create_seq_msg * @param env * @param application_rm_msg * @param internal_seq_id * @param acks_to * @param seq_prop_mgr * @return sandesha2_msg_ctx_t */ sandesha2_msg_ctx_t *AXIS2_CALL sandesha2_msg_creator_create_create_seq_msg( const axutil_env_t *env, sandesha2_msg_ctx_t *application_rm_msg, axis2_char_t *internal_seq_id, axis2_char_t *acks_to, sandesha2_seq_property_mgr_t *seq_prop_mgr) { axis2_msg_ctx_t *application_msg_ctx = NULL; axis2_msg_ctx_t *create_seq_msg_ctx = NULL; axis2_conf_ctx_t *conf_ctx = NULL; axis2_op_t *app_msg_op_desc = NULL; axis2_op_ctx_t *op_ctx = NULL; axis2_char_t *create_seq_msg_id = NULL; axis2_char_t *rm_version = NULL; axis2_char_t *rm_ns_value = NULL; axis2_char_t *addressing_ns_value = NULL; axis2_char_t *anonymous_uri = NULL; axis2_char_t *temp_value = NULL; axis2_char_t *temp_action = NULL; axutil_string_t *temp_soap_action = NULL; axis2_endpoint_ref_t *to_epr = NULL; axis2_endpoint_ref_t *temp_to = NULL; axis2_endpoint_ref_t *acks_to_epr = NULL; axis2_endpoint_ref_t *temp_reply_to = NULL; sandesha2_create_seq_t *create_seq_part = NULL; sandesha2_seq_property_bean_t *reply_to_bean = NULL; sandesha2_seq_property_bean_t *to_bean = NULL; sandesha2_msg_ctx_t *create_seq_rm_msg = NULL; sandesha2_address_t *temp_address = NULL; sandesha2_acks_to_t *temp_acks_to = NULL; axutil_property_t *property = NULL; const axis2_char_t *reply_to_address = NULL; application_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(application_rm_msg, env); if(!application_msg_ctx) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_APPLICATION_MSG_NULL, AXIS2_FAILURE); return NULL; } conf_ctx = axis2_msg_ctx_get_conf_ctx(application_msg_ctx, env); if(!conf_ctx) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CONF_CTX_NULL, AXIS2_FAILURE); return NULL; } /* Creating by copying common contents. */ create_seq_msg_ctx = sandesha2_utils_create_new_related_msg_ctx(env, application_rm_msg); sandesha2_msg_creator_init_creation(env, application_msg_ctx, create_seq_msg_ctx); create_seq_msg_id = axutil_uuid_gen(env); axis2_msg_ctx_set_message_id(create_seq_msg_ctx, env, create_seq_msg_id); AXIS2_FREE(env->allocator, create_seq_msg_id); app_msg_op_desc = axis2_msg_ctx_get_op(application_msg_ctx, env); property = axis2_msg_ctx_get_property(application_msg_ctx, env, AXIS2_TARGET_EPR); if(property) { temp_to = axutil_property_get_value(property, env); to_epr = axis2_endpoint_ref_create(env, axis2_endpoint_ref_get_address(temp_to, env)); } if (!to_epr) { temp_to = sandesha2_msg_ctx_get_to(application_rm_msg, env); if (temp_to) { to_epr = axis2_endpoint_ref_create(env, axis2_endpoint_ref_get_address(temp_to, env)); } } if (to_epr) { axis2_msg_ctx_set_to(create_seq_msg_ctx, env, to_epr); to_epr = NULL; } temp_reply_to = sandesha2_msg_ctx_get_reply_to(application_rm_msg, env); if(temp_reply_to) { axis2_endpoint_ref_t *reply_to_epr = NULL; reply_to_address = axis2_endpoint_ref_get_address(temp_reply_to, env); reply_to_epr = axis2_endpoint_ref_create(env, reply_to_address); if(reply_to_epr) { axis2_msg_ctx_set_reply_to(create_seq_msg_ctx, env, reply_to_epr); } } create_seq_rm_msg = sandesha2_msg_ctx_create(env, create_seq_msg_ctx); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "create_seq_internal_seq_id:%s", internal_seq_id); rm_version = sandesha2_utils_get_rm_version(env, application_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); addressing_ns_value = sandesha2_utils_get_seq_property(env, internal_seq_id, SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, seq_prop_mgr); create_seq_part = sandesha2_create_seq_create(env, addressing_ns_value, rm_ns_value); if(!create_seq_part) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] creating create sequence message failed"); return NULL; } /* Adding sequence offer if present */ op_ctx = axis2_msg_ctx_get_op_ctx(application_msg_ctx, env); if(op_ctx) { axis2_op_t *operation = NULL; int mep = -1; axis2_char_t *offered_seq_id = NULL; /*axutil_property_t *property = NULL; axis2_ctx_t *ctx = NULL; ctx = axis2_msg_ctx_get_base(application_msg_ctx, env); property = axis2_ctx_get_property(ctx, env, SANDESHA2_CLIENT_OFFERED_SEQ_ID); if(property) { offered_seq_id = axutil_property_get_value(property, env); }*/ operation = axis2_op_ctx_get_op(op_ctx, env); mep = axis2_op_get_axis_specific_mep_const(operation, env); if(mep == AXIS2_MEP_CONSTANT_OUT_IN) { offered_seq_id = axutil_uuid_gen(env); } /*if(offered_seq_id && 0 != axutil_strcmp("", offered_seq_id))*/ if(offered_seq_id) { sandesha2_seq_offer_t *offer_part = NULL; sandesha2_identifier_t *identifier = NULL; sandesha2_endpoint_t *endpoint = NULL; offer_part = sandesha2_seq_offer_create(env, rm_ns_value, addressing_ns_value); identifier = sandesha2_identifier_create(env, rm_ns_value); sandesha2_identifier_set_identifier(identifier, env, offered_seq_id); sandesha2_seq_offer_set_identifier(offer_part, env, identifier); if(!axutil_strcmp(SANDESHA2_SPEC_VERSION_1_1, rm_version)) { axis2_endpoint_ref_t *reply_to_epr = NULL; sandesha2_address_t *address = NULL; reply_to_epr = axis2_endpoint_ref_create(env, reply_to_address); address = sandesha2_address_create(env, addressing_ns_value, reply_to_epr); endpoint = sandesha2_endpoint_create(env, address, rm_ns_value, addressing_ns_value); sandesha2_seq_offer_set_endpoint(offer_part, env, endpoint); } sandesha2_create_seq_set_seq_offer(create_seq_part, env, offer_part); } } reply_to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_seq_id, SANDESHA2_SEQ_PROP_REPLY_TO_EPR); to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_seq_id, SANDESHA2_SEQ_PROP_TO_EPR); if (to_bean) { temp_value = sandesha2_seq_property_bean_get_value(to_bean, env); if (temp_value) { to_epr = axis2_endpoint_ref_create(env, temp_value); } sandesha2_seq_property_bean_free(to_bean, env); } anonymous_uri = sandesha2_spec_specific_consts_get_anon_uri(env, addressing_ns_value); if(reply_to_bean) { axis2_endpoint_ref_t *reply_to_epr = NULL; temp_value = sandesha2_seq_property_bean_get_value(reply_to_bean, env); if(temp_value) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "dam_reply_to:%s", temp_value); reply_to_epr = axis2_endpoint_ref_create(env, temp_value); acks_to = axutil_strdup(env, temp_value); } if(reply_to_epr) { sandesha2_msg_ctx_set_reply_to(create_seq_rm_msg, env, reply_to_epr); } sandesha2_seq_property_bean_free(reply_to_bean, env); } if(!acks_to || !axutil_strcmp("", acks_to)) { acks_to = axutil_strdup(env, anonymous_uri); } acks_to_epr = axis2_endpoint_ref_create(env, acks_to); temp_to = sandesha2_msg_ctx_get_to(create_seq_rm_msg, env); if(!temp_to && to_epr) { sandesha2_msg_ctx_set_to(create_seq_rm_msg, env, to_epr); } else { axis2_endpoint_ref_free(to_epr, env); } temp_address = sandesha2_address_create(env, addressing_ns_value, acks_to_epr); temp_acks_to = sandesha2_acks_to_create(env, temp_address, rm_ns_value, addressing_ns_value); if(addressing_ns_value) { AXIS2_FREE(env->allocator, addressing_ns_value); } sandesha2_create_seq_set_acks_to(create_seq_part, env, temp_acks_to); sandesha2_msg_ctx_set_create_seq(create_seq_rm_msg, env, create_seq_part); sandesha2_msg_ctx_add_soap_envelope(create_seq_rm_msg, env); temp_action = sandesha2_spec_specific_consts_get_create_seq_action(env, rm_version); sandesha2_msg_ctx_set_wsa_action(create_seq_rm_msg, env, temp_action); temp_soap_action = axutil_string_create(env, temp_action); if(temp_soap_action) { sandesha2_msg_ctx_set_soap_action(create_seq_rm_msg, env, temp_soap_action); axutil_string_free(temp_soap_action, env); } /*sandesha2_msg_creator_finalize_creation(env, application_msg_ctx, create_seq_msg_ctx);*/ return create_seq_rm_msg; }