示例#1
0
AXIS2_EXTERN axutil_url_t* AXIS2_CALL
service_admin_util_get_server_url(
	const axutil_env_t *env,
	axis2_msg_ctx_t *msg_ctx)
{

	axis2_endpoint_ref_t *epr = NULL;
	axis2_char_t *address = NULL;
	axis2_conf_ctx_t *conf_ctx = NULL;
	axis2_conf_t *conf = NULL;
	axis2_transport_in_desc_t *transport_in = NULL;
	axis2_svc_t *svc = NULL;
	axis2_char_t *svc_name = NULL;
	conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
	conf = axis2_conf_ctx_get_conf(conf_ctx, env);
	
	svc = axis2_msg_ctx_get_svc(msg_ctx, env);
	svc_name = axis2_svc_get_name(svc, env);

	transport_in = axis2_conf_get_transport_in(conf, env, AXIS2_TRANSPORT_ENUM_HTTP);

	if(transport_in)
	{
		axutil_url_t *url = NULL;
		axis2_transport_receiver_t *receiver = NULL;
		receiver = axis2_transport_in_desc_get_recv(transport_in, env);
		if(!receiver)
		{
			AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Transport Receiver Not found ");
			return NULL;
		}
		epr = axis2_transport_receiver_get_epr_for_service(receiver, env, svc_name);
		if(!epr)
		{
			AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Endpoint reference null");
			return NULL;
		}
		address = (axis2_char_t*)axis2_endpoint_ref_get_address(epr,env);
return axutil_url_parse_string(env, address);
		
	}
	return NULL;



}
示例#2
0
void test_url(axutil_env_t *env)
{
    axutil_url_t * url;
    axis2_char_t *url_str = "https://issues.apache.org/jira/secure/ManageAttachments.jspa?id=12386356";
    axis2_char_t *set_server = "www.yahoo.com";
    axis2_char_t *set_protocol = "file";
    axis2_char_t *set_path = "/bar/";
    axis2_port_t set_port = 80;
    axis2_char_t *get_protocol;
    axis2_char_t *get_server;
    axis2_port_t get_port;
    axis2_char_t *get_path;
    axis2_status_t status;

    url = axutil_url_parse_string(env,url_str);
    CUT_ASSERT_PTR_NOT_EQUAL(url, NULL, 1);

    status = axutil_url_set_protocol(url,env,set_protocol);   
    CUT_ASSERT_INT_EQUAL(status, AXIS2_SUCCESS, 0);
    status = axutil_url_set_server(url,env,set_server);    
    CUT_ASSERT_INT_EQUAL(status, AXIS2_SUCCESS, 0);
    status = axutil_url_set_port(url,env,set_port);    
    CUT_ASSERT_INT_EQUAL(status, AXIS2_SUCCESS, 0);
	status = axutil_url_set_path(url,env,set_path);   
    CUT_ASSERT_INT_EQUAL(status, AXIS2_SUCCESS, 0);
  
    get_protocol = axutil_url_get_protocol(url,env);
 	CUT_ASSERT_STR_EQUAL(get_protocol, set_protocol, 0);

    get_server = axutil_url_get_server(url,env);
	CUT_ASSERT_STR_EQUAL(get_server, "www.yahoo.com:80", 0);
    
    get_port = axutil_url_get_port(url,env);
    CUT_ASSERT_INT_EQUAL(get_port,set_port,0);
 
    get_path = axutil_url_get_path(url,env);
	CUT_ASSERT_STR_EQUAL(get_path, set_path, 0);

    axutil_url_free(url,env);
}