static void WSF_UNIT_CALL test_axutil_uuid_gen_create(wsf_unit_test_case_t *tc, void *data) { axutil_env_t *env = NULL; axutil_test_data_t *test_data = (axutil_test_data_t *)data; char *uuid1 = NULL; char *uuid2 = NULL; WSF_UNIT_ASSERT_NOT_NULL(tc, "Test Data Unavailable", test_data); WSF_UNIT_ASSERT_NOT_NULL(tc, "Test Environment Unavailable", test_data->test_env); env = test_data->test_env; uuid1 = axutil_uuid_gen(env); WSF_UNIT_ASSERT_NOT_NULL(tc, "UUID Create Failed", uuid1); uuid2 = axutil_uuid_gen(env); WSF_UNIT_ASSERT_NOT_NULL(tc, "UUID Create Failed", uuid2); if (uuid1 && uuid2) { WSF_UNIT_ASSERT_NOT_EQUALS_STRING(tc, "UUID Not Unique", uuid1, uuid2); } if (uuid1) { AXIS2_FREE(env->allocator, uuid1); } if (uuid2) { AXIS2_FREE(env->allocator, uuid2); } }
void test_uuid_gen( const axutil_env_t * env) { char *uuid = NULL; printf("starting uuid_gen test...\n"); uuid = axutil_uuid_gen(env); printf("Generated UUID 1:%s\n", uuid); AXIS2_FREE(env->allocator, uuid); uuid = axutil_uuid_gen(env); printf("Generated UUID 2:%s\n", uuid); AXIS2_FREE(env->allocator, uuid); printf("finished uuid_gen test...\n"); }
AXIS2_EXTERN axis2_char_t *AXIS2_CALL axiom_output_get_root_content_id( axiom_output_t * om_output, const axutil_env_t * env) { axis2_char_t *temp_str = NULL; axis2_char_t *uuid = NULL; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, om_output, NULL); if(!om_output->root_content_id) { uuid = axutil_uuid_gen(env); temp_str = axutil_stracat(env, "0.", uuid); om_output->root_content_id = axutil_stracat(env, temp_str, "@apache.org"); if(temp_str) { AXIS2_FREE(env->allocator, temp_str); temp_str = NULL; } if(uuid) { AXIS2_FREE(env->allocator, uuid); uuid = NULL; } } return om_output->root_content_id; }
static void xmpp_process_msg( axis2_xmpp_session_data_t *session, iks *node) { iks *t = NULL; session->features = iks_stream_features(node); /* save features */ if(session->features & IKS_STREAM_BIND) { t = iks_make_resource_bind(session->jid); iks_send(session->parser, t); iks_delete(t); } /* Send a session if required */ if(session->features & IKS_STREAM_SESSION) { t = iks_make_session(); iks_insert_attrib(t, "id", "auth"); iks_send(session->parser, t); iks_delete(t); } /* Subscribe if the service is configured to do so */ if((session->subscribe) && (session->subscribe_to)) { /* Check whether the type of subscription is user or room * and send the subscription request accordingly */ if(!axutil_strcmp(session->subscribe_type, AXIS2_XMPP_SUB_TYPE_USER)) { iks_send(session->parser, iks_make_s10n(IKS_TYPE_SUBSCRIBE, session->subscribe_to, "")); } else if(!axutil_strcmp(session->subscribe_type, AXIS2_XMPP_SUB_TYPE_ROOM)) { axis2_char_t *id = axutil_uuid_gen(session->env); iks *x = iks_make_pres(IKS_SHOW_AVAILABLE, ""); iks_insert_attrib(x, "to", session->subscribe_to); iks_insert_attrib(x, "id", id); iks_send(session->parser, x); AXIS2_FREE(session->env->allocator, id); } else { AXIS2_LOG_ERROR(session->env->log, AXIS2_LOG_SI, "[xmpp]Unknown subscription type. No subscription done"); } } }
AXIS2_EXTERN axis2_char_t* AXIS2_CALL axis2_amqp_util_conf_ctx_get_dual_channel_queue_name( axis2_conf_ctx_t* conf_ctx, const axutil_env_t* env) { axutil_property_t* property = NULL; axis2_char_t* queue_name = NULL; axis2_char_t* value = NULL; /* Get property */ property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_QUEUE_NAME); if(!property) /* Very first call */ { property = axutil_property_create(env); axis2_conf_ctx_set_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_QUEUE_NAME, property); } /* Get queue name */ value = (axis2_char_t*)axutil_property_get_value(property, env); /* AMQP listener and the sender are the two parties that are * interested in the queue. Either party can create the queue. * If the queue is already created by one party, "value" is * not NULL. If "value" is NULL, that mean the caller of * this method is supposed to create the queue */ if(value) { queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator, axutil_strlen(value) + 1); strcpy(queue_name, value); /*axutil_property_set_value(property, env, NULL);*/ } else { /* Create new queue name */ queue_name = axutil_stracat(env, AXIS2_AMQP_TEMP_QUEUE_NAME_PREFIX, axutil_uuid_gen(env)); /* Put queue name in the conf_ctx so that the sender will know */ axutil_property_set_value(property, env, (void*)queue_name); } return queue_name; }
AXIS2_EXTERN axis2_char_t *AXIS2_CALL axiom_output_get_next_content_id( axiom_output_t * om_output, const axutil_env_t * env) { axis2_char_t *uuid = NULL; axis2_char_t *temp_str = NULL; axis2_char_t *temp_str1 = NULL; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, om_output, NULL); axis2_char_t id[256]; om_output->next_id++; /** free existing id */ if(om_output->next_content_id) { AXIS2_FREE(env->allocator, om_output->next_content_id); om_output->next_content_id = NULL; } uuid = axutil_uuid_gen(env); if(!uuid) { return NULL; } sprintf(id, "%d", om_output->next_id); temp_str = axutil_stracat(env, id, "."); temp_str1 = axutil_stracat(env, temp_str, uuid); om_output->next_content_id = axutil_stracat(env, temp_str1, "@apache.org"); if(temp_str) { AXIS2_FREE(env->allocator, temp_str); temp_str = NULL; } if(temp_str1) { AXIS2_FREE(env->allocator, temp_str1); temp_str1 = NULL; } AXIS2_FREE(env->allocator, uuid); return om_output->next_content_id; }
/* Generates an id for an element. * Specially used in xml encryption and signature references. * */ AXIS2_EXTERN axis2_char_t* AXIS2_CALL oxs_util_generate_id(const axutil_env_t *env, axis2_char_t *prefix) { axis2_char_t *id = NULL; char _id[50]; axis2_char_t *random ; axis2_char_t *uuid = NULL; uuid = axutil_uuid_gen(env); random = axutil_strndup(env, uuid, 23); sprintf(_id, "%s-%s", prefix, random); id = (axis2_char_t*)axutil_strdup(env, _id); AXIS2_FREE(env->allocator, uuid); AXIS2_FREE(env->allocator, random); random = NULL; return id; }
AXIS2_EXTERN axis2_char_t *AXIS2_CALL axiom_output_get_mime_boundry( axiom_output_t * om_output, const axutil_env_t * env) { axis2_char_t *uuid = NULL; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, om_output, NULL); if(!om_output->mime_boundary) { uuid = axutil_uuid_gen(env); om_output->mime_boundary = axutil_stracat(env, "MIMEBoundary", uuid); if(uuid) { AXIS2_FREE(env->allocator, uuid); uuid = NULL; } } return om_output->mime_boundary; }
AXIS2_EXTERN axis2_char_t * AXIS2_CALL saml_id_generate_random_bytes(const axutil_env_t *env) { return axutil_uuid_gen(env); }
/** * 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; }
/** * Create a new create_terminate_seq_msg * @param env * @param ref_rm_msg * @param seq_id * @param internal_seq_id * @param seq_prop_mgr * @return */ sandesha2_msg_ctx_t *AXIS2_CALL sandesha2_msg_creator_create_terminate_seq_msg( const axutil_env_t *env, sandesha2_msg_ctx_t *ref_rm_msg, axis2_char_t *seq_id, axis2_char_t *internal_seq_id, sandesha2_seq_property_mgr_t *seq_prop_mgr) { axis2_msg_ctx_t *ref_msg_ctx = NULL; axis2_msg_ctx_t *terminate_seq_msg_ctx = NULL; axis2_conf_ctx_t *conf_ctx = NULL; axis2_char_t *terminate_seq_msg_id = NULL; axis2_char_t *temp_msg_id = NULL; axis2_char_t *rm_version = NULL; axis2_char_t *rm_ns_value = NULL; axis2_bool_t is_seq_res_reqd = AXIS2_FALSE; axiom_soap_envelope_t *temp_envelope = NULL; sandesha2_msg_ctx_t *terminate_rm_msg = NULL; sandesha2_terminate_seq_t *terminate_seq = NULL; int soap_version = -1; sandesha2_identifier_t *identifier = NULL; sandesha2_last_msg_number_t *last_msg_number = NULL; sandesha2_seq_property_bean_t *last_out_msg_no_bean = NULL; ref_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(ref_rm_msg, env); /*axis2_msg_ctx_set_keep_alive(ref_msg_ctx, env, AXIS2_TRUE);*/ if(!ref_msg_ctx) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_NULL_MSG_CTX, AXIS2_FAILURE); return NULL; } conf_ctx = axis2_msg_ctx_get_conf_ctx(ref_msg_ctx, env); if(!conf_ctx) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CONF_CTX_NULL, AXIS2_FAILURE); return NULL; } terminate_seq_msg_ctx = sandesha2_utils_create_new_related_msg_ctx(env, ref_rm_msg); terminate_seq_msg_id = (axis2_char_t*)axis2_msg_ctx_get_msg_id( terminate_seq_msg_ctx, env); rm_version = sandesha2_utils_get_rm_version(env, ref_msg_ctx); if(!rm_version) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_RM_VERSION_OF_GIVEN_MSG, AXIS2_FAILURE); return NULL; } rm_ns_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, rm_version); sandesha2_msg_creator_init_creation(env, ref_msg_ctx, terminate_seq_msg_ctx); is_seq_res_reqd = sandesha2_spec_specific_consts_is_term_seq_res_reqd(env, rm_version); if(!is_seq_res_reqd) { axis2_msg_ctx_set_property(terminate_seq_msg_ctx, env, AXIS2_TRANSPORT_IN, NULL); } terminate_rm_msg = sandesha2_msg_init_init_msg(env, terminate_seq_msg_ctx); if(!terminate_rm_msg) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_NULL_MSG_CTX, AXIS2_FAILURE); return NULL; } temp_msg_id = axutil_uuid_gen(env); axis2_msg_ctx_set_message_id(terminate_seq_msg_ctx, env, temp_msg_id); AXIS2_FREE(env->allocator, temp_msg_id); temp_envelope = sandesha2_msg_ctx_get_soap_envelope(ref_rm_msg, env); soap_version = sandesha2_utils_get_soap_version(env, temp_envelope); terminate_seq = sandesha2_terminate_seq_create(env, rm_ns_value); identifier = sandesha2_identifier_create(env, rm_ns_value); sandesha2_identifier_set_identifier(identifier, env, seq_id); sandesha2_terminate_seq_set_identifier(terminate_seq, env, identifier); sandesha2_msg_ctx_set_terminate_seq(terminate_rm_msg, env, terminate_seq); if(is_seq_res_reqd) { last_out_msg_no_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_seq_id, SANDESHA2_SEQ_PROP_LAST_OUT_MESSAGE_NUMBER); } if(last_out_msg_no_bean) { axis2_char_t *msg_no_str = NULL; long last_msg_num = -1; msg_no_str = sandesha2_seq_property_bean_get_value(last_out_msg_no_bean, env); if(msg_no_str) { last_msg_num = atol(msg_no_str); } last_msg_number = sandesha2_last_msg_number_create(env, rm_ns_value); if(last_msg_number) { sandesha2_last_msg_number_set_last_msg_number(last_msg_number, env, last_msg_num); sandesha2_terminate_seq_set_last_msg_number(terminate_seq, env, last_msg_number); } sandesha2_seq_property_bean_free(last_out_msg_no_bean, env); } sandesha2_msg_creator_finalize_creation(env, ref_msg_ctx, terminate_seq_msg_ctx); axis2_msg_ctx_set_property(terminate_seq_msg_ctx, env, AXIS2_TRANSPORT_IN, NULL); return terminate_rm_msg; }
/** * Create a new create_seq_response message. * @param env axis2 environment struct * @param create_seq_msg * @param out_msg * @param new_seq_id * @param seq_prop_mgr * @return sandesha2_msg_ctx_t */ sandesha2_msg_ctx_t * sandesha2_msg_creator_create_create_seq_res_msg( const axutil_env_t *env, sandesha2_msg_ctx_t *create_seq_msg, axis2_msg_ctx_t *out_msg, axis2_char_t *new_seq_id, sandesha2_seq_property_mgr_t *seq_prop_mgr) { axis2_conf_ctx_t *conf_ctx = NULL; axis2_msg_ctx_t *temp_msg_ctx = NULL; axis2_char_t *rm_version = NULL; axis2_char_t *rm_ns_value = NULL; axis2_char_t *addressing_ns_value = NULL; axis2_char_t *new_msg_id = NULL; axis2_char_t *temp_action = NULL; axutil_string_t *soap_action = NULL; axiom_soap_envelope_t *envelope = NULL; axiom_soap_envelope_t *temp_envelope = NULL; axiom_soap_body_t *temp_soap_body = NULL; axiom_node_t *temp_om_node = NULL; sandesha2_create_seq_res_t *create_seq_res = NULL; sandesha2_identifier_t *identifier = NULL; sandesha2_seq_offer_t *offer = NULL; sandesha2_msg_ctx_t *create_seq_res_rm_msg_ctx = NULL; sandesha2_create_seq_t *cs = NULL; int soap_version = -1; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_msg_creator_create_create_seq_res_msg"); temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); conf_ctx = axis2_msg_ctx_get_conf_ctx(temp_msg_ctx, env); cs = sandesha2_msg_ctx_get_create_seq(create_seq_msg, env); rm_version = sandesha2_utils_get_rm_version(env, temp_msg_ctx); if(!rm_version) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find rm version of given message"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_RM_VERSION_OF_GIVEN_MSG, AXIS2_FAILURE); return NULL; } rm_ns_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, rm_version); addressing_ns_value = sandesha2_utils_get_seq_property(env, new_seq_id, SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, seq_prop_mgr); if(!addressing_ns_value) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find addressing namespace value"); return NULL; } create_seq_res = sandesha2_create_seq_res_create(env, rm_ns_value, addressing_ns_value); identifier = sandesha2_identifier_create(env, rm_ns_value); sandesha2_identifier_set_identifier(identifier, env, new_seq_id); sandesha2_create_seq_res_set_identifier(create_seq_res, env, identifier); offer = sandesha2_create_seq_get_seq_offer(cs, env); if(offer) { axis2_char_t *out_seq_id = NULL; sandesha2_identifier_t *temp_identifier = NULL; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Offer present"); temp_identifier = sandesha2_seq_offer_get_identifier(offer, env); out_seq_id = sandesha2_identifier_get_identifier(temp_identifier, env); if(out_seq_id && axutil_strcmp("", out_seq_id)) { sandesha2_accept_t *accept = NULL; axis2_endpoint_ref_t *acks_to_epr = NULL; sandesha2_acks_to_t *acks_to = NULL; sandesha2_address_t *address = NULL; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] out_seq_id present"); accept = sandesha2_accept_create(env, rm_ns_value, addressing_ns_value); if(accept) { axis2_endpoint_ref_t *temp_to_epr = NULL; acks_to_epr = sandesha2_msg_ctx_get_to(create_seq_msg, env); if(acks_to_epr) { temp_to_epr = sandesha2_util_endpoint_ref_clone(env, acks_to_epr); } address = sandesha2_address_create(env, addressing_ns_value, temp_to_epr); acks_to = sandesha2_acks_to_create(env, address, rm_ns_value, addressing_ns_value); sandesha2_accept_set_acks_to(accept, env, acks_to); sandesha2_create_seq_res_set_accept(create_seq_res, env, accept); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Could not create accept element"); return NULL; } } } temp_envelope = sandesha2_msg_ctx_get_soap_envelope(create_seq_msg, env); soap_version = sandesha2_utils_get_soap_version(env, temp_envelope); envelope = axiom_soap_envelope_create_default_soap_envelope(env, soap_version); temp_soap_body = axiom_soap_envelope_get_body(envelope, env); temp_om_node = axiom_soap_body_get_base_node(temp_soap_body, env); sandesha2_create_seq_res_to_om_node(create_seq_res, env, temp_om_node); temp_action = sandesha2_spec_specific_consts_get_create_seq_res_action(env, rm_version); axis2_msg_ctx_set_wsa_action(out_msg, env, temp_action); soap_action = axutil_string_create(env, temp_action); /*if(soap_action) { axis2_msg_ctx_set_soap_action(out_msg, env, soap_action); axutil_string_free(soap_action, env); }*/ if(addressing_ns_value) { AXIS2_FREE(env->allocator, addressing_ns_value); } new_msg_id = axutil_uuid_gen(env); if(new_msg_id) { axis2_msg_ctx_set_message_id(out_msg, env, new_msg_id); AXIS2_FREE(env->allocator, new_msg_id); } axis2_msg_ctx_set_soap_envelope(out_msg, env, envelope); temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); sandesha2_msg_creator_init_creation(env, temp_msg_ctx, out_msg); create_seq_res_rm_msg_ctx = sandesha2_msg_init_init_msg(env, out_msg); sandesha2_msg_ctx_set_create_seq_res(create_seq_res_rm_msg_ctx, env, create_seq_res); temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); sandesha2_msg_creator_finalize_creation(env, temp_msg_ctx, out_msg); axis2_msg_ctx_set_server_side(temp_msg_ctx, env, AXIS2_TRUE); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Exit:sandesha2_msg_creator_create_create_seq_res_msg"); return create_seq_res_rm_msg_ctx; }
sandesha2_msg_ctx_t *AXIS2_CALL sandesha2_msg_creator_create_make_connection_msg( const axutil_env_t *env, sandesha2_msg_ctx_t *ref_rm_msg_ctx, axis2_char_t *make_conn_seq_id, const axis2_char_t *internal_seq_id, axis2_char_t *make_conn_anon_uri, sandesha2_seq_property_mgr_t *seq_prop_mgr) { axis2_msg_ctx_t *ref_msg_ctx = NULL; axis2_msg_ctx_t *make_conn_msg_ctx = NULL; axis2_char_t *rm_ns_value = NULL; axis2_char_t *mc_ns_value = NULL; axis2_char_t *wsa_action = NULL; sandesha2_make_connection_t *make_conn = NULL; sandesha2_msg_ctx_t *make_conn_rm_msg_ctx = NULL; rm_ns_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, SANDESHA2_SPEC_VERSION_1_1); mc_ns_value = MAKE_CONNECTION_SPEC_2007_02_NS_URI; if(ref_rm_msg_ctx) { ref_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(ref_rm_msg_ctx, env); } make_conn_msg_ctx = sandesha2_utils_create_new_related_msg_ctx(env, ref_rm_msg_ctx); if(make_conn_msg_ctx) { make_conn_rm_msg_ctx = sandesha2_msg_init_init_msg(env, make_conn_msg_ctx); } /* This if block is an hack to add the addressing handlers to the outflow. * Check whether this is not a hack */ /*if(ref_msg_ctx) { axis2_op_t *op = axis2_msg_ctx_get_op(ref_msg_ctx, env); axis2_op_t *make_conn_op = axis2_msg_ctx_get_op(make_conn_msg_ctx, env); axutil_array_list_t *out_flow = axis2_op_get_out_flow(op, env); axutil_array_list_t *in_flow = axis2_op_get_in_flow(op, env); int size = axutil_array_list_size(out_flow, env); if(size > 0) { int i = 0; axutil_array_list_t *new_flow = axutil_array_list_create(env, 0); for(i = 0; i < size; i++) { const axis2_phase_t *phase = axutil_array_list_get(out_flow, env, i); const axis2_char_t *phase_name = axis2_phase_get_name(phase, env); if(0 == axutil_strcmp(phase_name, AXIS2_PHASE_MESSAGE_OUT)) { axutil_array_list_add(new_flow, env, phase); } } axis2_op_set_out_flow(make_conn_op, env, new_flow); } size = axutil_array_list_size(in_flow, env); if(size > 0) { int i = 0; axutil_array_list_t *new_flow = axutil_array_list_create(env, 0); for(i = 0; i < size; i++) { const axis2_phase_t *phase = axutil_array_list_get(in_flow, env, i); const axis2_char_t *phase_name = axis2_phase_get_name(phase, env); if(0 == axutil_strcmp(phase_name, "RMPhase")) { axutil_array_list_add(new_flow, env, phase); } } axis2_op_set_in_flow(make_conn_op, env, new_flow); } }*/ make_conn = sandesha2_make_connection_create(env, mc_ns_value); if(make_conn_seq_id) { sandesha2_identifier_t *identifier = sandesha2_identifier_create(env, rm_ns_value); if(identifier) sandesha2_identifier_set_identifier(identifier, env, make_conn_seq_id); if(make_conn) sandesha2_make_connection_set_identifier(make_conn, env, identifier); } if(make_conn_anon_uri) { sandesha2_mc_address_t *address = NULL; axis2_endpoint_ref_t *epr = NULL; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] make_conn_anon_uri:%s", make_conn_anon_uri); address = sandesha2_mc_address_create(env, mc_ns_value, NULL); epr = axis2_endpoint_ref_create(env, make_conn_anon_uri); if(address) { sandesha2_mc_address_set_epr(address, env, epr); } if(make_conn) { sandesha2_make_connection_set_address(make_conn, env, address); } } if(make_conn_msg_ctx) { axis2_endpoint_ref_t *to = NULL; axis2_endpoint_ref_t *reply_to = NULL; axis2_char_t *address = NULL; axutil_string_t *soap_action = NULL; /* Setting the addressing properties */ to = axis2_msg_ctx_get_to(ref_msg_ctx, env); address = (axis2_char_t *) axis2_endpoint_ref_get_address((const axis2_endpoint_ref_t *) to, env); to = axis2_endpoint_ref_create(env, address); axis2_msg_ctx_set_to(make_conn_msg_ctx, env, to); reply_to = axis2_endpoint_ref_create(env, AXIS2_WSA_ANONYMOUS_URL); axis2_msg_ctx_set_reply_to(make_conn_msg_ctx, env, reply_to); wsa_action = sandesha2_spec_specific_consts_get_make_connection_action(env, SANDESHA2_SPEC_VERSION_1_1); axis2_msg_ctx_set_wsa_action(make_conn_msg_ctx, env, wsa_action); soap_action = axutil_string_create(env, wsa_action); axis2_msg_ctx_set_soap_action(make_conn_msg_ctx, env, soap_action); axis2_msg_ctx_set_message_id(make_conn_msg_ctx, env, axutil_uuid_gen(env)); sandesha2_msg_ctx_set_make_connection(make_conn_rm_msg_ctx, env, make_conn); /* Generating the soap envelope */ sandesha2_msg_ctx_add_soap_envelope(make_conn_rm_msg_ctx, env); return make_conn_rm_msg_ctx; } return NULL; }
/** * 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; }
int main(int argc, char** argv) { const axutil_env_t *env = NULL; const axis2_char_t *address = NULL; axis2_endpoint_ref_t* endpoint_ref = NULL; axis2_endpoint_ref_t* reply_to = NULL; axis2_options_t *options = NULL; const axis2_char_t *client_home = NULL; axis2_svc_client_t* svc_client = NULL; axiom_node_t *payload = NULL; axutil_property_t *property = NULL; axis2_listener_manager_t *listener_manager = NULL; axis2_char_t *offered_seq_id = NULL; axis2_status_t status = AXIS2_FAILURE; axiom_node_t *result = NULL; neethi_policy_t *policy = NULL; /* Set up the environment */ env = axutil_env_create_all("rm_echo_single_1_1_amqp.log", AXIS2_LOG_LEVEL_TRACE); /* Set end point reference of echo service */ address = "amqp://127.0.0.1:5672/axis2/services/RM11SampleService"; if (argc > 1) { if (axutil_strcmp(argv[1], "-h") == 0) { printf("Usage : %s [endpoint_url]\n", argv[0]); printf("use -h for help\n"); return 0; } else { address = argv[1]; } } printf ("Using endpoint : %s\n", address); /* Create EPR with given address */ endpoint_ref = axis2_endpoint_ref_create(env, address); /* Setup options */ options = axis2_options_create(env); axis2_options_set_to(options, env, endpoint_ref); /* Seperate listner needs addressing, hence addressing stuff in options */ axis2_options_set_action(options, env, "http://127.0.0.1:8080/axis2/services/RM11SampleService/anonOutInOp"); reply_to = axis2_endpoint_ref_create(env, AXIS2_WSA_ANONYMOUS_URL); axis2_options_set_reply_to(options, env, reply_to); /* Set up deploy folder. It is from the deploy folder, the configuration is * picked up using the axis2.xml file. * In this sample client_home points to the Axis2/C default deploy folder. * The client_home can be different from this folder on your system. For * example, you may have a different folder (say, my_client_folder) with its * own axis2.xml file. my_client_folder/modules will have the modules that * the client uses */ client_home = AXIS2_GETENV("AXIS2C_HOME"); if (!client_home) { client_home = "../../.."; } /* Create service client */ svc_client = axis2_svc_client_create(env, client_home); if (!svc_client) { printf("Error creating service client\n"); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code:%d :: %s", env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error)); return -1; } policy = neethi_util_create_policy_from_file(env, "../policy/rm11-policy.xml"); if(!policy) { printf("\nPolicy creation failed from the file"); return 0; } status = axis2_svc_client_set_policy(svc_client, env, policy); if(status == AXIS2_FAILURE) { printf("Policy setting failed\n"); } /* Set service client options */ axis2_svc_client_set_options(svc_client, env, options); axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); axis2_svc_client_engage_module(svc_client, env, "sandesha2"); listener_manager = axis2_listener_manager_create(env); if (!listener_manager) { return AXIS2_FAILURE; } /* Offer sequence */ offered_seq_id = axutil_uuid_gen(env); property = axutil_property_create(env); if(property) { axutil_property_set_value(property, env, axutil_strdup(env, offered_seq_id)); axis2_options_set_property(options, env, SANDESHA2_CLIENT_OFFERED_SEQ_ID, property); } /* RM Version 1.1 */ property = axutil_property_create_with_args(env, 3, 0, 0, SANDESHA2_SPEC_VERSION_1_1); if(property) { axis2_options_set_property(options, env, SANDESHA2_CLIENT_RM_SPEC_VERSION, property); } payload = build_om_payload_for_echo_svc(env, "echo1"); /*status = axis2_svc_client_send_robust(svc_client, env, payload); if(status) { printf("\necho client single channel invoke SUCCESSFUL!\n"); } payload = NULL;*/ result = axis2_svc_client_send_receive(svc_client, env, payload); if(result) { axis2_char_t *om_str = NULL; om_str = axiom_node_to_string(result, env); if (om_str) { printf("\nReceived OM : %s\n", om_str); AXIS2_FREE(env->allocator, om_str); } printf("\necho client two way single channel invoke SUCCESSFUL!\n"); result = NULL; } else { printf("\necho client two way single channel invoke FAILED!\n"); } payload = build_om_payload_for_echo_svc(env, "echo2"); /*status = axis2_svc_client_send_robust(svc_client, env, payload); if(status) { printf("\necho client single channel invoke SUCCESSFUL!\n"); } payload = NULL;*/ result = axis2_svc_client_send_receive(svc_client, env, payload); if(result) { axis2_char_t *om_str = NULL; om_str = axiom_node_to_string(result, env); if (om_str) { printf("\nReceived OM : %s\n", om_str); AXIS2_FREE(env->allocator, om_str); } printf("\necho client two way single channel invoke SUCCESSFUL!\n"); result = NULL; } else { printf("\necho client two way single channel invoke FAILED!\n"); } payload = build_om_payload_for_echo_svc(env, "echo3"); /*status = axis2_svc_client_send_robust(svc_client, env, payload); if(status) { printf("\necho client single channel invoke SUCCESSFUL!\n"); } payload = NULL;*/ result = axis2_svc_client_send_receive(svc_client, env, payload); if(result) { axis2_char_t *om_str = NULL; om_str = axiom_node_to_string(result, env); if (om_str) { printf("\nReceived OM : %s\n", om_str); AXIS2_FREE(env->allocator, om_str); } printf("\necho client two way single channel invoke SUCCESSFUL!\n"); result = NULL; } else { printf("\necho client two way single channel invoke FAILED!\n"); } AXIS2_SLEEP(SANDESHA2_SLEEP); sandesha2_client_terminate_seq_with_svc_client_and_seq_key(env, svc_client, NULL, NULL); AXIS2_SLEEP(6 * SANDESHA2_SLEEP); if (svc_client) { axis2_svc_client_free(svc_client, env); svc_client = NULL; } return 0; }
static axis2_status_t AXIS2_CALL sandesha2_create_seq_res_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 *msg_ctx = NULL; axis2_conf_ctx_t *conf_ctx = NULL; sandesha2_storage_mgr_t *storage_mgr = NULL; sandesha2_create_seq_res_t *csr_part = NULL; axis2_char_t *outgoing_sequence_id = NULL; axis2_relates_to_t *relates_to = NULL; axis2_char_t *create_seq_msg_id = NULL; sandesha2_sender_mgr_t *sender_mgr = NULL; sandesha2_create_seq_mgr_t *create_seq_mgr = NULL; sandesha2_create_seq_bean_t *create_seq_bean = NULL; axis2_char_t *outgoing_internal_sequence_id = NULL; sandesha2_seq_property_mgr_t *seq_prop_mgr = NULL; sandesha2_seq_property_bean_t *outgoing_sequence_bean = NULL; sandesha2_seq_property_bean_t *outgoing_internal_sequence_bean = NULL; sandesha2_accept_t *accept = NULL; axis2_op_ctx_t *op_ctx = NULL; axis2_bool_t polling_mode = AXIS2_FALSE; axis2_char_t *dbname = NULL; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_create_seq_res_msg_processor_process_in_msg"); AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE); msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, 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; } csr_part = sandesha2_msg_ctx_get_create_seq_res(rm_msg_ctx, env); if(!csr_part) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Create Sequence Response part is null"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING, AXIS2_FAILURE); if(storage_mgr) { sandesha2_storage_mgr_free(storage_mgr, env); } return AXIS2_FAILURE; } outgoing_sequence_id = sandesha2_identifier_get_identifier( sandesha2_create_seq_res_get_identifier(csr_part, env), env); if(!outgoing_sequence_id) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Out going sequence id is null"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_SEQ_ID, AXIS2_FAILURE); if(storage_mgr) { sandesha2_storage_mgr_free(storage_mgr, env); } return AXIS2_FAILURE; } relates_to = axis2_msg_ctx_get_relates_to(msg_ctx, env); if(!relates_to) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Invalid create sequence message. relates_to part is not available"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_INVALID_RELATES_TO, AXIS2_FAILURE); if(storage_mgr) { sandesha2_storage_mgr_free(storage_mgr, env); } return AXIS2_FAILURE; } create_seq_msg_id = (axis2_char_t *) axis2_relates_to_get_value(relates_to, env); 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); create_seq_bean = sandesha2_create_seq_mgr_retrieve(create_seq_mgr, env, create_seq_msg_id); if(!create_seq_bean) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Create Sequence entry not found"); 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(storage_mgr) { sandesha2_storage_mgr_free(storage_mgr, env); } return AXIS2_FAILURE; } outgoing_internal_sequence_id = axutil_strdup(env, sandesha2_create_seq_bean_get_internal_sequence_id( create_seq_bean, env)); if(!outgoing_internal_sequence_id) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Internal sequence id is not set"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_SEQ_ID, AXIS2_FAILURE); sandesha2_create_seq_bean_free(create_seq_bean, env); 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(storage_mgr) { sandesha2_storage_mgr_free(storage_mgr, env); } return AXIS2_FAILURE; } sandesha2_create_seq_bean_set_outgoing_sequence_id(create_seq_bean, env, outgoing_sequence_id); sandesha2_create_seq_mgr_update(create_seq_mgr, env, create_seq_bean); sandesha2_create_seq_bean_free(create_seq_bean, env); outgoing_sequence_bean = sandesha2_seq_property_bean_create_with_data(env, outgoing_internal_sequence_id, SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_SEQUENCE_ID, outgoing_sequence_id); if(outgoing_sequence_bean) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Inserting outgoing_sequence_bean with outgoing_sequence_id :%s and "\ "outgoing internal_sequence_id :%s", outgoing_sequence_id, outgoing_internal_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_with_data(env, outgoing_sequence_id, SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_INTERNAL_SEQUENCE_ID, outgoing_internal_sequence_id); if(outgoing_internal_sequence_bean) { sandesha2_sender_bean_t *find_sender_bean = NULL; sandesha2_sender_bean_t *sender_bean = NULL; find_sender_bean = sandesha2_sender_bean_create(env); sandesha2_sender_bean_set_msg_type(find_sender_bean, env, SANDESHA2_MSG_TYPE_CREATE_SEQ); sandesha2_sender_bean_set_internal_seq_id(find_sender_bean, env, outgoing_internal_sequence_id); sandesha2_sender_bean_set_send(find_sender_bean, env, AXIS2_TRUE); sender_bean = sandesha2_sender_mgr_find_unique(sender_mgr, env, find_sender_bean); if(sender_bean) { axis2_char_t *msg_id = NULL; msg_id = sandesha2_sender_bean_get_msg_id(sender_bean, env); sandesha2_sender_mgr_remove(sender_mgr, env, msg_id); sandesha2_sender_bean_free(sender_bean, env); } sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, outgoing_internal_sequence_bean); sandesha2_seq_property_bean_free(outgoing_internal_sequence_bean, env); } accept = sandesha2_create_seq_res_get_accept(csr_part, env); if(accept) { /*sandesha2_seq_property_bean_t *special_int_seq_bean = NULL;*/ sandesha2_seq_property_bean_t *offerd_seq_bean = NULL; axis2_char_t *incoming_sequence_id = NULL; axis2_endpoint_ref_t *acks_to_epr = NULL; axis2_endpoint_ref_t *to_epr = NULL; sandesha2_seq_property_bean_t *acks_to_bean = NULL; sandesha2_next_msg_bean_t *next_bean = NULL; sandesha2_next_msg_mgr_t *next_msg_mgr = NULL; sandesha2_seq_property_bean_t *rcvd_msg_bean = NULL; sandesha2_seq_property_bean_t *msgs_bean = NULL; sandesha2_seq_property_bean_t *addr_ver_bean = NULL; axis2_char_t *rm_spec_ver = NULL; axis2_char_t *addr_ns_val = NULL; axis2_char_t *new_msg_store_key = NULL; sandesha2_seq_property_bean_t *to_seq_bean = NULL; sandesha2_msg_ctx_t *create_seq_rm_msg = NULL; axis2_msg_ctx_t *create_seq_msg = NULL; axis2_char_t *acks_to = NULL; /* axis2_char_t *reply_to_addr = NULL; */ next_msg_mgr = sandesha2_permanent_next_msg_mgr_create(env, dbname); offerd_seq_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, outgoing_internal_sequence_id, SANDESHA2_SEQ_PROP_OFFERED_SEQ); if(!offerd_seq_bean) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] No offered sequence entry. But an accept was received"); if(outgoing_internal_sequence_id) { AXIS2_FREE(env->allocator, outgoing_internal_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(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_FAILURE; } incoming_sequence_id = axutil_strdup(env, sandesha2_seq_property_bean_get_value( offerd_seq_bean, env)); sandesha2_seq_property_bean_free(offerd_seq_bean, env); /*special_int_seq_bean = sandesha2_seq_property_bean_create_with_data(env, incoming_sequence_id, SANDESHA2_SEQ_PROP_SPECIAL_INTERNAL_SEQUENCE_ID, outgoing_internal_sequence_id); if(special_int_seq_bean) { sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, special_int_seq_bean); sandesha2_seq_property_bean_free(special_int_seq_bean, env); }*/ acks_to_epr = sandesha2_address_get_epr(sandesha2_acks_to_get_address( sandesha2_accept_get_acks_to(accept, env), env), env); acks_to_bean = sandesha2_seq_property_bean_create(env); if(acks_to_bean) { sandesha2_seq_property_bean_set_name(acks_to_bean, env, SANDESHA2_SEQ_PROP_ACKS_TO_EPR); sandesha2_seq_property_bean_set_seq_id(acks_to_bean, env, incoming_sequence_id); if (acks_to_epr) { sandesha2_seq_property_bean_set_value(acks_to_bean, env, (axis2_char_t*)axis2_endpoint_ref_get_address(acks_to_epr, env)); } sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, acks_to_bean); sandesha2_seq_property_bean_free(acks_to_bean, env); } rm_spec_ver = sandesha2_msg_ctx_get_rm_spec_ver(rm_msg_ctx, env); if(!axutil_strcmp(SANDESHA2_SPEC_VERSION_1_1, rm_spec_ver)) { /*reply_to_addr = sandesha2_utils_get_seq_property(env, internal_sequence_id, SANDESHA2_SEQ_PROP_REPLY_TO_EPR, seq_prop_mgr); if(reply_to_addr) { polling_mode = sandesha2_utils_is_anon_uri(env, reply_to_addr); }*/ } acks_to = (axis2_char_t *) axis2_endpoint_ref_get_address(acks_to_epr, env); create_seq_rm_msg = sandesha2_msg_creator_create_create_seq_msg(env, rm_msg_ctx, outgoing_internal_sequence_id, acks_to, seq_prop_mgr); if(!create_seq_rm_msg) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]create_seq_rm_msg is NULL"); /*if(reply_to_addr) { AXIS2_FREE(env->allocator, reply_to_addr); }*/ if(incoming_sequence_id) { AXIS2_FREE(env->allocator, incoming_sequence_id); } if(outgoing_internal_sequence_id) { AXIS2_FREE(env->allocator, outgoing_internal_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(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_FAILURE; } sandesha2_msg_ctx_set_flow(create_seq_rm_msg, env, SANDESHA2_MSG_CTX_OUT_FLOW); create_seq_msg = sandesha2_msg_ctx_get_msg_ctx(create_seq_rm_msg, env); to_seq_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, outgoing_internal_sequence_id, SANDESHA2_SEQ_PROP_TO_EPR); if(to_seq_bean) { axis2_char_t *to_addr = sandesha2_seq_property_bean_get_value(to_seq_bean, env); to_epr = axis2_endpoint_ref_create(env, to_addr); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]to:%s", to_addr); sandesha2_seq_property_bean_free(to_seq_bean, env); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] to_seq_bean is NULL"); /*if(reply_to_addr) { AXIS2_FREE(env->allocator, reply_to_addr); }*/ if(incoming_sequence_id) { AXIS2_FREE(env->allocator, incoming_sequence_id); } if(outgoing_internal_sequence_id) { AXIS2_FREE(env->allocator, outgoing_internal_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(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); } if(create_seq_msg) { axis2_msg_ctx_free(create_seq_msg, env); } if(create_seq_rm_msg) { sandesha2_msg_ctx_free(create_seq_rm_msg, env); } return AXIS2_FAILURE; } axis2_msg_ctx_set_to(create_seq_msg, env, to_epr); axis2_msg_ctx_set_relates_to(create_seq_msg, env, NULL); new_msg_store_key = axutil_uuid_gen(env); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]Storing msg_ctx with msg_id:%s", axis2_msg_ctx_get_msg_id(create_seq_msg, env)); sandesha2_storage_mgr_store_msg_ctx(storage_mgr, env, new_msg_store_key, create_seq_msg, AXIS2_TRUE); next_bean = sandesha2_next_msg_bean_create(env); sandesha2_next_msg_bean_set_seq_id(next_bean, env, incoming_sequence_id); sandesha2_next_msg_bean_set_internal_seq_id(next_bean, env, outgoing_internal_sequence_id); sandesha2_next_msg_bean_set_next_msg_no_to_process(next_bean, env, 1); sandesha2_next_msg_bean_set_ref_msg_key(next_bean, env, new_msg_store_key); sandesha2_next_msg_bean_set_polling_mode(next_bean, env, polling_mode); if(new_msg_store_key) { AXIS2_FREE(env->allocator, new_msg_store_key); } /* If polling_mode is true, starting the polling manager */ if(polling_mode) { /*sandesha2_polling_mgr_start(env, conf_ctx, storage_mgr, sender_mgr, create_seq_rm_msg, outgoing_internal_sequence_id, incoming_sequence_id, reply_to_addr);*/ } sandesha2_next_msg_mgr_insert(next_msg_mgr, env, next_bean); sandesha2_next_msg_bean_free(next_bean, env); rcvd_msg_bean = sandesha2_seq_property_bean_create_with_data(env, incoming_sequence_id, SANDESHA2_SEQ_PROP_SERVER_COMPLETED_MESSAGES, ""); if(rcvd_msg_bean) { sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, rcvd_msg_bean); sandesha2_seq_property_bean_free(rcvd_msg_bean, env); } msgs_bean = sandesha2_seq_property_bean_create_with_data(env, incoming_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); } addr_ns_val = sandesha2_msg_ctx_get_addr_ns_val(rm_msg_ctx, env); addr_ver_bean = sandesha2_seq_property_bean_create_with_data(env, incoming_sequence_id, SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, addr_ns_val); if(addr_ver_bean) { sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, addr_ver_bean); sandesha2_seq_property_bean_free(addr_ver_bean, env); } if(create_seq_msg) { axis2_core_utils_reset_out_msg_ctx(env, create_seq_msg); axis2_msg_ctx_free(create_seq_msg, env); } /*if(reply_to_addr) { AXIS2_FREE(env->allocator, reply_to_addr); }*/ if(create_seq_rm_msg) { sandesha2_msg_ctx_free(create_seq_rm_msg, env); } if(next_msg_mgr) { sandesha2_next_msg_mgr_free(next_msg_mgr, env); } if(incoming_sequence_id) { AXIS2_FREE(env->allocator, incoming_sequence_id); } } /* End of if accept block */ sandesha2_seq_mgr_update_last_activated_time(env, outgoing_internal_sequence_id, seq_prop_mgr); op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env); axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_TRUE); /* 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(outgoing_internal_sequence_id) { AXIS2_FREE(env->allocator, outgoing_internal_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(sender_mgr) { sandesha2_sender_mgr_free(sender_mgr, env); } if(storage_mgr) { sandesha2_storage_mgr_free(storage_mgr, env); } AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Exit:sandesha2_create_seq_res_msg_processor_process_in_msg"); return AXIS2_SUCCESS; }
int add_subscriber() { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; axis2_char_t *subscription_id = NULL; axis2_char_t *id = NULL; axis2_char_t *path = NULL; axis2_char_t *index_path = NULL; remote_registry_resource_t *res = NULL; axutil_hash_t *properties = NULL; char *content = (char *) strdup("<subscription><syn:endpoint xmlns:syn=\"http://ws.apache.org/ns/synapse\"><syn:address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" /></syn:endpoint></subscription>"); axis2_char_t *epr_type = "application/vnd.epr"; axis2_char_t *filter = "/weather/4/"; axis2_char_t *reg_url = "http://localhost:9762/registry"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); subscription_id = axutil_strcat(env, "urn:uuid:", axutil_uuid_gen(env), NULL); path = axutil_strcat(env, filter, SUBSCRIPTION_COLLECTION_NAME, "/", subscription_id, NULL); id = axutil_strcat(env, reg_url, filter, SUBSCRIPTION_COLLECTION_NAME, "/", subscription_id, NULL); remote_registry = remote_registry_create(env, reg_url, "admin", "admin"); topic_index_init(); res = remote_registry_resource_create(env); remote_registry_resource_set_content(res, env, content); remote_registry_resource_set_content_len(res, env, axutil_strlen(content)); remote_registry_resource_set_media_type(res, env, epr_type); remote_registry_resource_set_description(res, env, ""); properties = axutil_hash_make(env); if(properties) { axutil_hash_set(properties, axutil_strdup(env, "expires"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "*")); axutil_hash_set(properties, axutil_strdup(env, "staticFlag"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "false")); axutil_hash_set(properties, axutil_strdup(env, "filterValue"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, filter)); axutil_hash_set(properties, axutil_strdup(env, "subManagerURI"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "http://10.100.1.44:8280/services/SampleEventSource")); axutil_hash_set(properties, axutil_strdup(env, "filterDialect"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "http://synapse.apache.org/eventing/dialect/topicFilter")); remote_registry_resource_set_properties(res, env, properties); } remote_registry_put(remote_registry, env, path, res); if(id) { AXIS2_FREE(env->allocator, id); } if(path) { AXIS2_FREE(env->allocator, path); path = NULL; } if(res) { remote_registry_resource_free(res, env); res = NULL; } res = remote_registry_get(remote_registry, env, TOPIC_INDEX, NULL); if(!res) { return 0; } id = axutil_strcat(env, reg_url, TOPIC_INDEX, NULL); properties = remote_registry_resource_get_properties(res, env); if(properties) { path = axutil_strcat(env, filter, SUBSCRIPTION_COLLECTION_NAME, NULL); axutil_hash_set(properties, subscription_id, AXIS2_HASH_KEY_STRING, path); remote_registry_resource_set_properties(res, env, properties); } remote_registry_resource_set_content(res, env, NULL); remote_registry_resource_set_content_len(res, env, 0); index_path = axutil_strcat(env, TOPIC_INDEX, "/TopicIndex", NULL); remote_registry_put(remote_registry, env, TOPIC_INDEX, res); if(id) { AXIS2_FREE(env->allocator, id); } if(res) { remote_registry_resource_free(res, env); res = NULL; } printf("\n"); return 0; }
AXIS2_EXTERN axis2_svc_grp_ctx_t *AXIS2_CALL axis2_conf_ctx_fill_ctxs( axis2_conf_ctx_t * conf_ctx, const axutil_env_t * env, axis2_msg_ctx_t * msg_ctx) { axis2_char_t *svc_grp_ctx_id = NULL; axis2_svc_grp_ctx_t *svc_grp_ctx = NULL; axis2_svc_ctx_t *svc_ctx = NULL; axis2_svc_t *svc = NULL; axis2_svc_grp_t *svc_grp = NULL; const axutil_qname_t *qname = NULL; axis2_char_t *svc_id = NULL; axis2_op_ctx_t *op_ctx = NULL; AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL); svc = axis2_msg_ctx_get_svc(msg_ctx, env); if(!svc) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SERVICE_NOT_YET_FOUND, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service not yet found in message context. Cannot proceed"); return NULL; } qname = axis2_svc_get_qname(svc, env); if(!qname) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service found in message context has no name."); return NULL; } svc_id = axutil_qname_get_localpart(qname, env); if(!svc_id) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service found in message context has no name."); return NULL; } svc_grp = axis2_svc_get_parent(svc, env); if(svc_grp) { svc_grp_ctx_id = (axis2_char_t *)axis2_svc_grp_get_name(svc_grp, env); } if(!svc_grp_ctx_id) { svc_grp_ctx_id = (axis2_char_t *)axutil_string_get_buffer(axis2_msg_ctx_get_svc_grp_ctx_id( msg_ctx, env), env); } /* By this time service group context id must have a value, either from transport or from * addressing */ if(svc_grp_ctx_id) { svc_grp_ctx = (axis2_svc_grp_ctx_t *)axutil_hash_get(conf_ctx->svc_grp_ctx_map, svc_grp_ctx_id, AXIS2_HASH_KEY_STRING); if(svc_grp_ctx) { svc_ctx = axis2_svc_grp_ctx_get_svc_ctx(svc_grp_ctx, env, svc_id); if(!svc_ctx) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC_GRP, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service group context has no servie context set for service %s", svc_id); return NULL; } } } if(!svc_grp_ctx_id) { svc_grp_ctx_id = axutil_uuid_gen(env); if(svc_grp_ctx_id) { axutil_string_t *svc_grp_ctx_id_str = axutil_string_create_assume_ownership(env, &svc_grp_ctx_id); axis2_msg_ctx_set_svc_grp_ctx_id(msg_ctx, env, svc_grp_ctx_id_str); axutil_string_free(svc_grp_ctx_id_str, env); } } if(!svc_grp_ctx) { axis2_svc_grp_t *svc_group; svc_group = axis2_svc_get_parent(svc, env); svc_grp_ctx = axis2_svc_grp_get_svc_grp_ctx(svc_group, env, conf_ctx); svc_ctx = axis2_svc_grp_ctx_get_svc_ctx(svc_grp_ctx, env, svc_id); if(!svc_ctx) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC_GRP, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service group context has no servie context set for service %s", svc_id); return NULL; } axis2_svc_grp_ctx_set_id(svc_grp_ctx, env, svc_grp_ctx_id); axis2_conf_ctx_register_svc_grp_ctx(conf_ctx, env, svc_grp_ctx_id, svc_grp_ctx); } /* When you come here operation context MUST have already been assigned to the message context */ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env); if(!op_ctx) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_MSG_CTX, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Operation context not set for message context"); return NULL; } axis2_op_ctx_set_parent(op_ctx, env, svc_ctx); axis2_msg_ctx_set_svc_ctx(msg_ctx, env, svc_ctx); axis2_msg_ctx_set_svc_grp_ctx(msg_ctx, env, svc_grp_ctx); return svc_grp_ctx; }
int main(int argc, char** argv) { const axutil_env_t *env = NULL; const axis2_char_t *address = NULL; axis2_endpoint_ref_t* endpoint_ref = NULL; axis2_endpoint_ref_t* reply_to = NULL; axis2_options_t *options = NULL; const axis2_char_t *client_home = NULL; axis2_svc_client_t* svc_client = NULL; axiom_node_t *payload = NULL; axis2_callback_t *callback = NULL; axis2_callback_t *callback2 = NULL; axis2_callback_t *callback3 = NULL; axutil_property_t *property = NULL; axis2_char_t *offered_seq_id = NULL; axis2_bool_t offer = AXIS2_TRUE; neethi_policy_t *policy = NULL; axis2_status_t status = AXIS2_FAILURE; /* Set up the environment */ env = axutil_env_create_all("rm_echo_1_1_amqp.log", AXIS2_LOG_LEVEL_TRACE); /* Set end point reference of echo service */ address = "amqp://127.0.0.1:5672/axis2/services/RM11SampleService"; if (argc > 1) { if (axutil_strcmp(argv[1], "-h") == 0) { printf("Usage : %s [endpoint_url]\n", argv[0]); printf("use -h for help\n"); return 0; } else { address = argv[1]; } } printf ("Using endpoint : %s\n", address); /* Create EPR with given address */ endpoint_ref = axis2_endpoint_ref_create(env, address); /* Setup options */ options = axis2_options_create(env); axis2_options_set_to(options, env, endpoint_ref); axis2_options_set_use_separate_listener(options, env, AXIS2_TRUE); /* Seperate listner needs addressing, hence addressing stuff in options */ /*axis2_options_set_action(options, env, "http://127.0.0.1:8080/axis2/services/RM11SampleService/anonOutInOp");*/ axis2_options_set_action(options, env, "urn:wsrm:EchoString"); reply_to = axis2_endpoint_ref_create(env, "amqp://localhost:5672/axis2/services/__ANONYMOUS_SERVICE__"); axis2_options_set_reply_to(options, env, reply_to); axis2_options_set_transport_in_protocol(options, env, AXIS2_TRANSPORT_ENUM_AMQP); /* Set up deploy folder. It is from the deploy folder, the configuration is * picked up using the axis2.xml file. * In this sample client_home points to the Axis2/C default deploy folder. * The client_home can be different from this folder on your system. For * example, you may have a different folder (say, my_client_folder) with its * own axis2.xml file. my_client_folder/modules will have the modules that * the client uses */ client_home = AXIS2_GETENV("AXIS2C_HOME"); if (!client_home) { client_home = "../../.."; } /* Create service client */ svc_client = axis2_svc_client_create(env, client_home); if (!svc_client) { printf("Error creating service client\n"); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code: %d :: %s", env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error)); return -1; } /*Create the policy, from file*/ policy = neethi_util_create_policy_from_file(env, "../policy/rm11-policy.xml"); if(!policy) { printf("\nPolicy creation failed from the file"); return 0; } status = axis2_svc_client_set_policy(svc_client, env, policy); if(status == AXIS2_FAILURE) { printf("Policy setting failed\n"); } /* Set service client options */ axis2_svc_client_set_options(svc_client, env, options); axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); axis2_svc_client_engage_module(svc_client, env, "sandesha2"); /* Offer sequence */ if(offer) { offered_seq_id = axutil_uuid_gen(env); property = axutil_property_create(env); if(property) { axutil_property_set_value(property, env, axutil_strdup(env, offered_seq_id)); axis2_options_set_property(options, env, SANDESHA2_CLIENT_OFFERED_SEQ_ID, property); } } /* RM Version 1.1 */ property = axutil_property_create_with_args(env, 3, 0, 0, SANDESHA2_SPEC_VERSION_1_1); if(property) { axis2_options_set_property(options, env, SANDESHA2_CLIENT_RM_SPEC_VERSION, property); } payload = build_om_payload_for_echo_svc(env, "echo1"); callback = axis2_callback_create(env); axis2_callback_set_on_complete(callback, rm_echo_callback_on_complete); axis2_callback_set_on_error(callback, rm_echo_callback_on_error); axis2_svc_client_send_receive_non_blocking(svc_client, env, payload, callback); wait_on_callback(env, callback); payload = build_om_payload_for_echo_svc(env, "echo2"); callback2 = axis2_callback_create(env); axis2_callback_set_on_complete(callback2, rm_echo_callback_on_complete); axis2_callback_set_on_error(callback2, rm_echo_callback_on_error); axis2_svc_client_send_receive_non_blocking(svc_client, env, payload, callback2); wait_on_callback(env, callback2); AXIS2_SLEEP(SANDESHA2_MAX_COUNT); callback3 = axis2_callback_create(env); axis2_callback_set_on_complete(callback3, rm_echo_callback_on_complete); axis2_callback_set_on_error(callback3, rm_echo_callback_on_error); sandesha2_client_terminate_seq_with_svc_client(env, svc_client, callback3); AXIS2_SLEEP(SANDESHA2_MAX_COUNT); if (svc_client) { axis2_svc_client_free(svc_client, env); svc_client = NULL; } return 0; }
int main(int argc, char** argv) { const axutil_env_t *env = NULL; const axis2_char_t *address = NULL; axis2_endpoint_ref_t* endpoint_ref = NULL; axis2_options_t *options = NULL; const axis2_char_t *client_home = NULL; axis2_svc_client_t* svc_client = NULL; axiom_node_t *payload = NULL; axis2_status_t status = AXIS2_FAILURE; axutil_property_t *property = NULL; axis2_char_t *seq_key = NULL; neethi_policy_t *policy = NULL; /* Set up the environment */ env = axutil_env_create_all("rm_ping_1_0_amqp.log", AXIS2_LOG_LEVEL_TRACE); /* Set end point reference of echo service */ address = "amqp://127.0.0.1:5672/axis2/services/RM10SampleService"; if (argc > 1) { if (axutil_strcmp(argv[1], "-h") == 0) { printf("Usage : %s [endpoint_url]\n", argv[0]); printf("use -h for help\n"); return 0; } else { address = argv[1]; } } printf ("Using endpoint : %s\n", address); /* Create EPR with given address */ endpoint_ref = axis2_endpoint_ref_create(env, address); /* Setup options */ options = axis2_options_create(env); axis2_options_set_xml_parser_reset(options, env, AXIS2_FALSE); if(endpoint_ref) { axis2_options_set_to(options, env, endpoint_ref); } axis2_options_set_action(options, env, "urn:wsrm:Ping"); /* Set up deploy folder. It is from the deploy folder, the configuration is * picked up using the axis2.xml file. * In this sample client_home points to the Axis2/C default deploy folder. * The client_home can be different from this folder on your system. For * example, you may have a different folder (say, my_client_folder) with its * own axis2.xml file. my_client_folder/modules will have the modules that * the client uses */ client_home = AXIS2_GETENV("AXIS2C_HOME"); if (!client_home) { client_home = "../../.."; } /* Create service client */ svc_client = axis2_svc_client_create(env, client_home); if (!svc_client) { printf("Error creating service client\n"); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code: %d :: %s", env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error)); } /*Create the policy, from file*/ policy = neethi_util_create_policy_from_file(env, "../policy/rm10-policy.xml"); if(!policy) { printf("\nPolicy creation failed from the file"); return 0; } status = axis2_svc_client_set_policy(svc_client, env, policy); if(status == AXIS2_FAILURE) { printf("Policy setting failed\n"); } /* Set service client options */ axis2_svc_client_set_options(svc_client, env, options); /* Engage addressing module */ axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); axis2_svc_client_engage_module(svc_client, env, "sandesha2"); /* RM Version 1.0 */ property = axutil_property_create_with_args(env, 0, 0, 0, SANDESHA2_SPEC_VERSION_1_0); if(property) { axis2_options_set_property(options, env, SANDESHA2_CLIENT_RM_SPEC_VERSION, property); } seq_key = axutil_uuid_gen(env); property = axutil_property_create_with_args(env, 0, 0, 0, seq_key); if(property) { axis2_options_set_property(options, env, SANDESHA2_CLIENT_SEQ_KEY, property); } /* Send request */ payload = build_om_programatically(env, "ping1", seq_key); status = axis2_svc_client_send_robust(svc_client, env, payload); if(status) { printf("\nping client invoke SUCCESSFUL!\n"); } payload = NULL; payload = build_om_programatically(env, "ping2", seq_key); status = axis2_svc_client_send_robust(svc_client, env, payload); if(status) { printf("\nping client invoke SUCCESSFUL!\n"); } payload = NULL; property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE); axis2_options_set_property(options, env, "Sandesha2LastMessage", property); payload = build_om_programatically(env, "ping3", seq_key); status = axis2_svc_client_send_robust(svc_client, env, payload); if(status) { printf("\nping client invoke SUCCESSFUL!\n"); } /** Wait till callback is complete. Simply keep the parent thread running until our on_complete or on_error is invoked */ /*This sleep is for wait the main thread until sandesha sends the terminatesequence *messages. */ AXIS2_SLEEP(SANDESHA2_SLEEP); AXIS2_FREE(env->allocator, seq_key); if (svc_client) { axis2_svc_client_free(svc_client, env); svc_client = NULL; } if (env) { axutil_env_free((axutil_env_t *) env); env = NULL; } return 0; }
AXIS2_EXTERN axis2_char_t *AXIS2_CALL sandesha2_seq_mgr_setup_new_incoming_sequence( const axutil_env_t *env, sandesha2_msg_ctx_t *create_seq_msg, sandesha2_seq_property_mgr_t *seq_prop_mgr, sandesha2_next_msg_mgr_t *next_msg_mgr) { axis2_char_t *rmd_sequence_id = NULL; axis2_endpoint_ref_t *to = NULL; axis2_endpoint_ref_t *reply_to = NULL; axis2_endpoint_ref_t *acks_to = NULL; sandesha2_acks_to_t *temp_acks_to = NULL; sandesha2_address_t *temp_address = NULL; sandesha2_create_seq_t *create_seq = NULL; axis2_msg_ctx_t *msg_ctx = NULL; axis2_conf_ctx_t *conf_ctx = NULL; sandesha2_seq_property_bean_t *received_msg_bean = NULL; sandesha2_seq_property_bean_t *addressing_ns_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 *to_bean = NULL; sandesha2_next_msg_bean_t *next_msg_bean = NULL; axis2_char_t *addressing_ns_value = NULL; axis2_char_t *anonymous_uri = NULL; axis2_char_t *create_seq_msg_action = NULL; axis2_char_t *msg_rm_ns = NULL; axis2_char_t *spec_version = NULL; axis2_char_t *address = NULL; axis2_char_t *reply_to_addr = NULL; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Entry:sandesha2_seq_mgr_setup_new_incoming_sequence"); rmd_sequence_id = axutil_uuid_gen(env); to = sandesha2_msg_ctx_get_to(create_seq_msg, env); if(!to) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "To is NULL"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_TO_IS_NULL, AXIS2_FAILURE); return NULL; } reply_to = sandesha2_msg_ctx_get_reply_to(create_seq_msg, env); create_seq = sandesha2_msg_ctx_get_create_seq(create_seq_msg, env); if(!create_seq) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Create Sequence Part is NULL"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CREATE_SEQ_PART_IS_NULL, AXIS2_FAILURE); return NULL; } temp_acks_to = sandesha2_create_seq_get_acks_to(create_seq, env); temp_address = sandesha2_acks_to_get_address(temp_acks_to, env); acks_to = sandesha2_address_get_epr(temp_address, env); if(!acks_to) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Acks To is NULL"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_ACKS_TO_IS_NULL, AXIS2_FAILURE); return NULL; } msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); /* Setting the addressing version */ addressing_ns_value = sandesha2_msg_ctx_get_addr_ns_val(create_seq_msg, env); addressing_ns_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id, SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, addressing_ns_value); if(addressing_ns_bean) { sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, addressing_ns_bean); sandesha2_seq_property_bean_free(addressing_ns_bean, env); } anonymous_uri = sandesha2_spec_specific_consts_get_anon_uri(env, addressing_ns_value); /* If no replyTo value. Send responses as sync. */ if(reply_to) { reply_to_addr = (axis2_char_t*)axis2_endpoint_ref_get_address(reply_to, env); to_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id, SANDESHA2_SEQ_PROP_TO_EPR, reply_to_addr); } else { to_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id, SANDESHA2_SEQ_PROP_TO_EPR, anonymous_uri); } if(to_bean) { sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, to_bean); sandesha2_seq_property_bean_free(to_bean, env); } address = (axis2_char_t*)axis2_endpoint_ref_get_address(to, env); reply_to_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id, SANDESHA2_SEQ_PROP_REPLY_TO_EPR, address); if(reply_to_bean) { sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, reply_to_bean); sandesha2_seq_property_bean_free(reply_to_bean, env); } address = (axis2_char_t*)axis2_endpoint_ref_get_address(acks_to, env); acks_to_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id, SANDESHA2_SEQ_PROP_ACKS_TO_EPR, address); 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); } received_msg_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id, SANDESHA2_SEQ_PROP_SERVER_COMPLETED_MESSAGES, ""); if(received_msg_bean) { sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, received_msg_bean); sandesha2_seq_property_bean_free(received_msg_bean, env); } next_msg_bean = sandesha2_next_msg_bean_create_with_data(env, rmd_sequence_id, 1); /* 1 will be the next */ if(next_msg_bean) { axis2_char_t *internal_sequence_id = NULL; internal_sequence_id = sandesha2_utils_get_internal_sequence_id(env, rmd_sequence_id); if(internal_sequence_id) { sandesha2_next_msg_bean_set_internal_seq_id(next_msg_bean, env, internal_sequence_id); AXIS2_FREE(env->allocator, internal_sequence_id); } sandesha2_next_msg_mgr_insert(next_msg_mgr, env, next_msg_bean); sandesha2_next_msg_bean_free(next_msg_bean, env); } /* Message to invoke. This will apply for only in-order invocations */ /*if(!axis2_msg_ctx_get_server_side(msg_ctx, env) || !sandesha2_utils_is_anon_uri(env, * reply_to_addr)) * { * sandesha2_utils_start_sender_for_seq(env, conf_ctx, rmd_sequence_id); *}*/ /* Setting the RM Spec version for this sequence */ create_seq_msg_action = sandesha2_msg_ctx_get_wsa_action(create_seq_msg, env); if(!create_seq_msg_action) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CREATE_SEQ_MSG_DOES_NOT_HAVE_WSA_ACTION_VALUE, AXIS2_FAILURE); return NULL; } msg_rm_ns = sandesha2_create_seq_get_namespace_value(create_seq, env); if(!axutil_strcmp(SANDESHA2_SPEC_2005_02_NS_URI, msg_rm_ns)) { spec_version = axutil_strdup(env, SANDESHA2_SPEC_VERSION_1_0); } else if(!axutil_strcmp(SANDESHA2_SPEC_2007_02_NS_URI, msg_rm_ns)) { spec_version = axutil_strdup(env, SANDESHA2_SPEC_VERSION_1_1); } else { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CREATE_SEQ_MSG_DOES_NOT_HAVE_VALID_RM_NS_VALUE, AXIS2_FAILURE); return NULL; } if(spec_version) { AXIS2_FREE(env->allocator, spec_version); } /* TODO Get the SOAP version from the creaet sequence message */ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Entry:sandesha2_seq_mgr_setup_new_incoming_sequence"); return rmd_sequence_id; }
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; }
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; }