Пример #1
0
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
service_admin_util_is_filtered_out_service_group(
	axutil_env_t *env,
	axis2_svc_grp_t *svc_grp)
{
	axutil_param_t *param =  NULL;
	if(!svc_grp)
		return AXIS2_FALSE;

	param = axis2_svc_grp_get_param(svc_grp, env, ADMIN_SERVICE_PARAM_NAME);
	if(param)
	{
		axis2_char_t *value = NULL;
		value = axutil_param_get_value(param, env);
		if(value && axutil_strcmp(value, "true") == 0)
			return AXIS2_TRUE;
	}
	
	param = axis2_svc_grp_get_param(svc_grp, env, HIDDEN_SERVICE_PARAM_NAME);
	if(param)
	{
		axis2_char_t *value = NULL;
		value = axutil_param_get_value(param, env);
		if(value && axutil_strcmp(value, "true") == 0)
			return AXIS2_TRUE;
	}
	return AXIS2_FALSE;

}
Пример #2
0
axis2_status_t AXIS2_CALL
axis2_udp_receiver_init(
    axis2_transport_receiver_t * tr_receiver,
    const axutil_env_t * env,
    axis2_conf_ctx_t * conf_ctx,
    axis2_transport_in_desc_t * in_desc)
{
	axis2_udp_receiver_impl_t *receiver = NULL;
	axis2_char_t *str = NULL;
	axutil_param_t *param = NULL;
	axutil_param_container_t *container = NULL;

	receiver = AXIS2_INTF_TO_IMPL(tr_receiver);
	receiver->conf_ctx = conf_ctx;
	container = axis2_transport_in_desc_param_container(in_desc, env);

	/* Get the port */
	param = (axutil_param_t *) axutil_param_container_get_param(container, env, AXIS2_PORT_STRING);	
	if (param)
	{
		str = (axis2_char_t *)axutil_param_get_value(param, env);
		if (str)
		{
			receiver->port = atoi(str);
		}
	}
	
	/* Get the multicast group */
	param = (axutil_param_t *) axutil_param_container_get_param(container, env, 
		AXIS2_UDP_TRANSPORT_MULTICAST_GROUP);
	if (param)
	{
		receiver->multicast_group = (axis2_char_t *)axutil_param_get_value(param, env);
		receiver->is_multicast = AXIS2_TRUE;
	}
	/* Get the max packet size */
	param = (axutil_param_t *) axutil_param_container_get_param(container, env, 
		AXIS2_UDP_TRANSPORT_MAX_PACKET_SIZE_STR);
	if (param)
	{
		str = (axis2_char_t *)axutil_param_get_value(param, env);
		if (str)
		{
			receiver->max_packet_size = atoi(str);
		} 	
	}
	return AXIS2_SUCCESS;
}
Пример #3
0
axis2_status_t AXIS2_CALL
axis2_tcp_server_init(
    axis2_transport_receiver_t * server,
    const axutil_env_t * env,
    axis2_conf_ctx_t * conf_ctx,
    axis2_transport_in_desc_t * in_desc)
{
    axis2_tcp_server_impl_t *server_impl = NULL;
    axis2_char_t *port_str = NULL;
    axutil_param_t *param = NULL;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    server_impl = AXIS2_INTF_TO_IMPL(server);

    server_impl->conf_ctx = conf_ctx;
    param =
        (axutil_param_t *)
        axutil_param_container_get_param(axis2_transport_in_desc_param_container
                                         (in_desc, env), env, "port");
    if (param)
    {
        port_str = axutil_param_get_value(param, env);
    }
    if (port_str)
    {
        server_impl->port = atoi(port_str);
    }
    return AXIS2_SUCCESS;
}
Пример #4
0
AXIS2_EXTERN axiom_node_t* AXIS2_CALL
service_admin_util_serialize_param(axutil_env_t *env,
								   axutil_param_t *param)
{
	axis2_char_t *name = NULL;
	axis2_char_t *value = NULL;
	void *param_value = NULL;
	axiom_node_t *param_node = NULL;
	axiom_element_t *param_ele = NULL;
	axiom_attribute_t *attri = NULL;

	name = axutil_param_get_name(param, env);
	param_value = axutil_param_get_value(param, env);
	if(name && axutil_strcmp(name, "ServiceClass") ==0)
	{
		return NULL;
	}else
	{
		value = (axis2_char_t*)param_value;
	}

	param_ele = axiom_element_create(env, NULL, "parameter", NULL, &param_node);
	
	attri = axiom_attribute_create(env, "name", name, NULL);
	axiom_element_add_attribute(param_ele, env, attri, param_node);
	if(value)
		axiom_element_set_text(param_ele, env, value, param_node);
	return param_node;
}
Пример #5
0
AXIS2_EXPORT axis2_status_t AXIS2_CALL
axis2_msg_recv_delete_svc_obj(
    axis2_msg_recv_t * msg_recv,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axis2_svc_t *svc = NULL;
    axis2_op_ctx_t *op_ctx = NULL;
    axis2_svc_ctx_t *svc_ctx = NULL;
    axutil_param_t *impl_info_param = NULL;
    axutil_param_t *scope_param = NULL;
    axis2_char_t *param_value = NULL;
    axutil_dll_desc_t *dll_desc = NULL;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);

    op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
    svc_ctx = axis2_op_ctx_get_parent(op_ctx, env);
    svc = axis2_svc_ctx_get_svc(svc_ctx, env);
    if(!svc)
    {
        return AXIS2_FAILURE;
    }

    scope_param = axis2_svc_get_param(svc, env, AXIS2_SCOPE);
    if(scope_param)
    {
        param_value = axutil_param_get_value(scope_param, env);
    }
    if(param_value && (0 == axutil_strcmp(AXIS2_APPLICATION_SCOPE, param_value)))
    {
        return AXIS2_SUCCESS;
    }

    impl_info_param = axis2_svc_get_param(svc, env, AXIS2_SERVICE_CLASS);
    if(!impl_info_param)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC, AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }
    dll_desc = axutil_param_get_value(impl_info_param, env);
    return axutil_class_loader_delete_dll(env, dll_desc);
    (void)msg_recv;
}
Пример #6
0
void AXIS2_CALL
axutil_param_free(
    axutil_param_t *param,
    const axutil_env_t *env)
{
    void *param_value = NULL;
    axis2_char_t *param_name = NULL;

    param_value = axutil_param_get_value(param, env);
    if(param_value)
    {
        if(param && param->value_free)
        {
            param->value_free(param_value, env);
        }
        else /* we assume that param value is axis2_char_t* */
        {
            AXIS2_FREE(env->allocator, param_value);
        }
    }

    if(param->attrs)
    {
        axutil_hash_index_t *i = NULL;
        void *v = NULL;

        for(i = axutil_hash_first(param->attrs, env); i; i = axutil_hash_next(env, i))
        {
            axutil_hash_this(i, NULL, NULL, &v);
            axutil_generic_obj_free(v, env);
        }
        axutil_hash_free(param->attrs, env);
    }

    if(param->value_list)
    {
        int i = 0, size = 0;

        size = axutil_array_list_size(param->value_list, env);
        for(i = 0; i < size; i++)
        {
            axutil_param_t *param_l = NULL;

            param_l = (axutil_param_t *)axutil_array_list_get(param->value_list, env, i);
            if(param_l)
            {
                axutil_param_free(param_l, env);
            }
        }
        axutil_array_list_free(param->value_list, env);
    }
    param_name = axutil_param_get_name(param, env);
    AXIS2_FREE(env->allocator, param_name);
    AXIS2_FREE(env->allocator, param);
    return;
}
Пример #7
0
axis2_status_t AXIS2_CALL
axis2_statistics_admin_out_op_count_handler_invoke(struct axis2_handler *handler, 
                        const axutil_env_t *env,
                        struct axis2_msg_ctx *msg_ctx)
{
    axis2_status_t status = AXIS2_SUCCESS;
    service_admin_counter_t *counter = NULL;
    axutil_param_t *param = NULL;
    axis2_op_t *op = NULL;
    axis2_svc_t *svc = NULL;
    const axis2_char_t *svc_name = NULL;
    
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[adminservices] Start:axis2_statistics_admin_out_op_count_handler_invoke");
    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);

    svc = axis2_msg_ctx_get_svc(msg_ctx, env);
    if(svc)
    {
        svc_name = axis2_svc_get_name(svc, env);
    }
    op = axis2_msg_ctx_get_op(msg_ctx, env);
    if(op)
    {
        param = axis2_op_get_param(op, env, AXIS2_OUT_OPERATION_COUNTER);
        if(param)
        {
            counter = axutil_param_get_value(param, env);
            if(counter)
            {
                service_admin_counter_increment(counter, env, msg_ctx);
            }
        }
        else
        {
            axis2_char_t *op_name = NULL;

            op_name = axutil_qname_get_localpart(axis2_op_get_qname(op, env), env);
            axutil_allocator_switch_to_global_pool(env->allocator);
            counter = service_admin_counter_create(env, svc_name, op_name);
            if(counter)
            {
                service_admin_counter_increment(counter, env, msg_ctx);
                param = axutil_param_create(env, AXIS2_OUT_OPERATION_COUNTER, counter);
                if(param)
                {
                    axis2_op_add_param(op, env, param);
                }
            }
            axutil_allocator_switch_to_local_pool(env->allocator);
        }
    }
    
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[adminservices] End:axis2_statistics_admin_out_op_count_handler_invoke");
    
    return status;
}
Пример #8
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_repos_listener_check_modules(
    axis2_repos_listener_t * repos_listener,
    const axutil_env_t * env)
{
    axis2_char_t *module_path = NULL;
    axis2_char_t *temp_path = NULL;
    axis2_status_t status = AXIS2_FAILURE;
    axis2_bool_t axis2_flag = AXIS2_FALSE;
    axis2_conf_t *conf;

    axutil_param_t *module_param;
    axis2_char_t *module_dir;

    AXIS2_PARAM_CHECK(env->error, repos_listener, AXIS2_FAILURE);

    conf = axis2_repos_listener_get_conf(repos_listener, env);

    /* Configuration  is needed only to decide we are using axis2.xml. Other
     * case we don't need. Hence even if conf is NULL we can continue.
     */

    if(conf)
    {
        axis2_flag = axis2_conf_get_axis2_flag(conf, env);
    }

    if(!axis2_flag)
    {

        temp_path = axutil_stracat(env, repos_listener->folder_name, AXIS2_PATH_SEP_STR);
        module_path = axutil_stracat(env, temp_path, AXIS2_MODULE_PATH);
        AXIS2_FREE(env->allocator, temp_path);
    }
    else
    {
        module_param = axis2_conf_get_param(conf, env, AXIS2_MODULE_DIR);
        if(module_param)
        {
            module_dir = (axis2_char_t *)axutil_param_get_value(module_param, env);
            module_path = axutil_strdup(env, module_dir);
        }
        else
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "While creating axis2 configuration using "
                "axis2.xml, modulesDir  parameter not available.");
        }

    }

    status = axis2_repos_listener_search(repos_listener, env, module_path, AXIS2_MODULE);

    AXIS2_FREE(env->allocator, module_path);

    return status;
}
Пример #9
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_repos_listener_check_svcs(
    axis2_repos_listener_t * repos_listener,
    const axutil_env_t * env)
{
    axis2_char_t *svc_path = NULL;
    axis2_char_t *temp_path = NULL;
    axis2_status_t status = AXIS2_FAILURE;

    axis2_conf_t *conf;
    axis2_bool_t axis2_flag = AXIS2_FALSE;

    axutil_param_t *svc_param;
    axis2_char_t *svc_dir;

    AXIS2_PARAM_CHECK(env->error, repos_listener, AXIS2_FAILURE);

    conf = axis2_repos_listener_get_conf(repos_listener, env);

    if(conf)
        axis2_flag = axis2_conf_get_axis2_flag(conf, env);

    if(!axis2_flag)
    {
        temp_path = axutil_stracat(env, repos_listener->folder_name, AXIS2_PATH_SEP_STR);
        svc_path = axutil_stracat(env, temp_path, AXIS2_SVC_PATH);
        AXIS2_FREE(env->allocator, temp_path);
    }
    else
    {
        svc_param = axis2_conf_get_param(conf, env, AXIS2_SERVICE_DIR);
        if(svc_param)
        {
            svc_dir = axutil_param_get_value(svc_param, env);
            svc_path = axutil_strdup(env, svc_dir);
        }
        else
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                "While creating axis2 configuration using axis2.xml, servicesDir"
                    " parameter not available.");
        }
    }

    status = axis2_repos_listener_search(repos_listener, env, svc_path, AXIS2_SVC);
    AXIS2_FREE(env->allocator, svc_path);
    return status;
}
Пример #10
0
AXIS2_EXTERN axis2_char_t* AXIS2_CALL
axis2_amqp_util_get_out_desc_conf_value_string(
    axis2_transport_out_desc_t* out_desc,
    const axutil_env_t* env,
    const axis2_char_t* param_name)
{
    axutil_param_t* param = NULL;
    axis2_char_t* value = NULL;

    param = (axutil_param_t*)axutil_param_container_get_param(
        axis2_transport_out_desc_param_container(out_desc, env), env, param_name);
    if(param)
    {
        value = axutil_param_get_value(param, env);
    }

    return value;
}
Пример #11
0
axis2_status_t AXIS2_CALL
axutil_param_set_value(
    axutil_param_t *param,
    const axutil_env_t *env,
    const void *value)
{
    void *param_value = NULL;
    param_value = axutil_param_get_value(param, env);
    if(param_value)
    {
        if(param && param->value_free)
        {
            param->value_free(param_value, env);
        }
        else /* we assume that param value is axis2_char_t* */
        {
            AXIS2_FREE(env->allocator, param_value);
        }
    }
    param->value = (void *)value;
    return AXIS2_SUCCESS;
}
Пример #12
0
void
axis2_svc_client_set_http_info(
    axis2_svc_client_t * svc_client,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axis2_transport_in_desc_t *transport_in = NULL;
    axutil_param_t *expose_headers_param = NULL;
    axis2_bool_t expose_headers = AXIS2_FALSE;

    if(msg_ctx)
    {
        transport_in = axis2_msg_ctx_get_transport_in_desc(msg_ctx, env);
        if(transport_in)
        {
            expose_headers_param = axutil_param_container_get_param(
                axis2_transport_in_desc_param_container(transport_in, env), env,
                AXIS2_EXPOSE_HEADERS);
        }
        if(expose_headers_param)
        {
            axis2_char_t *expose_headers_value = NULL;
            expose_headers_value = axutil_param_get_value(expose_headers_param, env);
            if(expose_headers_value && 0 == axutil_strcasecmp(expose_headers_value,
                AXIS2_VALUE_TRUE))
            {
                expose_headers = AXIS2_TRUE;
            }
        }
    }
    if(expose_headers)
    {
        if(svc_client->http_headers == axis2_msg_ctx_get_http_output_headers(msg_ctx, env))
        {
            svc_client->http_status_code = axis2_msg_ctx_get_status_code(msg_ctx, env);
            return;
        }
    }

    if(svc_client->http_headers)
    {
        axis2_http_header_t *header = NULL;
        while(axutil_array_list_size(svc_client->http_headers, env))
        {
            header = (axis2_http_header_t *)axutil_array_list_remove(svc_client->http_headers, env,
                0);
            if(header)
            {
                axis2_http_header_free(header, env);
            }
        }
        axutil_array_list_free(svc_client->http_headers, env);
        svc_client->http_headers = NULL;
    }
    svc_client->http_status_code = 0;

    if(msg_ctx)
    {
        if(expose_headers)
        {
            svc_client->http_headers = axis2_msg_ctx_extract_http_output_headers(msg_ctx, env);
        }
        svc_client->http_status_code = axis2_msg_ctx_get_status_code(msg_ctx, env);
    }
}
Пример #13
0
  static int AXIS2_CALL Axis2Service_init_with_conf(
    axis2_svc_skeleton_t * /*pSvcSkeleton*/,
    const axutil_env_t * pEnv, 
    axis2_conf* pConf)
  {
    staff::CrashHandler::Enable();
#if defined WIN32
    // installing handler to process Staff deinitialization before dlls are unloaded
    SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
#endif

    const axis2_char_t* szServiceName = "StaffService";
    m_pAxis2Svc = axis2_conf_get_svc(pConf, pEnv, szServiceName);

    // check for staff module is engaged
    axutil_qname_t* pQName = axutil_qname_create(pEnv, "staff", NULL, NULL);
    axis2_bool_t bEngaged = axis2_svc_is_module_engaged(m_pAxis2Svc, pEnv, pQName);
    axutil_qname_free(pQName, pEnv);

    if (!bEngaged)
    {
      staff::LogError() << "staff module is not engaged. Unable to continue.";
      exit(1);
    }

#ifndef WITHOUT_SECURITY
    // check for staff_security is engaged
    pQName = axutil_qname_create(pEnv, "staff_security", NULL, NULL);
    bEngaged = axis2_svc_is_module_engaged(m_pAxis2Svc, pEnv, pQName);
    axutil_qname_free(pQName, pEnv);

    if (!bEngaged)
    {
      staff::LogError() << "staff_security module is not engaged. Unable to continue.";
      exit(1);
    }

    // initialize security
    if (!staff_security_init())
    {
      staff::LogError() << "Failed to initialize staff::security.";
      exit(1);
    }
#endif

    axutil_param_t* pParam = axis2_svc_get_param(m_pAxis2Svc, pEnv, "Http200OnFault");
    if (pParam != NULL)
    {
      const axis2_char_t* szValue = reinterpret_cast<const axis2_char_t*>(axutil_param_get_value(pParam, pEnv));
      if (szValue != NULL)
      {
        m_bHttp200OnFault = !axutil_strcasecmp(szValue, "true");
      }
    }

    m_pEnv = pEnv;
    m_pConf = pConf;

    try
    {
      staff::ServiceDispatcher::Inst().Init(staff::ServiceDispatcher::Events(StaffService::OnConnect, StaffService::OnDisconnect));
      std::cout << "StaffService started (version " VERSION_FULL ")" << std::endl;

      return AXIS2_SUCCESS;
    }
    STAFF_CATCH_ALL_DESCR("Failed to start StaffService dispatcher")

    return AXIS2_FAILURE;
  }
