/** * axis2_libcurl_set_auth_options maps authentication AXIS2/C options to * libcURL options. * * CURLOPT_USERPWD - char * user:password for authentication * CURLOPT_HTTPAUTH - long bitmask which authentication methods to use */ static axis2_status_t axis2_libcurl_set_auth_options( CURL *handler, const axutil_env_t * env, axis2_msg_ctx_t * msg_ctx) { axutil_property_t *property = NULL; axis2_char_t *uname = NULL; axis2_char_t *passwd = NULL; axis2_char_t *auth_type = NULL; property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_HTTP_AUTH_UNAME); if (property) { uname = (axis2_char_t *) axutil_property_get_value(property, env); } property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_HTTP_AUTH_PASSWD); if (property) { passwd = (axis2_char_t *) axutil_property_get_value(property, env); } if (uname && passwd) { axis2_char_t buffer[256]; strncpy(buffer, uname, 256); strncat(buffer, ":", 256); strncat(buffer, passwd, 256); curl_easy_setopt(handler, CURLOPT_USERPWD, buffer); } property = (axutil_property_t *)axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_HTTP_AUTH_TYPE); if (property) { auth_type = (axis2_char_t *) axutil_property_get_value(property, env); } if (auth_type && 0 == axutil_strcmp(auth_type, AXIS2_HTTP_AUTH_TYPE_BASIC)) { curl_easy_setopt(handler, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); } else { /* Uses anonymous connection.*/ } return AXIS2_SUCCESS; }
AXIS2_EXTERN int AXIS2_CALL axis2_amqp_util_msg_ctx_get_request_timeout( axis2_msg_ctx_t* msg_ctx, const axutil_env_t* env) { axis2_conf_ctx_t* conf_ctx = NULL; axutil_property_t* property = NULL; void* value = NULL; int request_timeout = AXIS2_QPID_DEFAULT_REQUEST_TIMEOUT; conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); if(conf_ctx) { property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_REQUEST_TIMEOUT); if(property) { value = axutil_property_get_value(property, env); if(value) { request_timeout = *(int*)value; } } } return request_timeout; }
/** * Get the complete set of security processed results * @env the environment * @msg_ctx the message context in which data are extracted * @return complete set of security processed results. */ AXIS2_EXTERN axutil_hash_t* AXIS2_CALL rampart_get_all_security_processed_results( const axutil_env_t *env, axis2_msg_ctx_t *msg_ctx) { axutil_property_t *sec_processed_results_prop = NULL; axutil_hash_t *sec_processed_results = NULL; sec_processed_results_prop = axis2_msg_ctx_get_property( msg_ctx, env, RAMPART_SECURITY_PROCESSED_RESULTS); if(!sec_processed_results_prop) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Cannot get %s from msg ctx ", RAMPART_SECURITY_PROCESSED_RESULTS); return NULL; } sec_processed_results = (axutil_hash_t*)axutil_property_get_value( sec_processed_results_prop, env); if(!sec_processed_results) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Cannot get Security Processed Results Hash table from the property"); return NULL; } return sec_processed_results; }
std::string AxisEnvironmentWrapper::at(const std::string &key) const{ axutil_property_t *property = NULL; property = axis2_ctx_get_property(_ctx, _env, key.c_str()); if (!property){ // std::cerr << "No property " << key << " found" << std::endl; return std::string(); } std::string ret(static_cast<char*>(axutil_property_get_value(property, _env))); return ret; }
axis2_char_t * wsf_util_get_http_headers_from_op_client ( axis2_op_client_t * op_client, axutil_env_t * env, axis2_wsdl_msg_labels_t msg_label) { if (op_client) { const axis2_msg_ctx_t *msg_ctx = NULL; axutil_property_t *client_property = NULL; axis2_http_client_t *client = NULL; axis2_http_simple_response_t *response = NULL; axutil_array_list_t *list = NULL; axis2_http_header_t *header = NULL; int i; char *header_buf = NULL; msg_ctx = axis2_op_client_get_msg_ctx (op_client, env, msg_label); if (!msg_ctx) return NULL; client_property = (axutil_property_t *) axis2_msg_ctx_get_property (msg_ctx, env, AXIS2_HTTP_CLIENT); if (client_property) client = (axis2_http_client_t *) axutil_property_get_value (client_property, env); else return NULL; if (client && (msg_label == AXIS2_WSDL_MESSAGE_LABEL_OUT)) { response = axis2_http_client_get_response (client, env); if (response) list = axis2_http_simple_response_get_headers (response, env); else return NULL; } if (list) { header_buf = malloc (500); if (!axutil_array_list_is_empty (list, env)) { for (i = 0; i < axutil_array_list_size (list, env); i++) { header = (axis2_http_header_t *) axutil_array_list_get (list, env, i); strcat (header_buf, axis2_http_header_to_external_form (header, env)); } return header_buf; } } } return NULL; }
/** * axis2_libcurl_set_ssl_options maps SSL AXIS2/C options to * libcURL options. * * CURLOPT_SSL_VERIFYHOST - long enum whether to verify the server identity * CURLOPT_SSL_VERIFYPEER - long boolean whether to verify the server certificate */ static axis2_status_t axis2_libcurl_set_ssl_options( CURL *handler, const axutil_env_t * env, axis2_msg_ctx_t * msg_ctx) { axutil_property_t *property = NULL; axis2_char_t *verify_peer = NULL; axis2_char_t *verify_host = NULL; property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_SSL_VERIFY_PEER); if (property) { verify_peer = (axis2_char_t *)axutil_property_get_value(property, env); } if (verify_peer) { if (0 == axutil_strcasecmp(verify_peer, AXIS2_VALUE_TRUE)) { curl_easy_setopt(handler, CURLOPT_SSL_VERIFYPEER, 1); } else { curl_easy_setopt(handler, CURLOPT_SSL_VERIFYPEER, 0); } } property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_SSL_VERIFY_HOST); if (property) { verify_host = (axis2_char_t *)axutil_property_get_value(property, env); } if (verify_host) { curl_easy_setopt(handler, CURLOPT_SSL_VERIFYHOST, AXIS2_ATOI(verify_host)); } return AXIS2_SUCCESS; }
void AXIS2_CALL service_admin_counter_set_last_count ( const axutil_env_t *env, axis2_msg_ctx_t *msg_ctx, axis2_char_t *svc_name, axis2_char_t *op_name, int last_count) { int *count = NULL; axis2_conf_ctx_t *conf_ctx = NULL; axutil_property_t *property = NULL; axutil_hash_t *last_counts = NULL; conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); if(svc_name && op_name) { axis2_char_t *key = NULL; key = axutil_strcat(env, svc_name, "-", op_name, NULL); property = axis2_conf_ctx_get_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_OPERATION_COUNT); /* set_last_count is always called after get_last_count. So checking for existence of property * is not necessary here */ last_counts = axutil_property_get_value(property, env); count = axutil_hash_get(last_counts, key, AXIS2_HASH_KEY_STRING); *count = last_count; AXIS2_FREE(env->allocator, key); } else if(svc_name) { property = axis2_conf_ctx_get_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_SERVICE_COUNT); /* set_last_count is always called after get_last_count. So checking for existence of property * is not necessary here */ last_counts = axutil_property_get_value(property, env); count = axutil_hash_get(last_counts, svc_name, AXIS2_HASH_KEY_STRING); *count = last_count; } }
/** * axis2_libcurl_set_connection_options maps connection AXIS2/C options to * libcURL options. * CURLOPT_CONNECTTIMEOUT_MS - long connection timeout in milliseconds * CURLOPT_TIMEOUT_MS - long transfer timeout in milliseconds */ static axis2_status_t axis2_libcurl_set_connection_options( CURL *handler, const axutil_env_t * env, axis2_msg_ctx_t * msg_ctx) { axutil_property_t *property = NULL; long long_property_value = 0; /* check if timeout has been set by user using options * with axis2_options_set_timeout_in_milli_seconds */ property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_HTTP_CONNECTION_TIMEOUT); if (property) { axis2_char_t *value = axutil_property_get_value(property, env); if (value) { long_property_value = AXIS2_ATOI(value); curl_easy_setopt(handler, CURLOPT_CONNECTTIMEOUT_MS, long_property_value); } } property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_HTTP_SO_TIMEOUT); if (property) { axis2_char_t *value = axutil_property_get_value(property, env); if (value) { long_property_value = AXIS2_ATOI(value); curl_easy_setopt(handler, CURLOPT_TIMEOUT_MS, long_property_value); } } return AXIS2_SUCCESS; }
static axutil_hash_t * sct_provider_hash_map_get_sct_hash_store( const axutil_env_t *env, axis2_msg_ctx_t* msg_ctx) { axis2_conf_ctx_t *conf_ctx = NULL; axis2_ctx_t *ctx = NULL; axutil_property_t *property = NULL; axutil_hash_t *hash_store = NULL; /* Get the conf ctx */ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); if(!conf_ctx) { AXIS2_LOG_ERROR(env->log,AXIS2_LOG_SI, "[rampart]Config context is NULL. Cannot get security context token hash store."); return NULL; } ctx = axis2_conf_ctx_get_base(conf_ctx,env); if(!ctx) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Axis2 context is NULL. Cannot get security context token hash store."); return NULL; } /* Get the hash store property */ property = axis2_ctx_get_property(ctx, env, RAMPART_SCT_PROVIDER_HASH_PROB); if(property) { /* Get the store */ hash_store = (axutil_hash_t*)axutil_property_get_value(property, env); } else { axutil_property_t *hash_store_prop = NULL; hash_store = axutil_hash_make(env); hash_store_prop = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, AXIS2_TRUE, (void *)sct_provider_hash_map_sct_hash_store_free, hash_store); axis2_ctx_set_property(ctx, env, RAMPART_SCT_PROVIDER_HASH_PROB, hash_store_prop); } return hash_store; }
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_bool_t AXIS2_CALL axis2_amqp_util_conf_ctx_get_server_side( axis2_conf_ctx_t* conf_ctx, const axutil_env_t* env) { axutil_property_t* property = NULL; axis2_char_t* value = NULL; property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_IS_SVR_SIDE); if(!property) return AXIS2_TRUE; value = (axis2_char_t*)axutil_property_get_value(property, env); if(!value) return AXIS2_TRUE; return (axutil_strcmp(value, AXIS2_VALUE_TRUE) == 0) ? AXIS2_TRUE : AXIS2_FALSE; }
AXIS2_EXTERN axis2_char_t* AXIS2_CALL axis2_amqp_util_conf_ctx_get_qpid_broker_ip( axis2_conf_ctx_t* conf_ctx, const axutil_env_t* env) { axutil_property_t* property = NULL; void* value = NULL; axis2_char_t* broker_ip = AXIS2_QPID_DEFAULT_BROKER_IP; property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP); if(property) { value = axutil_property_get_value(property, env); if(value) { broker_ip = (axis2_char_t*)value; } } return broker_ip; }
AXIS2_EXTERN int AXIS2_CALL axis2_amqp_util_conf_ctx_get_qpid_broker_port( axis2_conf_ctx_t* conf_ctx, const axutil_env_t* env) { axutil_property_t* property = NULL; void* value = NULL; int broker_port = AXIS2_QPID_DEFAULT_BROKER_PORT; property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT); if(property) { value = axutil_property_get_value(property, env); if(value) { broker_port = *(int*)value; } } return broker_port; }
AXIS2_EXTERN axis2_bool_t AXIS2_CALL axis2_amqp_util_msg_ctx_get_use_separate_listener( axis2_msg_ctx_t* msg_ctx, const axutil_env_t* env) { axutil_property_t* property = NULL; axis2_char_t* value = NULL; axis2_bool_t use_separate_listener = AXIS2_FALSE; property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_USE_SEPARATE_LISTENER); if(property) { value = (axis2_char_t*)axutil_property_get_value(property, env); if(value && (axutil_strcmp(AXIS2_VALUE_TRUE, value) == 0)) { use_separate_listener = AXIS2_TRUE; } } return use_separate_listener; }
axis2_status_t AXIS2_CALL sandesha2_out_handler_invoke( struct axis2_handler *handler, const axutil_env_t *env, struct axis2_msg_ctx *msg_ctx) { axutil_property_t *temp_prop = NULL; axis2_conf_ctx_t *conf_ctx = NULL; axis2_conf_t *conf = NULL; axis2_char_t *str_done = NULL; axis2_char_t *dummy_msg_str = NULL; axis2_bool_t dummy_msg = AXIS2_FALSE; axis2_svc_t *svc = NULL; axutil_qname_t *module_qname = NULL; sandesha2_msg_ctx_t *rm_msg_ctx = NULL; sandesha2_msg_processor_t *msg_processor = NULL; int msg_type = -1; AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_out_handler_invoke"); temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_SEQ_PROP_MAKE_CONNECTION_OUT_PATH); if (temp_prop) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] In make connection out path. So return here."); return AXIS2_SUCCESS; temp_prop = NULL; } if(sandesha2_util_is_rstr_msg(env, msg_ctx)) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] A RSTR message. Sandesha don't process."); return AXIS2_SUCCESS; } conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); if(!conf_ctx) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Configuration Context is NULL"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CONF_CTX_NULL, AXIS2_FAILURE); return AXIS2_FAILURE; } svc = axis2_msg_ctx_get_svc(msg_ctx, env); if(!svc) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]Axis2 Service is NULL"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SVC_NULL, AXIS2_FAILURE); return AXIS2_FAILURE; } module_qname = axutil_qname_create(env, SANDESHA2_MODULE, NULL, NULL); if(!axis2_svc_is_module_engaged(svc, env, module_qname)) { if(module_qname) { axutil_qname_free(module_qname, env); } AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]RM is not engaged. So return here"); return AXIS2_SUCCESS; } if(module_qname) { axutil_qname_free(module_qname, env); } temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE); if(temp_prop) { str_done = (axis2_char_t *) axutil_property_get_value(temp_prop, env); } if(str_done && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, str_done)) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]Application Processing Done. So return here."); return AXIS2_SUCCESS; } temp_prop = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE); axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, temp_prop); conf = axis2_conf_ctx_get_conf(conf_ctx, env); if(!sandesha2_permanent_storage_mgr_create_db(env, conf_ctx)) { return AXIS2_FAILURE; } /* Getting rm message */ rm_msg_ctx = sandesha2_msg_init_init_msg(env, msg_ctx); temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_CLIENT_DUMMY_MESSAGE); if(NULL != temp_prop) { dummy_msg_str = (axis2_char_t *) axutil_property_get_value(temp_prop, env); } if(dummy_msg_str && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, dummy_msg_str)) { dummy_msg = AXIS2_TRUE; } temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_SVC_CLIENT_CLOSED); if(temp_prop) { axis2_char_t *spec_version = NULL; axis2_endpoint_ref_t *reply_to = axis2_msg_ctx_get_reply_to(msg_ctx, env); if(reply_to) { axis2_char_t *address = axis2_endpoint_ref_get_address(reply_to, env); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "dam_reply_to_address:%s", address); } spec_version = sandesha2_utils_get_rm_version(env, msg_ctx); if(!axutil_strcmp(SANDESHA2_SPEC_VERSION_1_1, spec_version)) { axis2_char_t *action = NULL; axutil_string_t *str_action = NULL; action = sandesha2_spec_specific_consts_get_terminate_seq_action(env, spec_version); str_action = axutil_string_create(env, action); axis2_msg_ctx_set_soap_action(msg_ctx, env, str_action); axutil_string_free(str_action, env); /*axis2_msg_ctx_set_reply_to(msg_ctx, env, NULL);*/ msg_type = sandesha2_msg_ctx_set_msg_type(rm_msg_ctx, env, SANDESHA2_MSG_TYPE_CLOSE_SEQ); } else if(!axutil_strcmp(SANDESHA2_SPEC_VERSION_1_0, spec_version)) { axutil_property_t *property = NULL; axutil_string_t *str_action = NULL; /*axis2_msg_info_headers_set_action(axis2_msg_ctx_get_msg_info_headers(msg_ctx, env), * env, SANDESHA2_SPEC_2005_02_SOAP_ACTION_LAST_MESSAGE); */ str_action = axutil_string_create(env, SANDESHA2_SPEC_2005_02_SOAP_ACTION_LAST_MESSAGE); axis2_msg_ctx_set_soap_action(msg_ctx, env, str_action); axutil_string_free(str_action, env); property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE); axis2_msg_ctx_set_property(msg_ctx, env, "Sandesha2LastMessage", property); /*axis2_msg_ctx_set_reply_to(msg_ctx, env, NULL);*/ } } msg_type = sandesha2_msg_ctx_get_msg_type(rm_msg_ctx, env); if(msg_type == SANDESHA2_MSG_TYPE_UNKNOWN) { axis2_msg_ctx_t *req_msg_ctx = NULL; axis2_op_ctx_t *op_ctx = NULL; op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env); req_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN); if(req_msg_ctx) /* For the server side */ { sandesha2_msg_ctx_t *req_rm_msg_ctx = NULL; sandesha2_seq_t *seq_part = NULL; req_rm_msg_ctx = sandesha2_msg_init_init_msg(env, req_msg_ctx); seq_part = sandesha2_msg_ctx_get_sequence(req_rm_msg_ctx, env); if(seq_part) { msg_processor = (sandesha2_msg_processor_t *) sandesha2_app_msg_processor_create(env); /* rm intended msg */ } if(req_rm_msg_ctx) sandesha2_msg_ctx_free(req_rm_msg_ctx, env); } else if(!axis2_msg_ctx_get_server_side(msg_ctx, env)) { msg_processor = (sandesha2_msg_processor_t *) sandesha2_app_msg_processor_create(env); } } else { msg_processor = sandesha2_msg_processor_create_msg_processor(env, rm_msg_ctx); } if(msg_processor) { sandesha2_msg_processor_process_out_msg(msg_processor, env, rm_msg_ctx); sandesha2_msg_processor_free(msg_processor, env); } if(AXIS2_SUCCESS != AXIS2_ERROR_GET_STATUS_CODE(env->error)) { /* Message should not be sent in an exception situation */ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Pausing message context"); axis2_msg_ctx_set_paused(msg_ctx, env, AXIS2_TRUE); if(rm_msg_ctx) { sandesha2_msg_ctx_free(rm_msg_ctx, env); } AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Error in processing the message"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_PROCESS_MSG, AXIS2_FAILURE); return AXIS2_FAILURE; } temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE); if(temp_prop) { axutil_property_set_value(temp_prop, env, AXIS2_VALUE_FALSE); } if(rm_msg_ctx) { sandesha2_msg_ctx_free(rm_msg_ctx, env); } AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Exit:sandesha2_out_handler_invoke"); return AXIS2_SUCCESS; }
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; }
axis2_status_t __euca_authenticate(const axutil_env_t *env,axis2_msg_ctx_t *out_msg_ctx, axis2_op_ctx_t *op_ctx) { //***** First get the message context before doing anything dumb w/ a NULL pointer *****/ axis2_msg_ctx_t *msg_ctx = NULL; //<--- incoming msg context, it is NULL, see? msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN); //***** Print everything from the security results, just for testing now *****// rampart_context_t *rampart_context = NULL; axutil_property_t *property = NULL; property = axis2_msg_ctx_get_property(msg_ctx, env, RAMPART_CONTEXT); if(property) { rampart_context = (rampart_context_t *)axutil_property_get_value(property, env); // AXIS2_LOG_CRITICAL(env->log,AXIS2_LOG_SI," ======== PRINTING PROCESSED WSSEC TOKENS ======== "); rampart_print_security_processed_results_set(env,msg_ctx); } //***** Extract Security Node from header from enveloper from msg_ctx *****// axiom_soap_envelope_t *soap_envelope = NULL; axiom_soap_header_t *soap_header = NULL; axiom_node_t *sec_node = NULL; soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env); if(!soap_envelope) NO_U_FAIL("SOAP envelope cannot be found."); soap_header = axiom_soap_envelope_get_header(soap_envelope, env); if (!soap_header) NO_U_FAIL("SOAP header cannot be found."); sec_node = rampart_get_security_header(env, msg_ctx, soap_header); // <---- here it is! if(!sec_node)NO_U_FAIL("No node wsse:Security -- required: ws-security"); //***** Find the wsse:Reference to the BinarySecurityToken *****// //** Path is: Security/ //** *sec_node must be non-NULL, kkthx **// axiom_node_t *sig_node = NULL; axiom_node_t *key_info_node = NULL; axiom_node_t *sec_token_ref_node = NULL; /** the ds:Signature node **/ sig_node = oxs_axiom_get_first_child_node_by_name(env,sec_node, OXS_NODE_SIGNATURE, OXS_DSIG_NS, OXS_DS ); if(!sig_node)NO_U_FAIL("No node ds:Signature -- required: signature"); /** the ds:KeyInfo **/ key_info_node = oxs_axiom_get_first_child_node_by_name(env, sig_node, OXS_NODE_KEY_INFO, OXS_DSIG_NS, NULL ); if(!key_info_node)NO_U_FAIL("No node ds:KeyInfo -- required: signature key"); /** the wsse:SecurityTokenReference **/ sec_token_ref_node = oxs_axiom_get_first_child_node_by_name(env, key_info_node,OXS_NODE_SECURITY_TOKEN_REFRENCE, OXS_WSSE_XMLNS, NULL); if(!sec_token_ref_node)NO_U_FAIL("No node wsse:SecurityTokenReference -- required: signing token"); //** in theory this is the branching point for supporting all kinds of tokens -- we only do BST Direct Reference **/ //***** Find the wsse:Reference to the BinarySecurityToken *****// //** *sec_token_ref_node must be non-NULL **/ axis2_char_t *ref = NULL; axis2_char_t *ref_id = NULL; axiom_node_t *token_ref_node = NULL; axiom_node_t *bst_node = NULL; /** the wsse:Reference node **/ token_ref_node = oxs_axiom_get_first_child_node_by_name(env, sec_token_ref_node,OXS_NODE_REFERENCE, OXS_WSSE_XMLNS, NULL); /** pull out the name of the BST node **/ ref = oxs_token_get_reference(env, token_ref_node); ref_id = axutil_string_substring_starting_at(axutil_strdup(env, ref), 1); /** get the wsse:BinarySecurityToken used to sign the message **/ bst_node = oxs_axiom_get_node_by_id(env, sec_node, "Id", ref_id, OXS_WSU_XMLNS); if(!bst_node){oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_ELEMENT_FAILED, "Error retrieving elementwith ID=%s", ref_id);NO_U_FAIL("Cant find the required node");} //***** Find the wsse:Reference to the BinarySecurityToken *****// //** *bst_node must be non-NULL **/ axis2_char_t *data = NULL; oxs_x509_cert_t *_cert = NULL; oxs_x509_cert_t *recv_cert = NULL; axis2_char_t *file_name = NULL; axis2_char_t *recv_x509_buf = NULL; axis2_char_t *msg_x509_buf = NULL; /** pull out the data from the BST **/ data = oxs_axiom_get_node_content(env, bst_node); /** create an oxs_X509_cert **/ _cert = oxs_key_mgr_load_x509_cert_from_string(env, data); if(_cert) { //***** FINALLY -- we have the certificate used to sign the message. authenticate it HERE *****// msg_x509_buf = oxs_x509_cert_get_data(_cert,env); if(!msg_x509_buf)NO_U_FAIL("OMG WHAT NOW?!"); /* recv_x509_buf = (axis2_char_t *)rampart_context_get_receiver_certificate(rampart_context, env); if(recv_x509_buf) recv_cert = oxs_key_mgr_load_x509_cert_from_string(env, recv_x509_buf); else { file_name = rampart_context_get_receiver_certificate_file(rampart_context, env); if(!file_name) NO_U_FAIL("Policy for the service is incorrect -- ReceiverCertificate is not set!!"); if (check_file(file_name)) NO_U_FAIL("No cert file ($EUCALYPTUS/var/lib/eucalyptus/keys/cloud-cert.pem) found, failing"); recv_cert = oxs_key_mgr_load_x509_cert_from_pem_file(env, file_name); } */ file_name = rampart_context_get_receiver_certificate_file(rampart_context, env); if(!file_name) NO_U_FAIL("Policy for the service is incorrect -- ReceiverCertificate is not set!!"); if (check_file(file_name)) NO_U_FAIL("No cert file ($EUCALYPTUS/var/lib/eucalyptus/keys/cloud-cert.pem) found, failing"); recv_cert = oxs_key_mgr_load_x509_cert_from_pem_file(env, file_name); if (recv_cert) { recv_x509_buf = oxs_x509_cert_get_data(recv_cert,env); } else { NO_U_FAIL("could not populate receiver cert"); } if( axutil_strcmp(recv_x509_buf,msg_x509_buf)!=0){ AXIS2_LOG_CRITICAL(env->log,AXIS2_LOG_SI," --------- Received x509 certificate value ---------" ); AXIS2_LOG_CRITICAL(env->log,AXIS2_LOG_SI, msg_x509_buf ); AXIS2_LOG_CRITICAL(env->log,AXIS2_LOG_SI," --------- Local x509 certificate value! ---------" ); AXIS2_LOG_CRITICAL(env->log,AXIS2_LOG_SI, recv_x509_buf ); AXIS2_LOG_CRITICAL(env->log,AXIS2_LOG_SI," ---------------------------------------------------" ); NO_U_FAIL("The certificate specified is invalid!"); } } else { oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_DEFAULT, "Cannot load certificate from string =%s", data); NO_U_FAIL("Failed to build certificate from BinarySecurityToken"); } oxs_x509_cert_free(_cert, env); oxs_x509_cert_free(recv_cert, env); return AXIS2_SUCCESS; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL sandesha2_seq_mgr_setup_new_outgoing_sequence( const axutil_env_t *env, axis2_msg_ctx_t *first_app_msg, axis2_char_t *internal_sequence_id, axis2_char_t *spec_version, sandesha2_seq_property_mgr_t *seq_prop_mgr) { axis2_conf_ctx_t *conf_ctx = NULL; axis2_char_t *addr_ns_val = NULL; axutil_property_t *property = NULL; sandesha2_seq_property_bean_t *addr_ns_bean = NULL; axis2_char_t *anon_uri = NULL; axis2_endpoint_ref_t *to_epr = NULL; axis2_char_t *acks_to_str = NULL; sandesha2_seq_property_bean_t *to_bean = NULL; sandesha2_seq_property_bean_t *reply_to_bean = NULL; sandesha2_seq_property_bean_t *acks_to_bean = NULL; sandesha2_seq_property_bean_t *msgs_bean = NULL; axis2_char_t *transport_to = NULL; axis2_endpoint_ref_t *reply_to_epr = NULL; axis2_bool_t is_svr_side = AXIS2_FALSE; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:sandesha2_seq_mgr_setup_new_outgoing_sequence"); AXIS2_PARAM_CHECK(env->error, first_app_msg, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, internal_sequence_id, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, spec_version, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, seq_prop_mgr, AXIS2_FAILURE); conf_ctx = axis2_msg_ctx_get_conf_ctx(first_app_msg, env); property = axis2_msg_ctx_get_property(first_app_msg, env, AXIS2_WSA_VERSION); if(property) { addr_ns_val = axutil_property_get_value(property, env); } if(!addr_ns_val) { axis2_op_ctx_t *op_ctx = NULL; axis2_msg_ctx_t *req_msg_ctx = NULL; op_ctx = axis2_msg_ctx_get_op_ctx(first_app_msg, env); req_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN); if(req_msg_ctx) { property = axis2_msg_ctx_get_property(req_msg_ctx, env, AXIS2_WSA_VERSION); if(property) { addr_ns_val = axutil_property_get_value(property, env); } } } if(!addr_ns_val) { addr_ns_val = AXIS2_WSA_NAMESPACE; } addr_ns_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, addr_ns_val); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, addr_ns_bean); if(addr_ns_bean) { sandesha2_seq_property_bean_free(addr_ns_bean, env); } anon_uri = sandesha2_spec_specific_consts_get_anon_uri(env, addr_ns_val); to_epr = axis2_msg_ctx_get_to(first_app_msg, env); property = axis2_msg_ctx_get_property(first_app_msg, env, SANDESHA2_CLIENT_ACKS_TO); if(property) { acks_to_str = axutil_property_get_value(property, env); } if (to_epr) { to_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, SANDESHA2_SEQ_PROP_TO_EPR, (axis2_char_t*)axis2_endpoint_ref_get_address(to_epr, env)); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, to_bean); sandesha2_seq_property_bean_free(to_bean, env); } is_svr_side = axis2_msg_ctx_get_server_side(first_app_msg, env); if(is_svr_side) { axis2_op_ctx_t *op_ctx = NULL; axis2_msg_ctx_t *req_msg_ctx = NULL; op_ctx = axis2_msg_ctx_get_op_ctx(first_app_msg, env); req_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN); if(!req_msg_ctx) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find the request message from the operation context"); return AXIS2_FAILURE; } reply_to_epr = axis2_msg_ctx_get_to(req_msg_ctx, env); if(reply_to_epr) { const axis2_char_t *temp_epr_addr = axis2_endpoint_ref_get_address(reply_to_epr, env); if(temp_epr_addr) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "temp_epr_address:%s", temp_epr_addr); acks_to_str = (axis2_char_t *) temp_epr_addr; reply_to_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, SANDESHA2_SEQ_PROP_REPLY_TO_EPR, (axis2_char_t*) temp_epr_addr); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, reply_to_bean); sandesha2_seq_property_bean_free(reply_to_bean, env); } } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot get request message from the operation context"); return AXIS2_FAILURE; } } else /* Not server side */ { reply_to_epr = axis2_msg_ctx_get_reply_to(first_app_msg, env); if(reply_to_epr) { const axis2_char_t *temp_epr_addr = axis2_endpoint_ref_get_address(reply_to_epr, env); if(temp_epr_addr) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "temp_epr_address:%s", temp_epr_addr); reply_to_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, SANDESHA2_SEQ_PROP_REPLY_TO_EPR, (axis2_char_t*) temp_epr_addr); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, reply_to_bean); sandesha2_seq_property_bean_free(reply_to_bean, env); } } } if(!acks_to_str) { acks_to_str = anon_uri; } acks_to_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, SANDESHA2_SEQ_PROP_ACKS_TO_EPR, acks_to_str); msgs_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, SANDESHA2_SEQ_PROP_CLIENT_COMPLETED_MESSAGES, ""); if(msgs_bean) { sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, msgs_bean); sandesha2_seq_property_bean_free(msgs_bean, env); } if(acks_to_bean) { sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, acks_to_bean); sandesha2_seq_property_bean_free(acks_to_bean, env); } transport_to = axis2_msg_ctx_get_transport_url(first_app_msg, env); if(transport_to) { sandesha2_seq_property_bean_t *transport_to_bean = NULL; transport_to_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, SANDESHA2_SEQ_PROP_TRANSPORT_TO, transport_to); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, transport_to_bean); } sandesha2_seq_mgr_update_last_activated_time(env, internal_sequence_id, seq_prop_mgr); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:sandesha2_seq_mgr_setup_new_outgoing_sequence"); return AXIS2_SUCCESS; }
/** * axis2_libcurl_set_proxy_options maps proxy AXIS2/C options to * libcURL options. * * CURLOPT_PROXY - char * proxy hostname * CURLOPT_PROXYPORT - long proxy listen port * CURLOPT_PROXYUSERPWD - char * user:password to authenticate to proxy * * TODO: * CURLOPT_PROXYTYPE - long enum type of proxy (HTTP, SOCKS) * CURLOPT_PROXYAUTH - long bitmask which authentication methods to use for proxy */ static axis2_status_t axis2_libcurl_set_proxy_options( CURL *handler, const axutil_env_t * env, axis2_msg_ctx_t * msg_ctx) { axis2_conf_ctx_t *conf_ctx = NULL; axis2_conf_t *conf = NULL; axis2_transport_out_desc_t *trans_desc = NULL; axutil_param_t *proxy_param = NULL; axutil_hash_t *transport_attrs = NULL; axutil_property_t *property = NULL; axis2_char_t *uname = NULL; axis2_char_t *passwd = NULL; axis2_char_t *proxy_host = NULL; axis2_char_t *proxy_port = NULL; property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_PROXY_AUTH_UNAME); if (property) { uname = (axis2_char_t *) axutil_property_get_value(property, env); } property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_PROXY_AUTH_PASSWD); if (property) { passwd = (axis2_char_t *) axutil_property_get_value(property, env); } conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); if (conf_ctx) { conf = axis2_conf_ctx_get_conf(conf_ctx, env); if (conf) { trans_desc = axis2_conf_get_transport_out(conf, env, AXIS2_TRANSPORT_ENUM_HTTP); } } if (trans_desc) { proxy_param = axutil_param_container_get_param( axis2_transport_out_desc_param_container(trans_desc, env), env, AXIS2_HTTP_PROXY_API); if (!proxy_param) { proxy_param = axutil_param_container_get_param( axis2_transport_out_desc_param_container(trans_desc, env), env, AXIS2_HTTP_PROXY); } if (proxy_param) { transport_attrs = axutil_param_get_attributes(proxy_param, env); } } if (transport_attrs) { axutil_generic_obj_t *obj = NULL; axiom_attribute_t *attr = NULL; if (!uname || !passwd) { obj = axutil_hash_get(transport_attrs, AXIS2_HTTP_PROXY_USERNAME, AXIS2_HASH_KEY_STRING); if (obj) { attr = (axiom_attribute_t *) axutil_generic_obj_get_value(obj, env); } if (attr) { uname = axiom_attribute_get_value(attr, env); } attr = NULL; obj = axutil_hash_get(transport_attrs, AXIS2_HTTP_PROXY_PASSWORD, AXIS2_HASH_KEY_STRING); if (obj) { attr = (axiom_attribute_t *)axutil_generic_obj_get_value(obj, env); } if (attr) { passwd = axiom_attribute_get_value(attr, env); } } obj = axutil_hash_get(transport_attrs, AXIS2_HTTP_PROXY_HOST, AXIS2_HASH_KEY_STRING); if (obj) { attr = (axiom_attribute_t *)axutil_generic_obj_get_value(obj, env); } if (attr) { proxy_host = axiom_attribute_get_value(attr, env); } if (proxy_host) { curl_easy_setopt(handler, CURLOPT_PROXY, proxy_host); } attr = NULL; obj = axutil_hash_get(transport_attrs, AXIS2_HTTP_PROXY_PORT, AXIS2_HASH_KEY_STRING); if (obj) { attr = (axiom_attribute_t *)axutil_generic_obj_get_value(obj, env); } if (attr) { proxy_port = axiom_attribute_get_value(attr, env); } if (proxy_port) { curl_easy_setopt(handler, CURLOPT_PROXYPORT, AXIS2_ATOI(proxy_port)); } } if (uname && passwd) { axis2_char_t buffer[256]; strncpy(buffer, uname, 256); strncat(buffer, ":", 256); strncat(buffer, passwd, 256); curl_easy_setopt(handler, CURLOPT_PROXYUSERPWD, buffer); } return AXIS2_SUCCESS; }
AXIS2_EXTERN void AXIS2_CALL savan_default_publisher_publish( savan_publisher_t *publishermod, const axutil_env_t *env, void *msg_ctx, savan_subs_mgr_t *subs_mgr) { savan_default_publisher_t *publishermodimpl = NULL; axutil_array_list_t *subs_store = NULL; int i = 0, size = 0; savan_filter_mod_t *filtermod = NULL; const axis2_char_t *path = NULL; axiom_node_t *payload = NULL; axiom_soap_envelope_t *envelope = NULL; axiom_soap_body_t *body = NULL; axiom_node_t *body_node = NULL; const axis2_char_t *filter = NULL; axis2_conf_ctx_t *conf_ctx = NULL; axutil_property_t *topic_property = NULL; publishermodimpl = SAVAN_INTF_TO_IMPL(publishermod); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Entry:savan_default_publisher_publish"); topic_property = axis2_msg_ctx_get_property(msg_ctx, env, ELEM_NAME_TOPIC); if(topic_property) { filter = axutil_property_get_value(topic_property, env); } axutil_allocator_switch_to_global_pool(env->allocator); if(subs_mgr) { subs_store = savan_subs_mgr_retrieve_all_subscribers(subs_mgr, env, filter); } if (!subs_store) { axutil_allocator_switch_to_local_pool(env->allocator); AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "[savan] Subscriber store is NULL"); } conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); path = axis2_conf_ctx_get_root_dir(conf_ctx, env); if(!path) { path = AXIS2_GETENV("AXIS2C_HOME"); } envelope = axis2_msg_ctx_get_soap_envelope((axis2_msg_ctx_t *) msg_ctx, env); if (!envelope) { axutil_allocator_switch_to_local_pool(env->allocator); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] Failed to extract the soap envelop"); } body = axiom_soap_envelope_get_body(envelope, env); if (!body) { axutil_allocator_switch_to_local_pool(env->allocator); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] Failed to extract the soap body"); } body_node = axiom_soap_body_get_base_node(body, env); payload = axiom_node_get_first_child(body_node, env); size = axutil_array_list_size(subs_store, env); for(i = 0; i < size; i++) { axis2_svc_client_t *svc_client = NULL; savan_subscriber_t *sub = NULL; sub = (savan_subscriber_t *)axutil_array_list_get(subs_store, env, i); if (sub) { axis2_char_t *id = savan_subscriber_get_id(sub, env); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Publishing to:%s", id); svc_client = axis2_svc_client_create(env, path); filtermod = savan_util_get_filter_module(env, publishermodimpl->conf); /* Ideally publishing to each subscriber should happen within a thread for each * subscriber. However until Axis2/C provide a good thread pool to handle * such tasks I use this sequential publishing to subscribers. */ if(!savan_default_publisher_publish_to_subscriber(publishermod, env, svc_client, sub, filtermod, payload)) { axis2_endpoint_ref_t *notifyto = savan_subscriber_get_notify_to(sub, env); const axis2_char_t *address = NULL; if(notifyto) { address = axis2_endpoint_ref_get_address(notifyto, env); } AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Publishing to the Data Sink:%s proviced by subscriber:%s Failed. Check "\ "whether the Data Sink url is correct", address, id); } if(svc_client) { axis2_svc_client_free(svc_client, env); } } } axutil_allocator_switch_to_local_pool(env->allocator); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Exit:savan_default_publisher_publish"); }
axis2_status_t wsclient_output_http_headers (const axutil_env_t *env, axis2_svc_client_t *svc_client, axis2_char_t *file_name) { axis2_op_client_t *op_client; axis2_msg_ctx_t *msg_ctx; axis2_http_client_t *client = NULL; axutil_property_t *client_property; axis2_http_simple_response_t *response = NULL; axutil_array_list_t *list = NULL; axis2_http_header_t *header; FILE *file; int i; op_client = axis2_svc_client_get_op_client(svc_client, env); if (op_client) { msg_ctx = (axis2_msg_ctx_t *) axis2_op_client_get_msg_ctx (op_client, env, AXIS2_WSDL_MESSAGE_LABEL_OUT); client_property = (axutil_property_t *)axis2_msg_ctx_get_property( msg_ctx, env, AXIS2_HTTP_CLIENT); if (client_property) client = (axis2_http_client_t *)axutil_property_get_value ( client_property, env); else return AXIS2_FAILURE; if (client) response = axis2_http_client_get_response (client, env); else return AXIS2_FAILURE; if (response) list = axis2_http_simple_response_get_headers (response, env); else return AXIS2_FAILURE; if (list) { if (!axutil_array_list_is_empty (list, env)) { if (file_name) { file = fopen (file_name, "w"); if (!file) return AXIS2_FAILURE; } else file = stdout; for (i = 0; i < axutil_array_list_size (list, env); i++) { header = (axis2_http_header_t *)axutil_array_list_get (list, env, i); fputs (axis2_http_header_to_external_form (header, env), file); } fclose (file); } } else return AXIS2_FAILURE; } return AXIS2_SUCCESS; }
axis2_status_t AXIS2_CALL axis2_libcurl_send( axis2_libcurl_t *data, axiom_output_t * om_output, const axutil_env_t * env, axis2_msg_ctx_t * msg_ctx, axiom_soap_envelope_t * out, const axis2_char_t * str_url, const axis2_char_t * soap_action) { struct curl_slist *headers = NULL; axiom_soap_body_t *soap_body; axis2_bool_t is_soap = AXIS2_TRUE; axis2_bool_t send_via_get = AXIS2_FALSE; axis2_bool_t send_via_head = AXIS2_FALSE; axis2_bool_t send_via_put = AXIS2_FALSE; axis2_bool_t send_via_delete = AXIS2_FALSE; axis2_bool_t doing_mtom = AXIS2_FALSE; axiom_node_t *body_node = NULL; axiom_node_t *data_out = NULL; axutil_property_t *method = NULL; axis2_char_t *method_value = NULL; axiom_xml_writer_t *xml_writer = NULL; axis2_char_t *buffer = NULL; unsigned int buffer_size = 0; int content_length = -1; axis2_char_t *content_type = NULL; /*axis2_char_t *content_len = AXIS2_HTTP_HEADER_CONTENT_LENGTH_; */ const axis2_char_t *char_set_enc = NULL; axis2_char_t *content = AXIS2_HTTP_HEADER_CONTENT_TYPE_; axis2_char_t *soap_action_header = AXIS2_HTTP_HEADER_SOAP_ACTION_; axutil_stream_t *in_stream; axutil_property_t *trans_in_property; axutil_string_t *char_set_enc_str; axis2_byte_t *output_stream = NULL; int output_stream_size = 0; CURL *handler; axis2_conf_ctx_t *conf_ctx = NULL; axis2_conf_t *conf = NULL; axis2_transport_out_desc_t *trans_desc = NULL; axutil_param_t *write_xml_declaration_param = NULL; axutil_hash_t *transport_attrs = NULL; axis2_bool_t write_xml_declaration = AXIS2_FALSE; axutil_property_t *property; int *response_length = NULL; axis2_http_status_line_t *status_line = NULL; axis2_char_t *status_line_str = NULL; axis2_char_t *tmp_strcat = NULL; int status_code = 0; AXIS2_PARAM_CHECK(env->error, data, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, data->handler, AXIS2_FAILURE); handler = data->handler; curl_easy_reset(handler); curl_easy_setopt(handler, CURLOPT_ERRORBUFFER, data->errorbuffer); headers = curl_slist_append(headers, AXIS2_HTTP_HEADER_USER_AGENT_AXIS2C); headers = curl_slist_append(headers, AXIS2_HTTP_HEADER_ACCEPT_); headers = curl_slist_append(headers, AXIS2_HTTP_HEADER_EXPECT_); if(AXIS2_FAILURE == axis2_libcurl_set_options(handler, env, msg_ctx)) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[axis2libcurl]Setting options in Libcurl failed"); return AXIS2_FAILURE; } if (AXIS2_TRUE == axis2_msg_ctx_get_doing_rest(msg_ctx, env)) { is_soap = AXIS2_FALSE; } else { is_soap = AXIS2_TRUE; } if (!is_soap) { soap_body = axiom_soap_envelope_get_body(out, env); if (!soap_body) { AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL, AXIS2_FAILURE); return AXIS2_FAILURE; } body_node = axiom_soap_body_get_base_node(soap_body, env); if (!body_node) { AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL, AXIS2_FAILURE); return AXIS2_FAILURE; } data_out = axiom_node_get_first_element(body_node, env); method = (axutil_property_t *) axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_HTTP_METHOD); if (method) { method_value = (axis2_char_t *) axutil_property_get_value(method, env); } /* The default is POST */ if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_GET)) { send_via_get = AXIS2_TRUE; } else if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_HEAD)) { send_via_head = AXIS2_TRUE; } else if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_PUT)) { send_via_put = AXIS2_TRUE; } else if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_DELETE)) { send_via_delete = AXIS2_TRUE; } } conf_ctx = axis2_msg_ctx_get_conf_ctx (msg_ctx, env); if (conf_ctx) { conf = axis2_conf_ctx_get_conf (conf_ctx, env); } if (conf) { trans_desc = axis2_conf_get_transport_out (conf, env, AXIS2_TRANSPORT_ENUM_HTTP); } if (trans_desc) { write_xml_declaration_param = axutil_param_container_get_param (axis2_transport_out_desc_param_container (trans_desc, env), env, AXIS2_XML_DECLARATION); } if (write_xml_declaration_param) { transport_attrs = axutil_param_get_attributes (write_xml_declaration_param, env); if (transport_attrs) { axutil_generic_obj_t *obj = NULL; axiom_attribute_t *write_xml_declaration_attr = NULL; axis2_char_t *write_xml_declaration_attr_value = NULL; obj = axutil_hash_get (transport_attrs, AXIS2_ADD_XML_DECLARATION, AXIS2_HASH_KEY_STRING); if (obj) { write_xml_declaration_attr = (axiom_attribute_t *) axutil_generic_obj_get_value (obj, env); } if (write_xml_declaration_attr) { write_xml_declaration_attr_value = axiom_attribute_get_value (write_xml_declaration_attr, env); } if (write_xml_declaration_attr_value && 0 == axutil_strcasecmp (write_xml_declaration_attr_value, AXIS2_VALUE_TRUE)) { write_xml_declaration = AXIS2_TRUE; } } } if (write_xml_declaration) { axiom_output_write_xml_version_encoding (om_output, env); } if (!send_via_get && !send_via_head && !send_via_delete) { xml_writer = axiom_output_get_xml_writer(om_output, env); char_set_enc_str = axis2_msg_ctx_get_charset_encoding(msg_ctx, env); if (!char_set_enc_str) { char_set_enc = AXIS2_DEFAULT_CHAR_SET_ENCODING; } else { char_set_enc = axutil_string_get_buffer(char_set_enc_str, env); } if (!send_via_put && is_soap) { doing_mtom = axis2_msg_ctx_get_doing_mtom(msg_ctx, env); axiom_output_set_do_optimize(om_output, env, doing_mtom); axiom_soap_envelope_serialize(out, env, om_output, AXIS2_FALSE); if (AXIS2_TRUE == axis2_msg_ctx_get_is_soap_11(msg_ctx, env)) { if (AXIS2_ESC_DOUBLE_QUOTE != *soap_action) { axis2_char_t *tmp_soap_action = NULL; tmp_soap_action = AXIS2_MALLOC(env->allocator, (axutil_strlen(soap_action) + 5) * sizeof(axis2_char_t)); sprintf(tmp_soap_action, "\"%s\"", soap_action); tmp_strcat = axutil_stracat(env, soap_action_header,tmp_soap_action); headers = curl_slist_append(headers, tmp_strcat); AXIS2_FREE(env->allocator, tmp_strcat); AXIS2_FREE(env->allocator, tmp_soap_action); } else { tmp_strcat = axutil_stracat(env, soap_action_header, soap_action); headers = curl_slist_append(headers, tmp_strcat ); AXIS2_FREE(env->allocator, tmp_strcat); } } if (doing_mtom) { /*axiom_output_flush(om_output, env, &output_stream, &output_stream_size);*/ axiom_output_flush(om_output, env); content_type = (axis2_char_t *) axiom_output_get_content_type(om_output, env); if (AXIS2_TRUE != axis2_msg_ctx_get_is_soap_11(msg_ctx, env)) { if (axutil_strcmp(soap_action, "")) { /* handle SOAP action for SOAP 1.2 case */ axis2_char_t *temp_content_type = NULL; temp_content_type = axutil_stracat (env, content_type, AXIS2_CONTENT_TYPE_ACTION); content_type = temp_content_type; temp_content_type = axutil_stracat (env, content_type, soap_action); AXIS2_FREE (env->allocator, content_type); content_type = temp_content_type; temp_content_type = axutil_stracat (env, content_type, AXIS2_ESC_DOUBLE_QUOTE_STR); AXIS2_FREE (env->allocator, content_type); content_type = temp_content_type; } } } else if (AXIS2_TRUE == axis2_msg_ctx_get_is_soap_11(msg_ctx, env)) { axis2_char_t *temp_content_type = NULL; content_type = (axis2_char_t *) AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML; content_type = axutil_stracat(env, content_type, AXIS2_CONTENT_TYPE_CHARSET); temp_content_type = axutil_stracat(env, content_type, char_set_enc); AXIS2_FREE(env->allocator, content_type); content_type = temp_content_type; } else { axis2_char_t *temp_content_type = NULL; content_type = (axis2_char_t *) AXIS2_HTTP_HEADER_ACCEPT_APPL_SOAP; content_type = axutil_stracat(env, content_type, AXIS2_CONTENT_TYPE_CHARSET); temp_content_type = axutil_stracat(env, content_type, char_set_enc); AXIS2_FREE(env->allocator, content_type); content_type = temp_content_type; if (axutil_strcmp(soap_action, "")) { temp_content_type = axutil_stracat(env, content_type, AXIS2_CONTENT_TYPE_ACTION); AXIS2_FREE(env->allocator, content_type); content_type = temp_content_type; temp_content_type = axutil_stracat(env, content_type, soap_action); AXIS2_FREE(env->allocator, content_type); content_type = temp_content_type; } temp_content_type = axutil_stracat(env, content_type, AXIS2_SEMI_COLON_STR); AXIS2_FREE(env->allocator, content_type); content_type = temp_content_type; } } else if (is_soap) { AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "Attempt to send SOAP" "message using HTTP PUT failed"); return AXIS2_FAILURE; } else { axutil_property_t *content_type_property = NULL; axutil_hash_t *content_type_hash = NULL; axis2_char_t *content_type_value = NULL; axiom_node_serialize(data_out, env, om_output); content_type_property = (axutil_property_t *) axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_USER_DEFINED_HTTP_HEADER_CONTENT_TYPE); if (content_type_property) { content_type_hash = (axutil_hash_t *) axutil_property_get_value(content_type_property, env); if (content_type_hash) { content_type_value = (char *) axutil_hash_get(content_type_hash, AXIS2_HTTP_HEADER_CONTENT_TYPE, AXIS2_HASH_KEY_STRING); } } if (content_type_value) { content_type = content_type_value; } else { content_type = axutil_strdup(env,AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML); } } buffer = axiom_xml_writer_get_xml(xml_writer, env); if (!doing_mtom) { buffer_size = axiom_xml_writer_get_xml_size(xml_writer, env); } else buffer_size = output_stream_size; { /* * Curl calculates the content-length automatically. * This commented section is not only unnecessary, * it interferes with authentication. * * NTLM, for example, will send an empty request * first (no body) to get the auth challenge * before resending with actual content. */ /*char tmp_buf[10]; sprintf(tmp_buf, "%d", buffer_size); tmp_strcat = axutil_stracat(env, content_len, tmp_buf); headers = curl_slist_append(headers, tmp_strcat); AXIS2_FREE(env->allocator, tmp_strcat); tmp_strcat = NULL;*/ tmp_strcat = axutil_stracat(env, content, content_type); headers = curl_slist_append(headers, tmp_strcat); AXIS2_FREE(env->allocator, tmp_strcat); tmp_strcat = NULL; } if (!doing_mtom) { curl_easy_setopt(handler, CURLOPT_POSTFIELDSIZE, buffer_size); curl_easy_setopt(handler, CURLOPT_POSTFIELDS, buffer); } else { curl_easy_setopt(handler, CURLOPT_POSTFIELDSIZE, output_stream_size); curl_easy_setopt(handler, CURLOPT_POSTFIELDS, output_stream); } if (send_via_put) { curl_easy_setopt(handler, CURLOPT_CUSTOMREQUEST, AXIS2_HTTP_PUT); } curl_easy_setopt(handler, CURLOPT_URL, str_url); } else { axis2_char_t *request_param; axis2_char_t *url_encode; request_param = (axis2_char_t *) axis2_http_sender_get_param_string(NULL, env, msg_ctx); url_encode = axutil_strcat(env, str_url, AXIS2_Q_MARK_STR, request_param, NULL); if (send_via_get) { curl_easy_setopt(handler, CURLOPT_HTTPGET, 1); } else if (send_via_head) { curl_easy_setopt(handler, CURLOPT_NOBODY, 1); } else if (send_via_delete) { curl_easy_setopt(handler, CURLOPT_CUSTOMREQUEST, AXIS2_HTTP_DELETE); } curl_easy_setopt(handler, CURLOPT_URL, url_encode); } { axis2_bool_t manage_session; manage_session = axis2_msg_ctx_get_manage_session(msg_ctx, env); if (manage_session == AXIS2_TRUE) { if (data->cookies == AXIS2_FALSE) { /* Ensure cookies enabled to manage session */ /* Pass empty cookie string to enable cookies */ curl_easy_setopt(handler, CURLOPT_COOKIEFILE, " "); data->cookies = AXIS2_TRUE; } } else if (data->cookies == AXIS2_TRUE) { /* Pass special string ALL to reset cookies if any have been enabled. */ /* If cookies have ever been enabled, we reset every time as long as manage_session is false, as there is no clear curl option to turn off the cookie engine once enabled. */ curl_easy_setopt(handler, CURLOPT_COOKIELIST, AXIS2_ALL); } } curl_easy_setopt(handler, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(handler, CURLOPT_WRITEFUNCTION, axis2_libcurl_write_memory_callback); curl_easy_setopt(handler, CURLOPT_WRITEDATA, data); curl_easy_setopt (handler, CURLOPT_HEADERFUNCTION, axis2_libcurl_header_callback); curl_easy_setopt (handler, CURLOPT_WRITEHEADER, data); /* Free response data from previous request */ if( data->size ) { if (data->memory) { AXIS2_FREE(data->env->allocator, data->memory); } data->size = 0; } if (curl_easy_perform(handler)) { AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "%s", &data->errorbuffer); AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_HTTP_CLIENT_TRANSPORT_ERROR, AXIS2_FAILURE); return AXIS2_FAILURE; } in_stream = axutil_stream_create_libcurl(env, data->memory, data->size); trans_in_property = axutil_property_create(env); axutil_property_set_scope(trans_in_property, env, AXIS2_SCOPE_REQUEST); axutil_property_set_free_func(trans_in_property, env, libcurl_stream_free); axutil_property_set_value(trans_in_property, env, in_stream); axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_TRANSPORT_IN, trans_in_property); if (axutil_array_list_size(data->alist, env) > 0) { status_line_str = axutil_array_list_get(data->alist, env, 0); if (status_line_str) { status_line = axis2_http_status_line_create(env, status_line_str); } } if (status_line) { status_code = axis2_http_status_line_get_status_code(status_line, env); } axis2_msg_ctx_set_status_code (msg_ctx, env, status_code); AXIS2_FREE(data->env->allocator, content_type); content_type = axis2_libcurl_get_content_type(data, env); if (content_type) { if (strstr (content_type, AXIS2_HTTP_HEADER_ACCEPT_MULTIPART_RELATED) && strstr (content_type, AXIS2_HTTP_HEADER_ACCEPT_XOP_XML)) { axis2_ctx_t *axis_ctx = axis2_op_ctx_get_base (axis2_msg_ctx_get_op_ctx (msg_ctx, env), env); property = axutil_property_create (env); axutil_property_set_scope (property, env, AXIS2_SCOPE_REQUEST); axutil_property_set_value (property, env, axutil_strdup (env, content_type)); axis2_ctx_set_property (axis_ctx, env, MTOM_RECIVED_CONTENT_TYPE, property); } } content_length = axis2_libcurl_get_content_length(data, env); if (content_length >= 0) { response_length = AXIS2_MALLOC (env->allocator, sizeof (int)); memcpy (response_length, &content_length, sizeof (int)); property = axutil_property_create (env); axutil_property_set_scope (property, env, AXIS2_SCOPE_REQUEST); axutil_property_set_value (property, env, response_length); axis2_msg_ctx_set_property (msg_ctx, env, AXIS2_HTTP_HEADER_CONTENT_LENGTH, property); } curl_slist_free_all (headers); /* release the read http headers. */ /* (commenting out the call below is a clever way to force a premature EOF condition in subsequent messages, as they will be read using the content-length of the first message.) */ axis2_libcurl_free_headers(data, env); AXIS2_FREE(data->env->allocator, content_type); axis2_http_status_line_free( status_line, env); return AXIS2_SUCCESS; }
/* This is the function where threads start running */ void *AXIS2_THREAD_FUNC axis2_udp_receiver_thread_worker_func( axutil_thread_t * thd, void *data) { const axutil_env_t *env = NULL; axis2_status_t status = AXIS2_FAILURE; axis2_conf_t *conf = NULL; axis2_svc_t *svc = NULL; axis2_udp_recv_thd_args_t *args = NULL; axis2_udp_response_t response; axutil_hash_index_t *hi = NULL; axutil_hash_t *ori_all_svcs = NULL, *all_svcs = NULL; void *val = NULL; args = (axis2_udp_recv_thd_args_t *) data; env = (axutil_env_t *) args->env; conf = axis2_conf_ctx_get_conf(args->conf_ctx, env); /* Get all the service discriptions */ ori_all_svcs = axis2_conf_get_all_svcs(conf, env); if (!ori_all_svcs) { return NULL; } all_svcs = axutil_hash_copy(ori_all_svcs, env); if (args->is_multicast) { /* If multicast we go through every service and try to figure out weather they are accepting multicast messages. If a service accepts a multicast message we send the request to that service bypassing the normal dispatchers. Dispatchers cannot be used since no dispatching information is found in the multicast messages */ for (hi = axutil_hash_first(all_svcs, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, NULL, NULL, &val); svc = (axis2_svc_t *) val; if (svc) { axutil_param_t *param = NULL; axis2_char_t *param_val = NULL; /* Get the Multicast accept parameter from the services.xml */ param = axis2_svc_get_param(svc, env, AXIS2_UDP_MULTICAST_ACCEPT); if (!param) { continue; } /* check weather this service accepts multicast requests */ param_val = axutil_param_get_value(param, env); if (!param_val || !axutil_strcmp(param_val, "false") || axutil_strcmp(param_val, "true")) { continue; } response.buf_size = 0; response.buff = NULL; /* set the service to the request. This will bypass the dispatches */ args->request.svc = svc; /* Process the request */ status = axis2_udp_receiver_process_request(args->env, args->conf_ctx, &args->request, &response); if (status == AXIS2_FAILURE) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error processing the request."); return NULL; } /* If we have a response send it */ if (response.buff) { status = axutil_network_handler_send_dgram(env, args->send_socket, response.buff, &response.buf_size, args->req_addr, args->req_port, NULL); if (status == AXIS2_FAILURE) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error sending the response."); return NULL; } } } } } else { axis2_ctx_t *ctx = NULL; axutil_property_t *prop = NULL; axis2_udp_backchannel_info_t *binfo = NULL; ctx = axis2_conf_ctx_get_base(args->conf_ctx, env); prop = axis2_ctx_get_property(ctx, env, AXIS2_UDP_BACKCHANNEL_INFO); if (prop) { binfo = axutil_property_get_value(prop, env); } /* Unicast case. In this case message contains dispatching information. * So we send the request in the normal way */ response.buf_size = 0; response.buff = NULL; if (binfo) { args->request.svc = binfo->svc; args->request.op = binfo->op; } /* Process the request */ status = axis2_udp_receiver_process_request(args->env, args->conf_ctx, &args->request, &response); if (status == AXIS2_FAILURE) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error processing the request."); return NULL; } /* If we have a response send it */ if (response.buff) { status = axutil_network_handler_send_dgram(env, args->send_socket, response.buff, &response.buf_size, args->req_addr, args->req_port, NULL); if (status == AXIS2_FAILURE) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error sending the response."); return NULL; } } } return NULL; }
axis2_status_t AXIS2_CALL axis2_addr_out_handler_invoke( struct axis2_handler * handler, const axutil_env_t * env, axis2_msg_ctx_t * msg_ctx) { axis2_char_t *addr_ver_from_msg_ctx = NULL; const axis2_char_t *addr_ns = NULL; axis2_msg_info_headers_t *msg_info_headers = NULL; axis2_ctx_t *ctx = NULL; axiom_soap_envelope_t *soap_envelope = NULL; axiom_soap_header_t *soap_header = NULL; axiom_node_t *soap_header_node = NULL; axiom_element_t *soap_header_ele = NULL; axis2_endpoint_ref_t *epr_to = NULL; axis2_endpoint_ref_t *epr_reply_to = NULL; axis2_endpoint_ref_t *epr_from = NULL; axis2_endpoint_ref_t *epr_fault_to = NULL; axutil_property_t *property = NULL; const axis2_char_t *wsa_action = NULL; axis2_bool_t set_must_understand = AXIS2_FALSE; axutil_property_t *must_understand_prop; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE); AXIS2_LOG_INFO(env->log, "Starting addressing out handler"); soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env); if(!soap_envelope) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No SOAP envelope. Stop processing addressing"); return AXIS2_SUCCESS; /* Can happen in case of ONE-WAY services/clients */ } msg_info_headers = axis2_msg_ctx_get_msg_info_headers(msg_ctx, env); if(msg_info_headers) { wsa_action = axis2_msg_info_headers_get_action(msg_info_headers, env); } else { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No addressing in use"); return AXIS2_SUCCESS; /* No addressing in use */ } if(!wsa_action || !*wsa_action) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No action present. Stop processing addressing"); return AXIS2_SUCCESS; /* If no action present, assume no addressing in use */ } ctx = axis2_msg_ctx_get_base(msg_ctx, env); property = axis2_ctx_get_property(ctx, env, AXIS2_WSA_VERSION); if(property) { addr_ver_from_msg_ctx = axutil_property_get_value(property, env); property = NULL; } must_understand_prop = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_ADDR_ADD_MUST_UNDERSTAND_TO_ADDR_HEADERS); if(must_understand_prop) { axis2_char_t *value = axutil_property_get_value(must_understand_prop, env); if(axutil_strcmp(value, AXIS2_VALUE_TRUE) == 0) set_must_understand = AXIS2_TRUE; } /* Setting version 1.0 as the default addressing namespace */ addr_ns = AXIS2_WSA_NAMESPACE; if(addr_ver_from_msg_ctx) { if(!axutil_strcmp(AXIS2_WSA_NAMESPACE_SUBMISSION, addr_ver_from_msg_ctx)) { addr_ns = AXIS2_WSA_NAMESPACE_SUBMISSION; } } else if(axis2_msg_ctx_get_op_ctx(msg_ctx, env)) { axis2_op_ctx_t *op_ctx = NULL; axis2_msg_ctx_t *in_msg_ctx = NULL; op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env); if(op_ctx) { in_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN); } if(in_msg_ctx) { axis2_ctx_t *in_ctx = NULL; in_ctx = axis2_msg_ctx_get_base(in_msg_ctx, env); property = axis2_ctx_get_property(in_ctx, env, AXIS2_WSA_VERSION); if(property) { addr_ns = axutil_property_get_value(property, env); property = NULL; } if(!addr_ns || !*addr_ns) { addr_ns = AXIS2_WSA_NAMESPACE; } } } soap_header = axiom_soap_envelope_get_header(soap_envelope, env); if(!soap_header) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No SOAP header. Stop processing addressing"); return AXIS2_SUCCESS; /* No SOAP header, so no point proceeding */ } else { /* By this time, we definitely have some addressing information to be sent. This is because, * we have tested at the start of this whether msg_info_headers are null or not. * So rather than declaring addressing namespace in each and every addressing header, lets * define that in the Header itself. */ const axis2_char_t *action = NULL; const axis2_char_t *address = NULL; const axis2_char_t *svc_group_context_id = NULL; const axis2_char_t *message_id = NULL; axis2_relates_to_t *relates_to = NULL; axiom_node_t *relates_to_header_node = NULL; axiom_element_t *relates_to_header_ele = NULL; axiom_namespace_t *addressing_namespace = NULL; soap_header_node = axiom_soap_header_get_base_node(soap_header, env); soap_header_ele = (axiom_element_t *)axiom_node_get_data_element(soap_header_node, env); addressing_namespace = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX); axiom_element_declare_namespace(soap_header_ele, env, soap_header_node, addressing_namespace); epr_to = axis2_msg_info_headers_get_to(msg_info_headers, env); if(epr_to) { axiom_soap_body_t *body = axiom_soap_envelope_get_body(soap_envelope, env); if(body) { /* In case of a SOAP fault, we got to send the response to the adress specified by FaultTo */ if(axiom_soap_body_has_fault(body, env)) { axis2_endpoint_ref_t *epr_fault_to = axis2_msg_info_headers_get_fault_to( msg_info_headers, env); if(epr_fault_to) { const axis2_char_t *fault_to_address = axis2_endpoint_ref_get_address( epr_fault_to, env); if(fault_to_address) { if(axutil_strcmp(AXIS2_WSA_NONE_URL, fault_to_address) && axutil_strcmp(AXIS2_WSA_NONE_URL_SUBMISSION, fault_to_address)) { axis2_endpoint_ref_set_address(epr_to, env, fault_to_address); } } } } } address = axis2_endpoint_ref_get_address(epr_to, env); if(address && *address) { axiom_node_t *to_header_block_node = NULL; axiom_soap_header_block_t *to_header_block = NULL; axutil_array_list_t *ref_param_list = NULL; int size = 0; to_header_block = axiom_soap_header_add_header_block(soap_header, env, AXIS2_WSA_TO, addressing_namespace); if(set_must_understand == AXIS2_TRUE) { axiom_soap_header_block_set_must_understand_with_bool(to_header_block, env, AXIS2_TRUE); } to_header_block_node = axiom_soap_header_block_get_base_node(to_header_block, env); if(to_header_block_node) { axiom_element_t *to_header_block_element = NULL; to_header_block_element = (axiom_element_t *)axiom_node_get_data_element( to_header_block_node, env); if(to_header_block_element) { axiom_element_set_text(to_header_block_element, env, address, to_header_block_node); } } ref_param_list = axis2_endpoint_ref_get_ref_param_list(epr_to, env); size = axutil_array_list_size(ref_param_list, env); if(ref_param_list && size > 0) { axiom_soap_header_block_t *reference_header_block = NULL; axiom_node_t *reference_node = NULL; int i = 0; for(i = 0; i < size; i++) { axiom_node_t *temp_node = NULL; temp_node = (axiom_node_t *)axutil_array_list_get(ref_param_list, env, i); if(temp_node) { axiom_element_t *temp_ele = NULL; temp_ele = axiom_node_get_data_element(temp_node, env); if(temp_ele) { reference_header_block = axiom_soap_header_add_header_block( soap_header, env, axiom_element_get_localname(temp_ele, env), axiom_element_get_namespace(temp_ele, env, temp_node)); if(set_must_understand) { axiom_soap_header_block_set_must_understand_with_bool(reference_header_block, env, AXIS2_TRUE); } reference_node = axiom_soap_header_block_get_base_node( reference_header_block, env); if(reference_node) { axiom_element_t *reference_ele = NULL; reference_ele = (axiom_element_t *)axiom_node_get_data_element( reference_node, env); if(reference_ele) { axiom_namespace_t *addr_ns_obj = NULL; axiom_attribute_t *reference_attr = NULL; addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX); reference_attr = axiom_attribute_create(env, /*"isReferenceParameter"*/ AXIS2_WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE, "true", addr_ns_obj); axiom_element_add_attribute(reference_ele, env, reference_attr, reference_node); axiom_element_set_text(reference_ele, env, axiom_element_get_text(temp_ele, env, temp_node), reference_node); } } } } } } } }/* if(epr_to) */ axiom_namespace_free(addressing_namespace, env); action = axis2_msg_info_headers_get_action(msg_info_headers, env); if(action && *action) { axis2_addr_out_handler_process_string_info(env, action, AXIS2_WSA_ACTION, &soap_header, addr_ns, set_must_understand); } epr_reply_to = axis2_msg_info_headers_get_reply_to(msg_info_headers, env); if(!epr_reply_to) { const axis2_char_t *anonymous_uri = NULL; axis2_bool_t anonymous = axis2_msg_info_headers_get_reply_to_anonymous( msg_info_headers, env); axis2_bool_t none = axis2_msg_info_headers_get_reply_to_none(msg_info_headers, env); if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION)) { if(none) { anonymous_uri = AXIS2_WSA_NONE_URL_SUBMISSION; } else if(anonymous) { anonymous_uri = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION; } } else { if(none) { anonymous_uri = AXIS2_WSA_NONE_URL; } else if(anonymous) { anonymous_uri = AXIS2_WSA_ANONYMOUS_URL; } } if(anonymous_uri) { epr_reply_to = axis2_endpoint_ref_create(env, anonymous_uri); } if(epr_reply_to) { axis2_msg_info_headers_set_reply_to(msg_info_headers, env, epr_reply_to); } } /* add the service group id as a reference parameter */ svc_group_context_id = axutil_string_get_buffer(axis2_msg_ctx_get_svc_grp_ctx_id(msg_ctx, env), env); axis2_addr_out_handler_add_to_soap_header(env, epr_reply_to, AXIS2_WSA_REPLY_TO, soap_header, addr_ns); epr_from = axis2_msg_info_headers_get_from(msg_info_headers, env); if(epr_from) { axis2_addr_out_handler_add_to_soap_header(env, epr_from, AXIS2_WSA_FROM, soap_header, addr_ns); } epr_fault_to = axis2_msg_info_headers_get_fault_to(msg_info_headers, env); if(!epr_fault_to) { const axis2_char_t *anonymous_uri = NULL; axis2_bool_t anonymous = axis2_msg_info_headers_get_fault_to_anonymous( msg_info_headers, env); axis2_bool_t none = axis2_msg_info_headers_get_fault_to_none(msg_info_headers, env); if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION)) { if(none) { anonymous_uri = AXIS2_WSA_NONE_URL_SUBMISSION; } else if(anonymous) { anonymous_uri = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION; } } else { if(none) anonymous_uri = AXIS2_WSA_NONE_URL; else if(anonymous) anonymous_uri = AXIS2_WSA_ANONYMOUS_URL; } if(anonymous_uri) { epr_fault_to = axis2_endpoint_ref_create(env, anonymous_uri); } } if(epr_fault_to) { /* optional */ axis2_addr_out_handler_add_to_soap_header(env, epr_fault_to, AXIS2_WSA_FAULT_TO, soap_header, addr_ns); } message_id = axis2_msg_info_headers_get_message_id(msg_info_headers, env); if(message_id) { axis2_addr_out_handler_process_string_info(env, message_id, AXIS2_WSA_MESSAGE_ID, &soap_header, addr_ns, set_must_understand); } relates_to = axis2_msg_info_headers_get_relates_to(msg_info_headers, env); if(relates_to) { const axis2_char_t *value = NULL; value = axis2_relates_to_get_value(relates_to, env); relates_to_header_node = axis2_addr_out_handler_process_string_info(env, value, AXIS2_WSA_RELATES_TO, &soap_header, addr_ns, set_must_understand); } if(relates_to_header_node) { const axis2_char_t *relationship_type = NULL; relationship_type = axis2_relates_to_get_relationship_type(relates_to, env); if(relationship_type && *relationship_type) { axiom_attribute_t *om_attr = NULL; axiom_namespace_t *addr_ns_obj = NULL; axiom_namespace_t *dec_ns = NULL; relates_to_header_ele = (axiom_element_t *)axiom_node_get_data_element( relates_to_header_node, env); if(relates_to_header_ele) { dec_ns = axiom_element_find_declared_namespace(relates_to_header_ele, env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX); if(dec_ns) { addr_ns_obj = dec_ns; } else { addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX); } if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION)) { om_attr = axiom_attribute_create(env, AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE, AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE_SUBMISSION, addr_ns_obj); } else { om_attr = axiom_attribute_create(env, AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE, AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE, addr_ns_obj); } axiom_element_add_attribute(relates_to_header_ele, env, om_attr, relates_to_header_node); dec_ns = axiom_element_find_declared_namespace(relates_to_header_ele, env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX); if(!dec_ns) { dec_ns = axiom_element_find_namespace(relates_to_header_ele, env, relates_to_header_node, addr_ns, AXIS2_WSA_DEFAULT_PREFIX); if(dec_ns) { axiom_namespace_free(addr_ns_obj, env); addr_ns_obj = NULL; axiom_attribute_set_namespace(om_attr, env, dec_ns); } } } } } } return AXIS2_SUCCESS; }
/** * This function is invoked in RM 1.1 where client explicitly send the * terminate sequence message */ static axis2_status_t AXIS2_CALL sandesha2_terminate_seq_msg_processor_process_out_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_seq_property_mgr_t *seq_prop_mgr = NULL; sandesha2_create_seq_mgr_t *create_seq_mgr = NULL; sandesha2_sender_mgr_t *sender_mgr = NULL; axis2_char_t *to_address = NULL; axis2_char_t *seq_key = NULL; axis2_char_t *int_seq_id = NULL; axis2_char_t *out_seq_id = NULL; axutil_property_t *property = NULL; axis2_char_t *terminated = NULL; axis2_op_t *old_op = NULL; axis2_op_t *out_in_op = NULL; axutil_qname_t *qname = NULL; sandesha2_terminate_seq_t *term_seq_part = NULL; axis2_char_t *rm_version = NULL; axis2_char_t *transport_to = NULL; sandesha2_seq_property_bean_t *term_added = NULL; axis2_char_t *temp_action = NULL; axutil_string_t *soap_action = NULL; axis2_char_t *dbname = NULL; AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Entry:sandesha2_terminate_seq_msg_processor_process_out_msg."); 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; } 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); to_address = (axis2_char_t*)axis2_endpoint_ref_get_address(axis2_msg_ctx_get_to(msg_ctx, env), env); property = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_CLIENT_SEQ_KEY); if(property) { seq_key = axutil_property_get_value(property, env); } int_seq_id = sandesha2_utils_get_client_internal_sequence_id(env, to_address, seq_key); out_seq_id = sandesha2_utils_get_seq_property(env, int_seq_id, SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_SEQUENCE_ID, seq_prop_mgr); if(!out_seq_id) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]seq_id was not found. Cannot send the terminate message"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_SEQ_ID, AXIS2_FAILURE); 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; } terminated = sandesha2_utils_get_seq_property(env, int_seq_id, SANDESHA2_SEQ_PROP_TERMINATE_ADDED, seq_prop_mgr); old_op = axis2_msg_ctx_get_op(msg_ctx, env); qname = axutil_qname_create(env, "temp", NULL, NULL); out_in_op = axis2_op_create_with_qname(env, qname); if(qname) { axutil_qname_free(qname, env); } axis2_op_set_msg_exchange_pattern(out_in_op, env, AXIS2_MEP_URI_OUT_IN); axis2_op_set_in_flow(out_in_op, env, axis2_op_get_in_flow(old_op, env)); if(terminated && !axutil_strcmp(terminated, AXIS2_VALUE_TRUE)) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Terminate was added previously"); if(terminated) { AXIS2_FREE(env->allocator, terminated); } if(out_seq_id) { AXIS2_FREE(env->allocator, out_seq_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); } return AXIS2_SUCCESS; } if(terminated) { AXIS2_FREE(env->allocator, terminated); } term_seq_part = sandesha2_msg_ctx_get_terminate_seq(rm_msg_ctx, env); sandesha2_identifier_set_identifier(sandesha2_terminate_seq_get_identifier(term_seq_part, env), env, out_seq_id); sandesha2_msg_ctx_set_flow(rm_msg_ctx, env, AXIS2_OUT_FLOW); property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE); axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, property); axis2_msg_ctx_set_to(msg_ctx, env, axis2_endpoint_ref_create(env, to_address)); rm_version = sandesha2_utils_get_rm_version(env, msg_ctx); if(!rm_version) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cant find the rm_version of the given message"); if(out_seq_id) { AXIS2_FREE(env->allocator, out_seq_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); } return AXIS2_FAILURE; } axis2_msg_ctx_set_wsa_action(msg_ctx, env, sandesha2_spec_specific_consts_get_terminate_seq_action(env, rm_version)); temp_action = sandesha2_spec_specific_consts_get_terminate_seq_soap_action(env, rm_version); soap_action = axutil_string_create(env, temp_action); axis2_msg_ctx_set_soap_action(msg_ctx, env, soap_action); transport_to = sandesha2_utils_get_seq_property(env, int_seq_id, SANDESHA2_SEQ_PROP_TRANSPORT_TO, seq_prop_mgr); if(transport_to) { axis2_msg_ctx_set_transport_url(msg_ctx, env, transport_to); AXIS2_FREE(env->allocator, transport_to); } if(!sandesha2_util_is_ack_already_piggybacked(env, rm_msg_ctx)) { sandesha2_ack_mgr_piggyback_acks_if_present(env, out_seq_id, rm_msg_ctx, storage_mgr, seq_prop_mgr, sender_mgr); } term_added = sandesha2_seq_property_bean_create(env); sandesha2_seq_property_bean_set_name(term_added, env, SANDESHA2_SEQ_PROP_TERMINATE_ADDED); sandesha2_seq_property_bean_set_seq_id(term_added, env, int_seq_id); if(out_seq_id) { AXIS2_FREE(env->allocator, out_seq_id); } sandesha2_seq_property_bean_set_value(term_added, env, AXIS2_VALUE_TRUE); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, term_added); 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_terminate_seq_msg_processor_process_out_msg"); return AXIS2_SUCCESS; }
axis2_status_t AXIS2_CALL wsf_xml_msg_recv_invoke_business_logic_sync( axis2_msg_recv_t * msg_recv, const axutil_env_t * env, axis2_msg_ctx_t * in_msg_ctx, axis2_msg_ctx_t * out_msg_ctx) { axis2_op_ctx_t *op_ctx = NULL; axis2_op_t *op_desc = NULL; axiom_namespace_t *env_ns = NULL; int soap_version = AXIOM_SOAP12; axis2_status_t status = AXIS2_SUCCESS; axis2_bool_t skel_invoked = AXIS2_FALSE; const axis2_char_t *style = NULL; axis2_char_t *local_name = NULL; axis2_char_t *soap_ns = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; axis2_char_t *operation_name = NULL; char *classname = NULL; axutil_property_t *svc_info_prop = NULL; axutil_property_t *req_info_prop = NULL; wsf_svc_info_t *svc_info = NULL; wsf_request_info_t *req_info = NULL; /** store in_msg_ctx envelope */ axiom_soap_envelope_t *envelope = NULL; axiom_soap_body_t *body = NULL; axiom_node_t *in_body_node = NULL; /* store out_msg_ctx envelope */ axiom_soap_envelope_t *default_envelope = NULL; axiom_soap_body_t *out_body = NULL; axiom_soap_header_t *out_header = NULL; axiom_soap_fault_t *out_soap_fault = NULL; axiom_node_t *result_node = NULL; axiom_node_t *out_body_content_node = NULL; axiom_element_t *out_body_content_element = NULL; axiom_node_t *out_node = NULL; zval **output_headers_zval = NULL; TSRMLS_FETCH(); AXIS2_PARAM_CHECK(env->error, in_msg_ctx, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, out_msg_ctx, AXIS2_FAILURE); op_ctx = axis2_msg_ctx_get_op_ctx(in_msg_ctx, env); op_desc = axis2_op_ctx_get_op(op_ctx, env); style = axis2_op_get_style(op_desc, env); envelope = axis2_msg_ctx_get_soap_envelope(in_msg_ctx, env); body = axiom_soap_envelope_get_body(envelope, env); in_body_node = axiom_soap_body_get_base_node(body, env); if (0 == axutil_strcmp(AXIS2_STYLE_DOC, style)) { local_name = wsf_xml_msg_recv_get_method_name(in_msg_ctx, env); if (!local_name) { return AXIS2_FAILURE; } } else if (0 == axutil_strcmp(AXIS2_STYLE_RPC, style)) { axiom_node_t *op_node = NULL; axiom_element_t *op_element = NULL; op_node = axiom_node_get_first_child(in_body_node, env); if (!op_node) { return AXIS2_FAILURE; } op_element = axiom_node_get_data_element(op_node, env); if (!op_element) { return AXIS2_FAILURE; } local_name = axiom_element_get_localname(op_element, env); if (!local_name) { return AXIS2_FAILURE; } } /** set soap version and soap namespace to local variables */ if (in_msg_ctx && axis2_msg_ctx_get_is_soap_11(in_msg_ctx, env)) { soap_ns = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; /* default is 1.2 */ soap_version = AXIOM_SOAP11; } svc_info_prop = axis2_msg_ctx_get_property(in_msg_ctx, env, WSF_SVC_INFO); if (svc_info_prop) { svc_info = (wsf_svc_info_t *) axutil_property_get_value(svc_info_prop, env); if (svc_info) { operation_name = axutil_hash_get(svc_info->ops_to_functions, local_name, AXIS2_HASH_KEY_STRING); if (!operation_name) { return AXIS2_FAILURE; } } else { return AXIS2_FAILURE; } if (svc_info->ops_to_classes) { classname = axutil_hash_get(svc_info->ops_to_classes, local_name, AXIS2_HASH_KEY_STRING); } } req_info_prop = axis2_msg_ctx_get_property(in_msg_ctx, env, WSF_REQ_INFO); if (req_info_prop) { req_info = (wsf_request_info_t *) axutil_property_get_value(req_info_prop, env); if (axis2_msg_ctx_get_doing_rest(in_msg_ctx, env)) { axis2_op_t *op = NULL; axiom_node_t *body_child_node = NULL; axiom_element_t *body_child = NULL; int i = 0; body_child_node = axiom_node_get_first_child(in_body_node, env); if (!body_child_node) { op = axis2_msg_ctx_get_op(in_msg_ctx, env); if (op) { body_child = axiom_element_create_with_qname(env, NULL, axis2_op_get_qname(op, env), &body_child_node); axiom_soap_body_add_child(body, env, body_child_node); } } if (req_info->param_keys && req_info->param_values) { int i = 0; for (i = 0; i < axutil_array_list_size(req_info->param_keys, env); i++) { axiom_node_t *node = NULL; axiom_element_t *element = NULL; axis2_char_t *param_key = NULL; axis2_char_t *param_value = NULL; param_key = axutil_array_list_get(req_info->param_keys, env, i); param_value = axutil_array_list_get(req_info->param_values, env, i); element = axiom_element_create(env, NULL, param_key, NULL, &node); axiom_element_set_text(element, env, param_value, node); axiom_node_add_child(body_child_node, env, node); AXIS2_FREE(env->allocator, param_key); AXIS2_FREE(env->allocator, param_value); } axutil_array_list_free(req_info->param_keys, env); axutil_array_list_free(req_info->param_values, env); } } } if (svc_info->ht_op_params) { zval **tmp; char *function_type = NULL; if (zend_hash_find(svc_info->ht_op_params, operation_name, strlen(operation_name) + 1, (void **) & tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_STRING) { function_type = Z_STRVAL_PP(tmp); if (strcmp(function_type, WSF_MIXED) == 0) { result_node = wsf_xml_msg_recv_invoke_mixed(env, svc_info, in_msg_ctx, out_msg_ctx, operation_name, classname, &output_headers_zval TSRMLS_CC); } else if (strcmp(function_type, WSF_WSMESSAGE) == 0) { result_node = wsf_xml_msg_recv_invoke_wsmsg(env, operation_name, in_msg_ctx, out_msg_ctx, svc_info, classname, req_info->content_type TSRMLS_CC); } } } else { /* this is where the default value for opParam is set, If the wsdl option is set go for the MIXED mode by default */ if (svc_info->wsdl == NULL || svc_info->omit_wsdl) { result_node = wsf_xml_msg_recv_invoke_wsmsg(env, operation_name, in_msg_ctx, out_msg_ctx, svc_info, classname, req_info->content_type TSRMLS_CC); } else { result_node = wsf_xml_msg_recv_invoke_mixed(env, svc_info, in_msg_ctx, out_msg_ctx, operation_name, classname, &output_headers_zval TSRMLS_CC); } } if (!result_node) { status = AXIS2_ERROR_GET_STATUS_CODE(env->error); } else { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "Response node is not null"); } if (result_node) { if (0 == axutil_strcmp(style, AXIS2_STYLE_RPC)) { axiom_namespace_t *ns = NULL; axis2_char_t *response_name = NULL; response_name = axutil_stracat(env, local_name, "Response"); ns = axiom_namespace_create(env, "http://soapenc/", "res"); if (!ns) { return AXIS2_FAILURE; } out_body_content_element = axiom_element_create(env, NULL, response_name, ns, &out_body_content_node); axiom_node_add_child(out_body_content_node, env, result_node); } else { out_body_content_node = result_node; } } if (axis2_msg_ctx_get_soap_envelope(out_msg_ctx, env)) { /* service implementation has set the envelope, useful when setting a SOAP fault. No need to further process */ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "soap fault is set"); return AXIS2_SUCCESS; } /* create the soap envelope here */ env_ns = axiom_namespace_create(env, soap_ns, AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX); if (!env_ns) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] error seting the namespces for the " AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX); return AXIS2_FAILURE; } default_envelope = axiom_soap_envelope_create(env, env_ns); if (!default_envelope) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "failed in creating the response soap envelope"); return AXIS2_FAILURE; } out_body = axiom_soap_body_create_with_parent(env, default_envelope); if (!out_body) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] failed in creating the response soap body"); return AXIS2_FAILURE; } out_header = axiom_soap_header_create_with_parent(env, default_envelope); if (!out_header) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "failed in creating the response soap headers"); return AXIS2_FAILURE; } if (output_headers_zval) { axiom_node_t *header_base_node = NULL; HashPosition pos; zval **param; char *header_str; axiom_node_t *header_node; for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(output_headers_zval), &pos); zend_hash_get_current_data_ex(Z_ARRVAL_PP(output_headers_zval), (void **) & param, &pos) == SUCCESS; zend_hash_move_forward_ex(Z_ARRVAL_PP(output_headers_zval), &pos)) { if (Z_TYPE_PP(param) == IS_STRING) { header_base_node = axiom_soap_header_get_base_node(out_header, env); if (header_base_node) { header_str = Z_STRVAL_PP(param); header_node = wsf_util_deserialize_buffer(env, header_str); axiom_node_add_child(header_base_node, env, header_node); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] failed in retrieving the response soap headers node"); return AXIS2_FAILURE; } } } } out_node = axiom_soap_body_get_base_node(out_body, env); if (!out_node) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] failed in retrieving the response soap body node"); return AXIS2_FAILURE; } if (status != AXIS2_SUCCESS) { /* something went wrong, set a SOAP Fault */ axis2_char_t *fault_value_str = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":" AXIOM_SOAP12_SOAP_FAULT_VALUE_SENDER; axis2_char_t *fault_reason_str = NULL; axis2_char_t *err_msg = NULL; if (!skel_invoked) fault_value_str = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":" AXIOM_SOAP12_SOAP_FAULT_VALUE_RECEIVER; ; err_msg = (char *) AXIS2_ERROR_GET_MESSAGE(env->error); if (err_msg) { fault_reason_str = err_msg; } else { fault_reason_str = "Error occurred while processing SOAP message"; } out_soap_fault = axiom_soap_fault_create_default_fault(env, out_body, fault_value_str, fault_reason_str, soap_version); } if (out_body_content_node) { axiom_node_add_child(out_node, env, out_body_content_node); status = axis2_msg_ctx_set_soap_envelope(out_msg_ctx, env, default_envelope); } else if (out_soap_fault) { axis2_msg_ctx_set_soap_envelope(out_msg_ctx, env, default_envelope); status = AXIS2_FAILURE; /* if there is a failure we have to return a failure code */ } else { /* we should free the memory as the envelope is not used, one way case */ axiom_soap_envelope_free(default_envelope, env); default_envelope = NULL; } 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; }
AXIS2_EXTERN axis2_amqp_destination_info_t* AXIS2_CALL axis2_amqp_util_msg_ctx_get_destination_info( axis2_msg_ctx_t* msg_ctx, const axutil_env_t* env) { /* The destination URI that is expected by this method * should be of one of the following formats * 1. amqp://IP:PORT/services/SERVICE_NAME * 2. jms:/SERVICE_NAME?java.naming.provider.url=tcp://IP:PORT... * 3. TempQueue... */ axis2_endpoint_ref_t* endpoint_ref = NULL; axis2_amqp_destination_info_t* destination_info = NULL; destination_info = (axis2_amqp_destination_info_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_amqp_destination_info_t)); destination_info->broker_ip = NULL; destination_info->broker_port = AXIS2_QPID_NULL_CONF_INT; destination_info->queue_name = NULL; endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env); if(endpoint_ref) { const axis2_char_t* endpoint_address_original = NULL; axis2_char_t* endpoint_address = NULL; char* substr = NULL; char* token = NULL; endpoint_address_original = axis2_endpoint_ref_get_address(endpoint_ref, env); if(!endpoint_address_original) return NULL; endpoint_address = (axis2_char_t*)AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t) * axutil_strlen(endpoint_address_original)) + 1); strcpy((char*)endpoint_address, (char*)endpoint_address_original); if((substr = strstr(endpoint_address, AXIS2_AMQP_EPR_PREFIX))) /* Start with amqp: */ { if(strstr(endpoint_address, AXIS2_AMQP_EPR_ANON_SERVICE_NAME)) { /* Server reply to dual-channel client */ axutil_property_t* property = NULL; property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO); if(property) { axis2_char_t* queue_name = (axis2_char_t*)axutil_property_get_value(property, env); if(queue_name) { destination_info->queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t) * strlen(queue_name)) + 1); strcpy(destination_info->queue_name, queue_name); } } } else { substr += strlen(AXIS2_AMQP_EPR_PREFIX) + 2; /* 2 -> "//" */ if(substr) /* IP:PORT/services/SERVICE_NAME */ { token = strtok(substr, ":"); if(token) /* IP */ { axis2_char_t* broker_ip = (axis2_char_t*)AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t) * strlen(token)) + 1); strcpy(broker_ip, token); destination_info->broker_ip = broker_ip; token = strtok(NULL, "/"); /* PORT */ if(token) { destination_info->broker_port = atoi(token); token = strtok(NULL, "#"); /* ... services/SERVICE_NAME */ if(token) { if((substr = strstr(token, AXIS2_AMQP_EPR_SERVICE_PREFIX))) { substr += strlen(AXIS2_AMQP_EPR_SERVICE_PREFIX) + 1; /* 1 -> "/" */ if(substr) { axis2_char_t* queue_name = (axis2_char_t*)AXIS2_MALLOC( env->allocator, (sizeof(axis2_char_t) * strlen(substr)) + 1); strcpy(queue_name, substr); destination_info->queue_name = queue_name; } } } } } } } } else if(0 == strcmp(endpoint_address, AXIS2_WSA_ANONYMOUS_URL)) /* Required to work with Sandesha2 */ { axutil_property_t* property = NULL; property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO); if(property) { axis2_char_t* queue_name = (axis2_char_t*)axutil_property_get_value(property, env); if(queue_name) { destination_info->queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t) * strlen(queue_name)) + 1); strcpy(destination_info->queue_name, queue_name); } } } else if((substr = strstr(endpoint_address, "jms:/")) && (substr == endpoint_address)) { } AXIS2_FREE(env->allocator, endpoint_address); } else { /* Single-channel blocking */ axutil_property_t* property = NULL; property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO); if(property) { axis2_char_t* queue_name = (axis2_char_t*)axutil_property_get_value(property, env); if(queue_name) { destination_info->queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t) * strlen(queue_name)) + 1); strcpy(destination_info->queue_name, queue_name); } } } /* Get broker IP/Port from conf_ctx if they are not * found in the destination URI */ if(!destination_info->broker_ip) { axis2_conf_ctx_t* conf_ctx = NULL; conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); if(conf_ctx) { axutil_property_t* property = NULL; property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP); if(property) { axis2_char_t* broker_ip = (axis2_char_t*)axutil_property_get_value(property, env); if(broker_ip) { destination_info->broker_ip = (axis2_char_t*)AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t) * strlen(broker_ip)) + 1); strcpy(destination_info->broker_ip, broker_ip); } } } } if(AXIS2_QPID_NULL_CONF_INT == destination_info->broker_port) { axis2_conf_ctx_t* conf_ctx = NULL; conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); if(conf_ctx) { axutil_property_t* property = NULL; property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT); if(property) { void* value = axutil_property_get_value(property, env); if(value) { destination_info->broker_port = *(int*)value; } } } } return destination_info; }
int AXIS2_CALL service_admin_counter_get_last_count ( const axutil_env_t *env, axis2_msg_ctx_t *msg_ctx, axis2_char_t *svc_name, axis2_char_t *op_name) { int *count = NULL; axutil_hash_t *last_counts = NULL; axutil_property_t *property = NULL; axis2_conf_ctx_t *conf_ctx = NULL; conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); if(svc_name && op_name) { axis2_char_t *key = NULL; key = axutil_strcat(env, svc_name, "-", op_name, NULL); property = axis2_conf_ctx_get_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_OPERATION_COUNT); if(!property) { last_counts = axutil_hash_make(env); property = axutil_property_create_with_args(env, AXIS2_TRUE, AXIS2_SCOPE_APPLICATION, service_admin_counter_last_counts_free_void_arg, last_counts); axis2_conf_ctx_set_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_OPERATION_COUNT, property); } else { last_counts = axutil_property_get_value(property, env); } count = axutil_hash_get(last_counts, key, AXIS2_HASH_KEY_STRING); if(count) { AXIS2_FREE(env->allocator, key); } else { count = AXIS2_MALLOC(env->allocator, sizeof(int)); *count = 0; axutil_hash_set(last_counts, key, AXIS2_HASH_KEY_STRING, count); } } else if(svc_name) { property = axis2_conf_ctx_get_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_SERVICE_COUNT); if(!property) { last_counts = axutil_hash_make(env); property = axutil_property_create_with_args(env, AXIS2_TRUE, AXIS2_SCOPE_APPLICATION, service_admin_counter_last_counts_free_void_arg, last_counts); axis2_conf_ctx_set_property(conf_ctx, env, SERVICE_ADMIN_COUNTER_LAST_SERVICE_COUNT, property); } else { last_counts = axutil_property_get_value(property, env); } count = axutil_hash_get(last_counts, svc_name, AXIS2_HASH_KEY_STRING); if(!count) { count = AXIS2_MALLOC(env->allocator, sizeof(int)); *count = 0; axutil_hash_set(last_counts, axutil_strdup(env, svc_name) , AXIS2_HASH_KEY_STRING, count); } } return *count; }