Пример #14
0
/**
* auto generated function definition signature
* for "getKeyStores|http://service.keystore.security.carbon.wso2.org" operation.
* @param env environment ( mandatory)* @param MessageContext the outmessage context
*
* @return adb_getKeyStoresResponse_t*
*/
adb_getKeyStoresResponse_t* 
axis2_skel_KeyStoreAdminService_getKeyStores(const axutil_env_t *env , 
											 axis2_msg_ctx_t *msg_ctx,
											 axis2_skel_KeyStoreAdminService_getKeyStores_fault *fault )
{
	axis2_svc_t* svc = NULL;
	axutil_param_t* param = NULL;
	axis2_char_t* primary_keystore = NULL;
	axis2_bool_t is_primary_keystore = AXIS2_FALSE;
	axis2_conf_ctx_t* conf_ctx = NULL;
	axis2_conf_t* conf = NULL;
	axis2_char_t* repo_path = NULL;
	axutil_array_list_t* keystore_filenames = NULL;
	int keystore_file_count = 0;
	int index = 0;
	adb_getKeyStoresResponse_t* response = NULL;
	axis2_char_t* keystore_filename = NULL;
	axis2_char_t* keystore_name = NULL;
	axis2_char_t* extension = NULL;
	axis2_char_t* keystore_type = NULL;
	axis2_char_t* provider = NULL;
	axis2_bool_t private_store = AXIS2_FALSE;
	axis2_char_t* tok = NULL;
	adb_KeyStoreData_t* data = NULL;

	/* Get primary keystore filename */
	svc = axis2_msg_ctx_get_svc(msg_ctx, env);
	param = axis2_svc_get_param(svc, env, "PrimaryKeystore");
	if (param)
	{
		primary_keystore = (axis2_char_t*)
			axutil_param_get_value(param, env);
	}

	/* Form keystore directory name*/
	conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    conf = axis2_conf_ctx_get_conf(conf_ctx, env);
    repo_path = axis2_conf_get_repo(conf, env);

	/* Read file names in keystore directory */	
	keystore_filenames = keystore_admin_util_get_keystore_filenames(
		env, repo_path);

	if (!keystore_filenames) return NULL;
	
	/* Create response */
	response = adb_getKeyStoresResponse_create(env);

	/* Fill data */
	keystore_file_count = axutil_array_list_size(keystore_filenames, env);
	for (index = 0; index < keystore_file_count; ++index)
	{
		axis2_char_t* filename = NULL;

		keystore_filename = NULL;
		keystore_name = NULL;
		extension = NULL;
		keystore_type = NULL;
		provider = NULL;
		private_store = AXIS2_FALSE;
		tok = NULL;

		/* Get name */
		filename = (axis2_char_t*)axutil_array_list_get(keystore_filenames, env, index);
		keystore_filename = axutil_strdup(env, filename);

		tok = strtok(filename, ".");
		if (tok) /* Keystore name */
		{
			keystore_name = tok;
			
			tok = strtok(NULL, " .");
			if (tok) /* Extension */
			{
				extension = tok;
			}
		}

		if (NULL == extension) /* No extension found */
		{
			AXIS2_FREE(env->allocator, filename);
			AXIS2_FREE(env->allocator, keystore_filename);
			keystore_filename = filename = NULL;
			continue;
		}

		if (0 == axutil_strcmp(extension, "p12")) /* PKCS12 */
		{
			keystore_type = "PKCS12";
		}
		else
		{
			AXIS2_FREE(env->allocator, filename);
			AXIS2_FREE(env->allocator, keystore_filename);
			keystore_filename = filename = NULL;
			continue;
		}

		is_primary_keystore = 
			(0 == axutil_strcmp(keystore_filename, primary_keystore)) ? AXIS2_TRUE : AXIS2_FALSE;

		if (is_primary_keystore)
		{
			/* Primary keystore */
			provider = axutil_strcat(env, " ", NULL);
			private_store = AXIS2_TRUE;
		}
		else
		{
			axis2_char_t password_tmp[10];
			axis2_char_t provider_tmp[20];
			axis2_char_t pvt_key_pass_tmp[10];

			/* Get password, provider and pvt_key_pass */
			if (!keystore_admin_util_get_keystore_details(env, repo_path, keystore_name, 
				password_tmp, provider_tmp, pvt_key_pass_tmp))
			{
				AXIS2_FREE(env->allocator, filename);
				AXIS2_FREE(env->allocator, keystore_filename);
				keystore_filename = filename = NULL;
				continue;
			}

			provider = axutil_strdup(env, provider_tmp);

			private_store = keystore_admin_util_get_private_store(env, repo_path,
				keystore_name, password_tmp);
		}
		
		data = adb_KeyStoreData_create(env);

		adb_KeyStoreData_set_keyStoreName(data, env, keystore_filename);
		adb_KeyStoreData_set_keyStoreType(data, env, keystore_type);
		adb_KeyStoreData_set_provider(data, env, provider);
		adb_KeyStoreData_set_privateStore(data, env, private_store);

		adb_getKeyStoresResponse_add_return(response, env, data);
	}

	axutil_array_list_free(keystore_filenames, env);
	
	return response;
}
Пример #15
0
/**
* auto generated function definition signature
* for "deleteStore|http://service.keystore.security.carbon.wso2.org" operation.
* @param env environment ( mandatory)* @param MessageContext the outmessage context
* @param _deleteStore of the adb_deleteStore_t*
*
* @return 
*/
axis2_status_t  
axis2_skel_KeyStoreAdminService_deleteStore(const axutil_env_t *env , 
											axis2_msg_ctx_t *msg_ctx,
											adb_deleteStore_t* _deleteStore,
											axis2_skel_KeyStoreAdminService_deleteStore_fault *fault )
{
	axis2_svc_t* svc = NULL;
	axutil_param_t* param = NULL;
	axis2_char_t* primary_keystore = NULL;
	axis2_char_t* keystore_name = NULL;
	axis2_conf_ctx_t* conf_ctx = NULL;
	axis2_conf_t* conf = NULL;
	axis2_char_t* repo_path = NULL;
	axis2_char_t* keystore_file = NULL;
	axis2_char_t* keystore_details_file = NULL;
	int status = 0;

	/* Get required keystore name*/
	keystore_name = axutil_strdup(
		env, adb_deleteStore_get_keyStoreName(_deleteStore, env));
	if (!keystore_name) return AXIS2_FAILURE;

	/* Get primary keystore filename */
	svc = axis2_msg_ctx_get_svc(msg_ctx, env);
	param = axis2_svc_get_param(svc, env, "PrimaryKeystore");
	if (param)
	{
		primary_keystore = (axis2_char_t*)
			axutil_param_get_value(param, env);
	}

	/* Primary keystore should not be deleted*/
	if (0 == axutil_strcmp(keystore_name, primary_keystore))
		return AXIS2_FAILURE;

	keystore_name = strtok(keystore_name, ".");

	/* Form keystore file names*/
	conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    conf = axis2_conf_ctx_get_conf(conf_ctx, env);
    repo_path = axis2_conf_get_repo(conf, env);
	keystore_file = axutil_strcat(env, repo_path, AXIS2_PATH_SEP_STR, "services", 
		AXIS2_PATH_SEP_STR, "KeyStoreAdminService", AXIS2_PATH_SEP_STR, "keystores", 
		AXIS2_PATH_SEP_STR, keystore_name, ".p12", NULL);
	keystore_details_file = axutil_strcat(env, repo_path, AXIS2_PATH_SEP_STR, "services", 
		AXIS2_PATH_SEP_STR, "KeyStoreAdminService", AXIS2_PATH_SEP_STR, "keystores", 
		AXIS2_PATH_SEP_STR, keystore_name, ".dat", NULL);

	/* Remove keystore and detail files*/
	status = remove(keystore_file);
	if (0 == status)
		status = remove(keystore_details_file);

	AXIS2_FREE(env->allocator, keystore_name);
	AXIS2_FREE(env->allocator, keystore_file);
	AXIS2_FREE(env->allocator, keystore_details_file);
	
	if (0 != status) return AXIS2_FAILURE;

	return AXIS2_SUCCESS;
}
Пример #16
0
AXIS2_EXTERN axiom_soap_envelope_t* AXIS2_CALL
axis2_amqp_util_get_soap_envelope(
    axis2_amqp_response_t* response,
    const axutil_env_t* env,
    axis2_msg_ctx_t* msg_ctx)
{
    axiom_xml_reader_t* xml_reader = NULL;
    axiom_stax_builder_t* stax_builder = NULL;
    axiom_soap_builder_t* soap_builder = NULL;
    axiom_soap_envelope_t* soap_envelope = NULL;
    const axis2_char_t* soap_ns_uri = NULL;
    axis2_char_t *soap_body_str = NULL;
    int soap_body_len = 0;
    axis2_bool_t is_mtom = AXIS2_FALSE;
    axutil_hash_t *binary_data_map = NULL;
    axis2_bool_t is_soap_11 = AXIS2_FALSE;

    if(!response || !response->data || !response->content_type)
    {
        return NULL;
    }

    is_soap_11 = axis2_msg_ctx_get_is_soap_11(msg_ctx, env);

    /* Handle MTOM */
    if(strstr(response->content_type, AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED))
    {
        axis2_char_t* mime_boundary = axis2_amqp_util_get_value_from_content_type(env,
            response->content_type, AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY);

        if(mime_boundary)
        {
            axiom_mime_parser_t *mime_parser = NULL;
            int soap_body_len = 0;
            axutil_param_t *buffer_size_param = NULL;
            axutil_param_t *max_buffers_param = NULL;
            axutil_param_t *attachment_dir_param = NULL;
            axis2_char_t *value_size = NULL;
            axis2_char_t *value_num = NULL;
            axis2_char_t *value_dir = NULL;
            int size = 0;
            int num = 0;

            mime_parser = axiom_mime_parser_create(env);

            buffer_size_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_BUFFER_SIZE);

            if(buffer_size_param)
            {
                value_size = (axis2_char_t *)axutil_param_get_value(buffer_size_param, env);

                if(value_size)
                {
                    size = atoi(value_size);
                    axiom_mime_parser_set_buffer_size(mime_parser, env, size);
                }
            }

            max_buffers_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_MAX_BUFFERS);

            if(max_buffers_param)
            {
                value_num = (axis2_char_t*)axutil_param_get_value(max_buffers_param, env);

                if(value_num)
                {
                    num = atoi(value_num);
                    axiom_mime_parser_set_max_buffers(mime_parser, env, num);
                }
            }

            attachment_dir_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_ATTACHMENT_DIR);

            if(attachment_dir_param)
            {
                value_dir = (axis2_char_t*)axutil_param_get_value(attachment_dir_param, env);

                if(value_dir)
                {
                    axiom_mime_parser_set_attachment_dir(mime_parser, env, value_dir);
                }
            }

            if(mime_parser)
            {
                axis2_callback_info_t* callback_ctx = NULL;
                axutil_stream_t* stream = NULL;

                callback_ctx = (axis2_callback_info_t*)AXIS2_MALLOC(env->allocator,
                    sizeof(axis2_callback_info_t));

                stream = axutil_stream_create_basic(env);

                if(stream)
                {
                    axutil_stream_write(stream, env, response->data, response->length);
                    callback_ctx->env = env;
                    callback_ctx->in_stream = stream;
                    callback_ctx->content_length = response->length;
                    callback_ctx->unread_len = response->length;
                    callback_ctx->chunked_stream = NULL;
                }

                /*binary_data_map = 
                 axiom_mime_parser_parse(mime_parser, env,
                 axis2_amqp_util_on_data_request,
                 (void*)callback_ctx,
                 mime_boundary);*/

                if(!binary_data_map)
                {
                    return AXIS2_FAILURE;
                }

                soap_body_len = axiom_mime_parser_get_soap_body_len(mime_parser, env);

                soap_body_str = axiom_mime_parser_get_soap_body_str(mime_parser, env);

                axutil_stream_free(stream, env);
                AXIS2_FREE(env->allocator, callback_ctx);
                axiom_mime_parser_free(mime_parser, env);
            }

            AXIS2_FREE(env->allocator, mime_boundary);
        }

        is_mtom = AXIS2_TRUE;
    }
    else
    {
        soap_body_str = response->data;
        soap_body_len = axutil_strlen(response->data);
    }

    soap_body_len = axutil_strlen(soap_body_str);

    xml_reader = axiom_xml_reader_create_for_memory(env, soap_body_str, soap_body_len, NULL,
        AXIS2_XML_PARSER_TYPE_BUFFER);
    if(!xml_reader)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Reader");
        return NULL;
    }

    stax_builder = axiom_stax_builder_create(env, xml_reader);
    if(!stax_builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create StAX Builder");
        return NULL;
    }

    soap_ns_uri = is_soap_11 ? AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI
        : AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;

    soap_builder = axiom_soap_builder_create(env, stax_builder, soap_ns_uri);
    if(!soap_builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create SOAP Builder");
        return NULL;
    }

    if(binary_data_map)
    {
        axiom_soap_builder_set_mime_body_parts(soap_builder, env, binary_data_map);
    }

    soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env);
    return soap_envelope;
}
Пример #17
0
AXIS2_EXTERN axiom_node_t *AXIS2_CALL
axis2_svc_client_send_receive_with_op_qname(
    axis2_svc_client_t * svc_client,
    const axutil_env_t * env,
    const axutil_qname_t * op_qname,
    const axiom_node_t * payload)
{
    axiom_soap_envelope_t *soap_envelope = NULL;
    axiom_soap_body_t *soap_body = NULL;
    axiom_node_t *soap_node = NULL;
    axis2_op_t *op = NULL;
    axutil_param_t *param = NULL;
    axutil_uri_t *action_uri = NULL;
    axis2_char_t *action_str = NULL;
    axis2_bool_t qname_free_flag = AXIS2_FALSE;

    axis2_msg_ctx_t *res_msg_ctx = NULL;
    axis2_msg_ctx_t *msg_ctx = NULL;

    AXIS2_PARAM_CHECK(env->error, svc_client, NULL);

    svc_client->last_response_soap_envelope = NULL;
    svc_client->last_response_has_fault = AXIS2_FALSE;
    svc_client->auth_failed = AXIS2_FALSE;
    svc_client->required_auth_is_http = AXIS2_FALSE;
    if(svc_client->auth_type)
    {
        AXIS2_FREE(env->allocator, svc_client->auth_type);
    }
    svc_client->auth_type = NULL;

    op = axis2_svc_get_op_with_qname(svc_client->svc, env, op_qname);
    if(op)
    {
        param = axis2_op_get_param(op, env, AXIS2_SOAP_ACTION);
        if(param)
        {
            action_uri = (axutil_uri_t *)axutil_param_get_value(param, env);
            action_str = axutil_uri_to_string(action_uri, env, AXIS2_URI_UNP_OMITUSERINFO);
            axis2_options_set_action(svc_client->options, env, action_str);
        }
    }

    if(!op_qname)
    {
        op_qname = axutil_qname_create(env, AXIS2_ANON_OUT_IN_OP, NULL, NULL);
        if(!op_qname)
            return NULL;

        qname_free_flag = AXIS2_TRUE;
    }

    /* If dual channel blocking. We come to this block if the client indicate to use
     * a separate listener but don't provide a callback function to acted upon when
     * response is received in the listener thread. What we do here is we create a callback
     * and call axis2_svc_client_send_receive_non_blocking_with_op_qname with it. */
    if(axis2_options_get_use_separate_listener(svc_client->options, env))
    {
        axis2_callback_t *callback = NULL;
        axis2_msg_ctx_t *msg_ctx = NULL;
        long index = 0;

        /* This means doing a Request-Response invocation using two channels.
         If the transport is a two way transport (e.g. http), only one channel is used
         (e.g. in http cases 202 OK is sent to say no response available).
         Axis2 gets blocked and return when the response is available. */

        callback = axis2_callback_create(env);
        if(!callback)
        {
            return NULL;
        }

        /* Call two channel non blocking invoke to do the work and wait on the callback. We don't 
         * set a callback function for the callback. That functionality is handled here. 
         */
        axis2_svc_client_send_receive_non_blocking_with_op_qname(svc_client, env, op_qname,
            payload, callback);

        index = axis2_options_get_timeout_in_milli_seconds(svc_client->options, env) / 10;

        while(!axis2_callback_get_complete(callback, env))
        {
            if(index-- >= 0)
            {
                AXIS2_USLEEP(10000);
            }
            else
            {
                AXIS2_ERROR_SET(env->error, AXIS2_ERROR_RESPONSE_TIMED_OUT, AXIS2_FAILURE);
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Response time out.");
                return NULL;
            }
        }

        soap_envelope = axis2_callback_get_envelope(callback, env);
        msg_ctx = axis2_callback_get_msg_ctx(callback, env);
        axis2_op_client_add_in_msg_ctx(svc_client->op_client, env, msg_ctx);

        /* start of hack to get rid of memory leak */
        /*msg_ctx = axis2_msg_ctx_create(env, axis2_svc_ctx_get_conf_ctx(svc_client-> svc_ctx, env),
            NULL, NULL);
        if(!msg_ctx)
            return NULL;

        axis2_op_client_add_in_msg_ctx(svc_client->op_client, env, msg_ctx);

        axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope);*/
        /* end of hack to get rid of memory leak */

        /* process the result of the invocation */
        if(!soap_envelope)
        {
            if(axis2_callback_get_error(callback, env) != AXIS2_ERROR_NONE)
            {
                AXIS2_ERROR_SET(env->error, axis2_callback_get_error(callback, env), AXIS2_FAILURE);
                return NULL;
            }
        }
    }
    else
    {
        msg_ctx = axis2_msg_ctx_create(env, axis2_svc_ctx_get_conf_ctx(svc_client->svc_ctx, env),
            NULL, NULL);
        if(!msg_ctx)
            return NULL;

        if(!axis2_svc_client_fill_soap_envelope(env, svc_client, msg_ctx, payload))
        {
            return NULL;
        }

        if(!axis2_svc_client_create_op_client(svc_client, env, op_qname))
        {
            return NULL;
        }

        axis2_op_client_add_msg_ctx(svc_client->op_client, env, msg_ctx);
        axis2_op_client_execute(svc_client->op_client, env, AXIS2_TRUE);
        axis2_svc_client_set_http_info(svc_client, env, msg_ctx);
        svc_client->auth_failed = axis2_msg_ctx_get_auth_failed(msg_ctx, env);
        svc_client->required_auth_is_http = axis2_msg_ctx_get_required_auth_is_http(msg_ctx, env);
        if(axis2_msg_ctx_get_auth_type(msg_ctx, env))
        {
            svc_client->auth_type = axutil_strdup(env, axis2_msg_ctx_get_auth_type(msg_ctx, env));
        }
        res_msg_ctx = (axis2_msg_ctx_t *)axis2_op_client_get_msg_ctx(svc_client-> op_client, env,
            AXIS2_WSDL_MESSAGE_LABEL_IN);

        if(res_msg_ctx)
        {
            soap_envelope = axis2_msg_ctx_get_soap_envelope(res_msg_ctx, env);
        }
        else
        {
            axis2_op_client_add_msg_ctx(svc_client->op_client, env, res_msg_ctx);
            /* set in msg_ctx to be NULL to reset */
        }
    }

    if(qname_free_flag)
    {
        axutil_qname_free((axutil_qname_t *)op_qname, env);
    }

    if(!soap_envelope)
    {
        return NULL;
    }
    svc_client->last_response_soap_envelope = soap_envelope;

    soap_body = axiom_soap_envelope_get_body(soap_envelope, env);

    if(!soap_body)
    {
        axiom_node_t *node = axiom_soap_envelope_get_base_node(soap_envelope, env);
        if(node)
        {
            axiom_element_t *envelope_element = (axiom_element_t *)axiom_node_get_data_element(
                node, env);
            axiom_util_get_first_child_element_with_localname(envelope_element, env, node,
                AXIOM_SOAP_BODY_LOCAL_NAME, &soap_node);
            if(soap_node)
            {
                return axiom_node_get_first_element(soap_node, env);
            }
        }
        return NULL;
    }

    if(axis2_msg_ctx_get_doing_rest(res_msg_ctx, env))
    {
        /* All HTTP 4xx and 5xx status codes are treated as errors */
        if(axis2_msg_ctx_get_status_code(res_msg_ctx, env) >= 400)
        {
            svc_client->last_response_has_fault = AXIS2_TRUE;
        }
        else
        {
            svc_client->last_response_has_fault = AXIS2_FALSE;
        }
    }
    else
    {
        svc_client->last_response_has_fault = axiom_soap_body_has_fault(soap_body, env);
    }

    if(AXIOM_SOAP11 == axiom_soap_envelope_get_soap_version(soap_envelope, env))
    {
        axiom_soap_body_convert_fault_to_soap11(soap_body, env);
    }

    soap_node = axiom_soap_body_get_base_node(soap_body, env);
    if(!soap_node)
    {
        return NULL;
    }
    return axiom_node_get_first_element(soap_node, env);
}
axis2_status_t
axis2_amqp_process_request(
    const axutil_env_t* env,
    axis2_amqp_request_processor_resource_pack_t* request_resource_pack)
{
    axiom_xml_reader_t* xml_reader = NULL;
    axiom_stax_builder_t* stax_builder = NULL;
    axiom_soap_builder_t* soap_builder = NULL;
    axis2_transport_out_desc_t* out_desc = NULL;
    axis2_transport_in_desc_t* in_desc = NULL;
    axis2_msg_ctx_t* msg_ctx = NULL;
    axiom_soap_envelope_t* soap_envelope = NULL;
    axis2_engine_t* engine = NULL;
    const axis2_char_t* soap_ns_uri = NULL;
    axis2_bool_t is_soap_11 = AXIS2_FALSE;
    axis2_char_t *soap_body_str = NULL;
    int soap_body_len = 0;
    axis2_bool_t is_mtom = AXIS2_FALSE;
    axis2_status_t status = AXIS2_FAILURE;
    axutil_hash_t *binary_data_map = NULL;
    axiom_soap_body_t *soap_body = NULL;
    axutil_property_t* reply_to_property = NULL;

    /* Create msg_ctx */
    if(!request_resource_pack->conf_ctx)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Conf Context not Available");
        return AXIS2_FAILURE;
    }

    out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf(
        request_resource_pack->conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_AMQP);
    if(!out_desc)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport Out Descriptor not Found");
        return AXIS2_FAILURE;
    }

    in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(request_resource_pack->conf_ctx,
        env), env, AXIS2_TRANSPORT_ENUM_AMQP);
    if(!in_desc)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport In Descriptor not Found");
        return AXIS2_FAILURE;
    }

    /* Create msg_ctx */
    msg_ctx = axis2_msg_ctx_create(env, request_resource_pack->conf_ctx, in_desc, out_desc);

    axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);

    /* Handle MTOM */
    if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED))
    {
        axis2_char_t* mime_boundary = axis2_amqp_util_get_value_from_content_type(env,
            request_resource_pack->content_type, AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY);

        if(mime_boundary)
        {
            axiom_mime_parser_t *mime_parser = NULL;
            int soap_body_len = 0;
            axutil_param_t *buffer_size_param = NULL;
            axutil_param_t *max_buffers_param = NULL;
            axutil_param_t *attachment_dir_param = NULL;
            axis2_char_t *value_size = NULL;
            axis2_char_t *value_num = NULL;
            axis2_char_t *value_dir = NULL;
            int size = 0;
            int num = 0;

            mime_parser = axiom_mime_parser_create(env);

            buffer_size_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_BUFFER_SIZE);
            if(buffer_size_param)
            {
                value_size = (axis2_char_t*)axutil_param_get_value(buffer_size_param, env);
                if(value_size)
                {
                    size = atoi(value_size);
                    axiom_mime_parser_set_buffer_size(mime_parser, env, size);
                }
            }

            max_buffers_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_MAX_BUFFERS);
            if(max_buffers_param)
            {
                value_num = (axis2_char_t*)axutil_param_get_value(max_buffers_param, env);
                if(value_num)
                {
                    num = atoi(value_num);
                    axiom_mime_parser_set_max_buffers(mime_parser, env, num);
                }
            }

            /* If this paramter is there mime_parser will cached the attachment 
             * using to the directory for large attachments. */
            attachment_dir_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_ATTACHMENT_DIR);
            if(attachment_dir_param)
            {
                value_dir = (axis2_char_t*)axutil_param_get_value(attachment_dir_param, env);
                if(value_dir)
                {
                    axiom_mime_parser_set_attachment_dir(mime_parser, env, value_dir);
                }
            }

            if(mime_parser)
            {
                axis2_callback_info_t *callback_ctx = NULL;
                axutil_stream_t *stream = NULL;

                callback_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_callback_info_t));

                stream = axutil_stream_create_basic(env);
                if(stream)
                {
                    axutil_stream_write(stream, env, request_resource_pack->request_content,
                        request_resource_pack->content_length);
                    callback_ctx->env = env;
                    callback_ctx->in_stream = stream;
                    callback_ctx->content_length = request_resource_pack->content_length;
                    callback_ctx->unread_len = request_resource_pack->content_length;
                    callback_ctx->chunked_stream = NULL;
                }

                /*binary_data_map = 
                 axiom_mime_parser_parse(mime_parser, env,
                 axis2_amqp_util_on_data_request,
                 (void*)callback_ctx,
                 mime_boundary);*/
                if(!binary_data_map)
                {
                    return AXIS2_FAILURE;
                }

                soap_body_str = axiom_mime_parser_get_soap_body_str(mime_parser, env);
                soap_body_len = axiom_mime_parser_get_soap_body_len(mime_parser, env);

                axutil_stream_free(stream, env);
                AXIS2_FREE(env->allocator, callback_ctx);
                axiom_mime_parser_free(mime_parser, env);
            }

            AXIS2_FREE(env->allocator, mime_boundary);
        }

        is_mtom = AXIS2_TRUE;
    }
    else
    {
        soap_body_str = request_resource_pack->request_content;
        soap_body_len = request_resource_pack->content_length;
    }

    soap_body_len = axutil_strlen(soap_body_str);

    xml_reader = axiom_xml_reader_create_for_memory(env, soap_body_str, soap_body_len, NULL,
        AXIS2_XML_PARSER_TYPE_BUFFER);
    if(!xml_reader)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Reader");
        return AXIS2_FAILURE;
    }

    stax_builder = axiom_stax_builder_create(env, xml_reader);
    if(!stax_builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create StAX Builder");
        return AXIS2_FAILURE;
    }

    soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;

    if(request_resource_pack->content_type)
    {
        if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML))
        {
            is_soap_11 = AXIS2_TRUE;
            soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI;
        }
        /*if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_APPL_SOAP))
         {
         is_soap_11 = AXIS2_FALSE;
         soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
         }
         else if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML))
         {
         is_soap_11 = AXIS2_TRUE;
         soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI;
         }*/
    }

    soap_builder = axiom_soap_builder_create(env, stax_builder, soap_ns_uri);
    if(!soap_builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create SOAP Builder");
        return AXIS2_FAILURE;
    }

    if(binary_data_map)
    {
        axiom_soap_builder_set_mime_body_parts(soap_builder, env, binary_data_map);
    }

    soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env);
    axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope);

    soap_body = axiom_soap_envelope_get_body(soap_envelope, env);

    if(!soap_body)
    {
        return AXIS2_FAILURE;
    }

    /* SOAPAction */
    if(request_resource_pack->soap_action)
    {
        axis2_msg_ctx_set_soap_action(msg_ctx, env, axutil_string_create(env,
            request_resource_pack->soap_action));
    }

    /* SOAP version */
    axis2_msg_ctx_set_is_soap_11(msg_ctx, env, is_soap_11);

    /* Set ReplyTo in the msg_ctx as a property. This is used by the server when
     * 1. WS-A is not in use
     * 2. ReplyTo is an anonymous EPR - Sandesha2/Dual-channel */
    reply_to_property = axutil_property_create_with_args(env, AXIS2_SCOPE_REQUEST, 0, 0,
        (void*)request_resource_pack->reply_to);
    axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO,
        reply_to_property);

    engine = axis2_engine_create(env, request_resource_pack->conf_ctx);

    if(AXIS2_TRUE == axiom_soap_body_has_fault(soap_body, env))
    {
        status = axis2_engine_receive_fault(engine, env, msg_ctx);
    }
    else
    {
        status = axis2_engine_receive(engine, env, msg_ctx);
    }

    if(engine)
    {
        axis2_engine_free(engine, env);
    }

    if(soap_body_str && is_mtom)
    {
        AXIS2_FREE(env->allocator, soap_body_str);
    }

    return status;
}
Пример #19
0
/* 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;
}