示例#1
0
int 
main(
    int argc,
    char *argv) 
{
    axutil_env_t * env = NULL;
    axis2_char_t * operation = NULL;
    axis2_char_t * client_home = NULL;
    axis2_char_t * endpoint_uri = NULL;
    axis2_stub_t * stub = NULL;
    adb_addResponse_t * add_res = NULL;
    adb_add_t * add_in = NULL;
    int res_val = 0;
    endpoint_uri = "http://localhost:9090/axis2/services/Calculator";
    env = axutil_env_create_all("alltest.log", AXIS2_LOG_LEVEL_TRACE);
    
    /* Set up deploy folder. */ 
    client_home = AXIS2_GETENV("AXIS2C_HOME");
    if (!client_home)
        client_home = "../../../deploy";
    stub = axis2_stub_create_Calculator(env, client_home, endpoint_uri);
    add_in = adb_add_create(env);
    adb_add_set_arg_0_0(add_in, env, 10);
    adb_add_set_arg_1_0(add_in, env, 10);
    add_res = axis2_stub_op_Calculator_add(stub, env, add_in);
    if (!add_res)
        
    {
        printf("Error: response NULL\n");
        return -1;
    }
    res_val = adb_addResponse_get_addReturn(add_res, env);
    printf("ADD Result:%d ", res_val);
    return 0;
}
void
axis2_test_svc_client_blocking(
    )
{
    axutil_env_t *env = NULL;
    axis2_options_t *options = NULL;
    const axis2_char_t *client_home = NULL;
    axis2_svc_client_t *svc_client = NULL;
    axiom_node_t *payload = NULL;
    axiom_node_t *ret_node = NULL;
    const axis2_char_t *address = NULL;
    axis2_endpoint_ref_t *endpoint_ref = NULL;

    axutil_allocator_t *allocator = axutil_allocator_init(NULL);
    axiom_element_t *result_ele = NULL;
    const axis2_char_t *echo_text = "echo_text";
    axis2_char_t *result = NULL;

    env = axutil_env_create(allocator);
    address = "http://localhost:9090/axis2/services/echo/echo";
    endpoint_ref = axis2_endpoint_ref_create(env, address);
    client_home = AXIS2_GETENV("AXIS2C_HOME");
    if (!client_home)
        client_home = "../../deploy";

    svc_client = axis2_svc_client_create(env, client_home);

    if (!svc_client)
    {
        printf("axis2_test axis2_svc_client_create FAILURE\n");
        printf
            ("Client repository path not properly set. Please check AXIS2C_HOME setting\n");
        return;
    }

    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);
    axis2_svc_client_set_options(svc_client, env, options);

    payload = build_om_payload_for_echo_svc(env, echo_text);
    ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
    if (ret_node)
    {
        if (axiom_node_get_node_type(ret_node, env) == AXIOM_ELEMENT)
        {
            ret_node = axiom_node_get_first_child(ret_node, env);
            result_ele =
                (axiom_element_t *) axiom_node_get_data_element(ret_node, env);
            result = axiom_element_get_text(result_ele, env, ret_node);
            if (!strcmp(result, echo_text))
                printf("axis2_test SVC_CLIENT_SEND_RECEIVE SUCCESS\n");
            else
                printf("axis2_test SVC_CLIENT_SEND_RECEIVE FAILURE\n");
        }
    }

    axis2_svc_client_free(svc_client, env);
}
int
main(
    int argc,
    char **argv)
{
    axutil_env_t *env = NULL;
    axis2_char_t *operation = NULL;
    axis2_char_t *client_home = NULL;

    axis2_char_t *endpoint_uri = NULL;

    axis2_stub_t *stub = NULL;

    /* variables use databinding */
    adb_addResponse_t *add_res = NULL;
    adb_add_t *add_req = NULL;

    int ret_val = 0;

    int val1 = 8;
    int val2 = 13;

    endpoint_uri = "http://localhost:9090/axis2/services/calculator";

    env =
        axutil_env_create_all("codegen_utest_blocking.log",
                              AXIS2_LOG_LEVEL_TRACE);

    /* Set up deploy folder. */
    client_home = AXIS2_GETENV("WSFC_HOME");
    if (!client_home)
        client_home = "../../../deploy";

    stub = axis2_stub_create_Calculator(env, client_home, endpoint_uri);

    /* create the struct */
    add_req = adb_add_create(env);
    adb_add_set_in0(add_req, env, val1);
    adb_add_set_in1(add_req, env, val2);


    /* invoke the web service method */
    add_res = axis2_stub_op_Calculator_add(stub, env, add_req);

    if (!add_res)
    {
        printf("Error: response NULL\n");
        return -1;
    }

    /* return the output params using databinding */
    ret_val = adb_addResponse_get_addReturn(add_res, env);

    printf("finally: add (%d %d ) = %d\n", val1, val2, ret_val);

    return 0;
}
示例#4
0
int
main(
    int argc,
    char **argv)
{
    axutil_env_t *env = NULL;
    axis2_char_t *client_home = NULL;

    axis2_char_t *endpoint_uri = NULL;

    axis2_stub_t *stub = NULL;

    /* variables use databinding */
    adb_echoDate_t *echo_in = NULL;
    adb_echoDateResponse_t *echo_out = NULL;

    axutil_date_time_t *echo_date = NULL;
    axutil_date_time_t *return_echo_date = NULL;

    axis2_char_t *send_date_str = NULL;
    axis2_char_t *return_date_str = NULL;

    endpoint_uri = "http://localhost:9090/axis2/services/interop_doc1";

    env = axutil_env_create_all("codegen_utest_blocking.log",
                                AXIS2_LOG_LEVEL_TRACE);

    /* Set up deploy folder. */
    client_home = AXIS2_GETENV("AXIS2C_HOME");
    if (!client_home)
        client_home = "../../../deploy";

    stub = axis2_stub_create_InteropTestPortTypeDocService(env,
                                                           client_home,
                                                           endpoint_uri);

    /* create the struct */
    echo_date = axutil_date_time_create(env);   /* default to current date */
    send_date_str = axutil_date_time_serialize_date_time(echo_date, env);
    printf("sending date %s\n", send_date_str);

    /* create the input params using databinding */
    echo_in = adb_echoDate_create(env);
    adb_echoDate_set_arg_0_10(echo_in, env, echo_date);

    /* invoke the web service method */
    echo_out = axis2_stub_op_InteropTestPortTypeDocService_echoDate(stub, env, echo_in);

    /* return the output params using databinding */
    return_echo_date = adb_echoDateResponse_get_echoDateReturn(echo_out, env);

    return_date_str =
        axutil_date_time_serialize_date_time(return_echo_date, env);
    printf("returned date %s\n", return_date_str);

    return 0;
}
示例#5
0
int 
main(
    int argc,
    char *argv[]) 
{
    axutil_env_t * env = NULL;
    axis2_char_t * client_home = NULL;
    axis2_char_t * endpoint_uri = NULL;
    axis2_stub_t * stub = NULL;
    axis2_char_t * symbol = NULL;
    adb_getStockQuote_t * req = NULL;
    adb_getStockQuoteResponse_t * res = NULL;
    if (argc > 1)
        
    {
        symbol = argv[1];
    }
    
    else
        
    {
        printf("\nEnter Symbol Name!");
        return -1;
    }
    endpoint_uri = "http://localhost:9090/axis2/services/StockQuoteService";
    env =
        axutil_env_create_all("codegen_sample_stock_quote.log",
                              AXIS2_LOG_LEVEL_TRACE);
    
        /* Set up deploy folder. */ 
        client_home = AXIS2_GETENV("AXIS2C_HOME");
    if (!client_home)
        client_home = "../../../deploy";
    stub =
        axis2_stub_create_StockQuoteService(env, client_home, endpoint_uri);
    
        /* Create the struct */ 
        req = adb_getStockQuote_create(env);
    adb_getStockQuote_set_symbol(req, env, symbol);
    res = axis2_stub_op_StockQuoteService_getStockQuote(stub, env, req);
    if (!res)
        
    {
        printf("Error: response NULL!\n");
        return -1;
    }
    handle_response(res, env);    /*Handle Response */
    return 0;
}
示例#6
0
/**
* auto generated function definition signature
* for "GenerateUnsubscribeEvent|http://mopevm.ru/axis2/services/Subscribers" operation.
* @param env environment ( mandatory)* @param MessageContext the outmessage context
* @param _generateUnsubscribeEventRequest of the adb_generateUnsubscribeEventRequest_t*
*
* @return adb_generateUnsubscribeEventResponse_t*
*/
adb_generateUnsubscribeEventResponse_t* axis2_skel_Subscribers_GenerateUnsubscribeEvent(const axutil_env_t *env , axis2_msg_ctx_t *msg_ctx,
                              adb_generateUnsubscribeEventRequest_t* _generateUnsubscribeEventRequest )
{
	axis2_stub_t *stub = NULL;
//	const axutil_env_t *env = NULL;
	const axis2_char_t *address = NULL;
	const axis2_char_t *client_home = NULL;
	int id;
	sqlite3 *db;
	sqlite3_stmt *stmt;
	int rc;

//	env = axutil_env_create_all("subscribers.log", AXIS2_LOG_LEVEL_TRACE);

	client_home = AXIS2_GETENV("AXIS2C_HOME");
	if (!client_home || !strcmp(client_home, ""))
	client_home = "../..";    

	if (SQLITE_OK == sqlite3_open("Subscribers.db", &db))
	{
		printf("Database opened\n");	
	}
	else
	{
		printf("Error opening database\n");
	}

	char* query = "select * from info";
	sqlite3_prepare(db, query, -1, &stmt, 0);
	rc=sqlite3_step(stmt);
	id = sqlite3_column_int( stmt, 0 );
	address = sqlite3_column_text( stmt, 1 );
	sqlite3_finalize(stmt);
	sqlite3_close(db);	

	stub = axis2_stub_create_Subscribers(env, client_home, address);

	adb_unsubscribeResponse_t* unsubscribeResponse = axis2_stub_op_Subscribers_Unsubscribe( stub, env,
                                                  adb_unsubscribeRequest_create_with_values(env, id));

	adb_generateUnsubscribeEventResponse_t* reply = adb_generateUnsubscribeEventResponse_create(env);

	adb_generateUnsubscribeEventResponse_set_message(reply, env, adb_unsubscribeResponse_get_message(unsubscribeResponse, env));
	
	return reply;
}
int
main(
    int argc,
    char **argv)
{
    axutil_env_t *env = NULL;
    axis2_char_t *operation = NULL;
    axis2_char_t *client_home = NULL;

    axis2_char_t *endpoint_uri = NULL;

    axis2_stub_t *stub = NULL;

    axiom_node_t *req = NULL;
    axiom_node_t *res = NULL;

    endpoint_uri = "http://localhost:9090/axis2/services/Calculator";

    env =
        axutil_env_create_all("codegen_utest_blocking.log",
                              AXIS2_LOG_LEVEL_TRACE);

    /* Set up deploy folder. */
    client_home = AXIS2_GETENV("WSFC_HOME");
    if (!client_home)
        client_home = "../../../deploy";

    stub = axis2_stub_create_Calculator(env, client_home, endpoint_uri);

    req = generate_request_xml(env);

    /* invoke the web service method */
    res = axis2_stub_op_Calculator_add(stub, env, req);

    handle_respone_xml(env, res);

    return 0;
}
int
main(
    int argc,
    char **argv)
{
    const axutil_env_t *env = NULL;
    const axis2_char_t *address = NULL;
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_options_t *options = NULL;
    const axis2_char_t *client_home = NULL;
    axis2_svc_client_t *svc_client = NULL;
    axiom_node_t *payload = NULL;
    axiom_node_t *ret_node = NULL;
    const axis2_char_t *image_name = "resources/axis2.jpg";

    /* Set up the environment */
    env = axutil_env_create_all("mtom_callback.log", AXIS2_LOG_LEVEL_TRACE);

    /* Set end point reference of mtom service */
    address = "http://localhost:9090/axis2/services/mtom_callback";
    if (argc > 1)
        address = argv[1];
    if (axutil_strcmp(address, "-h") == 0)
    {
        printf
            ("Usage : %s [endpoint_url] [image_name] \n",
             argv[0]);
        printf("use -h for help\n");
        return 0;
    }
    if (argc > 2)
        image_name = argv[2];

    printf("Using endpoint : %s\n", address);

    /* Create EPR with given address */
    endpoint_ref = axis2_endpoint_ref_create(env, address);

    /* Setup options */
    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);
    axis2_options_set_action(options, env,
                             "http://ws.apache.org/axis2/c/samples/mtomCallbackSample");

    axis2_options_set_soap_version(options, env, AXIOM_SOAP11);

    axis2_options_set_enable_mtom(options, env, AXIS2_TRUE);

    /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
     * using the axis2.xml file.
     * In this sample client_home points to the Axis2/C default deploy folder. The client_home can 
     * be different from this folder on your system. For example, you may have a different folder 
     * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the 
     * modules that the client uses
     */
    client_home = AXIS2_GETENV("WSFC_HOME");
    if (!client_home || !strcmp(client_home, ""))
        client_home = "../..";

    /* Create service client */
    svc_client = axis2_svc_client_create(env, client_home);
    if (!svc_client)
    {
        printf
            ("Error creating service client, Please check WSFC_HOME again\n");
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        AXIS2_ERROR_GET_MESSAGE(env->error));
        return -1;
    }

    /* Set service client options */
    axis2_svc_client_set_options(svc_client, env, options);

    /* Engage addressing module */
    axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);

    /* Build the SOAP request message payload using OM API. */
    payload =
        build_om_programatically(env, image_name);

    /* Send request */
    ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
    if (ret_node)
    {
        axis2_char_t *om_str = NULL;
        om_str = axiom_node_to_string(ret_node, env);
        if (om_str)
        {
            if (axis2_svc_client_get_last_response_has_fault(svc_client, env) == AXIS2_TRUE)
            {
                printf("\nRecieved Fault : %s\n", om_str);
                AXIS2_FREE(env->allocator, om_str);
            }
            else
            {
                printf("\nReceived OM : %s\n", om_str);
                AXIS2_FREE(env->allocator, om_str);
                printf("\nmtom client invoke SUCCESSFUL!\n");
                process_response_node(env, ret_node);
            }
        }
    }
    else
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        AXIS2_ERROR_GET_MESSAGE(env->error));
        printf("\nmtom client invoke FAILED!\n");
        printf("\nSending callback may not be set. Check the log for more details.\n");
    }

    if (svc_client)
    {
        axis2_svc_client_free(svc_client, env);
        svc_client = NULL;
    }

    if (env)
    {
        axutil_env_free((axutil_env_t *) env);
        env = NULL;
    }

    return 0;

}
示例#9
0
int
main(
    int argc,
    char **argv)
{
    axutil_env_t *env = NULL;
    const axis2_char_t *address = NULL;
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_options_t *options = NULL;
    const axis2_char_t *client_home = NULL;
    axis2_svc_client_t *svc_client = NULL;
    axiom_node_t *payload = NULL;
    axiom_node_t *ret_node = NULL;
    axiom_element_t *ret_ele = NULL;
    axis2_char_t *om_str = NULL;
    axis2_char_t *result = NULL;

    const axis2_char_t *echo_operation = NULL;
    const axis2_char_t *word_to_echo = NULL;
    const axis2_char_t *echo_type = NULL;
    axis2_char_t operation[32];
    axis2_char_t echo_response_buff[32];

    echo_operation = "String";
    word_to_echo = "helloworld";
    echo_type = "string";

    if ((argc > 1) && (axutil_strcmp("-h", argv[1]) == 0))
    {
        printf("\nUsage : %s [echo_operation] [echo_value] [XSD_type]\n",
               argv[0]);
        printf("use -h for help\n");
        return 0;
    }

    if (argc > 1)
        echo_operation = argv[1];
    if (argc > 2)
        word_to_echo = argv[2];
    if (argc > 3)
        echo_type = argv[3];

    /* address = "http://localhost:7070/cgi-bin/interopserver"; */
    address = "http://easysoap.sourceforge.net/cgi-bin/interopserver";

    sprintf(operation, "echo%s", echo_operation);

    printf("Using endpoint : %s\n", address);
    printf("Invoking %s with param %s\n", operation, word_to_echo);

    /* Set up the environment */
    env = axutil_env_create_all("echo.log", AXIS2_LOG_LEVEL_TRACE);

    /* Create EPR with given address */

    endpoint_ref = axis2_endpoint_ref_create(env, address);
    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);

    /* this itest requried soap 1.1 message */
    axis2_options_set_soap_version(options, env, AXIOM_SOAP11);
    client_home = AXIS2_GETENV("AXIS2C_HOME");
    if (!client_home)
        client_home = "../../deploy";

    /* Create service client */
    svc_client = axis2_svc_client_create(env, client_home);
    if (!svc_client)
    {
        printf("Error creating service client\n");
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        axutil_error_get_message(env->error));
    }

    /* Set service client options */
    axis2_svc_client_set_options(svc_client, env, options);

    payload = build_soap_body_content(env, echo_operation,
                                      echo_type, word_to_echo);
    /* Send request */
    ret_node = axis2_svc_client_send_receive(svc_client, env, payload);

    if (ret_node)
    {
        om_str = AXIOM_NODE_TO_STRING(ret_node, env);
        if (om_str)
            printf("\nRecieving OM : %s\n", om_str);
        if (AXIOM_NODE_GET_NODE_TYPE(ret_node, env) == AXIOM_ELEMENT)
        {

            sprintf(echo_response_buff, "echo%sResponse", echo_operation);
            ret_ele =
                (axiom_element_t *) AXIOM_NODE_GET_DATA_ELEMENT(ret_node, env);
            if (axutil_strcmp
                (axiom_element_get_localname(ret_ele, env),
                 echo_response_buff) != 0)
            {
                printf("%s != %s\n", axiom_element_get_localname(ret_ele, env),
                       echo_response_buff);
                printf("\nFAIL\n\n");
                return AXIS2_FAILURE;
            }

            ret_node = AXIOM_NODE_GET_FIRST_CHILD(ret_node, env);
            ret_ele =
                (axiom_element_t *) AXIOM_NODE_GET_DATA_ELEMENT(ret_node, env);
            result = axiom_element_get_text(ret_ele, env, ret_node);
            if (!strcmp(word_to_echo, result))
            {
                printf("\nSUCCESS\n\n");
            }
            else
            {
                printf("\nFAIL\n\n");
            }

        }
        else
        {
            printf("\nFAIL\n\n");
            return AXIS2_FAILURE;
        }
    }
    else
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        axutil_error_get_message(env->error));
        printf("round1 stub invoke FAILED!\n");
        return AXIS2_FAILURE;
    }

    return AXIS2_SUCCESS;
}
示例#10
0
int main(int argc, char **argv) {
  axutil_env_t * env = NULL;
  axis2_char_t * client_home = NULL;
  axis2_char_t endpoint_uri[256], *tmpstr;
  axis2_stub_t * stub = NULL;
  int rc, i, port, use_wssec;
  char *euca_home, configFile[1024], policyFile[1024];

  mymeta.userId = strdup("admin");
  mymeta.correlationId = strdup("1234abcd");
  mymeta.epoch = 3;
  mymeta.servicesLen = 16;
  snprintf(mymeta.services[15].name, 16, "eucalyptusname");
  snprintf(mymeta.services[15].type, 16, "eucalyptustype");
  snprintf(mymeta.services[15].partition, 16, "eucalyptuspart");
  mymeta.services[15].urisLen = 1;
  snprintf(mymeta.services[15].uris[0], 512, "http://192.168.254.3:8773/services/Eucalyptus");
    
  if (MODE == 0) {
    if (argc != 2 || strcmp(argv[1], "-9")) {
      printf("only runnable from inside euca\n");
      exit(1);
    }
  } else {
    if (argc < 3) {
      printf("USAGE: CCclient <host:port> <command> <opts>\n");
      exit(1);
    }
  }
  
  euca_home = getenv("EUCALYPTUS");
  if (!euca_home) {
    snprintf(configFile, 1024, "/etc/eucalyptus/eucalyptus.conf");
    snprintf(policyFile, 1024, "/var/lib/eucalyptus/keys/cc-client-policy.xml");
  } else {
    snprintf(configFile, 1024, "%s/etc/eucalyptus/eucalyptus.conf", euca_home);
    snprintf(policyFile, 1024, "%s/var/lib/eucalyptus/keys/cc-client-policy.xml", euca_home);
  }

  rc = get_conf_var(configFile, "CC_PORT", &tmpstr);
  if (rc != 1) {
    // error
    logprintf("ERROR: parsing config file (%s) for CC_PORT\n",configFile);
    exit(1);
  } else {
    port = atoi(tmpstr);
  }

  rc = get_conf_var(configFile, "ENABLE_WS_SECURITY", &tmpstr);
  if (rc != 1) {
    /* Default to enabled */
    use_wssec = 1;
  } else {
    if (!strcmp(tmpstr, "Y")) {
      use_wssec = 1;
    } else {
      use_wssec = 0;
    }
  }
  
  if (MODE == 0) {
    snprintf(endpoint_uri, 256," http://localhost:%d/axis2/services/EucalyptusCC", port);
  } else {
    snprintf(endpoint_uri, 256," http://%s/axis2/services/EucalyptusCC", argv[1]);
  }
  //env =  axutil_env_create_all(NULL, 0);
  env =  axutil_env_create_all("/tmp/fofo", AXIS2_LOG_LEVEL_TRACE);
  
  client_home = AXIS2_GETENV("AXIS2C_HOME");
  if (!client_home) {
    printf("must have AXIS2C_HOME set\n");
    exit(1);
  }
  stub = axis2_stub_create_EucalyptusCC(env, client_home, endpoint_uri);
  
  if (use_wssec) {
    rc = InitWSSEC(env, stub, policyFile);
    if (rc) {
      printf("cannot initialize WS-SEC policy (%s)\n",policyFile);
      exit(1);
    } 
  }
  
  if (MODE == 0) {
    rc = cc_killallInstances(env, stub);
    if (rc != 0) {
      printf("cc_killallInstances() failed\n");
      exit(1);
    }
  } else {
    /*
    if (!strcmp(argv[2], "registerImage")) {
      rc = cc_registerImage(argv[3], env, stub);
      if (rc != 0) {
	printf("cc_registerImage() failed: in:%s out:%d\n", argv[3], rc);
	exit(1);
      }
    */
    if (!strcmp(argv[2], "runInstances")) {
      char *amiId=NULL, *amiURL=NULL, *kernelId=NULL, *kernelURL=NULL, *ramdiskId=NULL, *ramdiskURL=NULL;
      if (argv[3]) amiId = argv[3];
      if (argv[4]) amiURL = argv[4];
      if (argv[5]) kernelId = argv[5];
      if (argv[6]) kernelURL = argv[6];
      if (argv[10]) ramdiskId = argv[10];
      if (argv[11]) ramdiskURL = argv[11];

      virtualMachine params = { 64, 1, 64, "m1.small" };

      rc = cc_runInstances(amiId, amiURL, kernelId, kernelURL, ramdiskId, ramdiskURL, atoi(argv[7]), atoi(argv[8]), argv[9], &params, env, stub);
      if (rc != 0) {
	printf("cc_runInstances() failed: in:%s out:%d\n", argv[4], rc);
	exit(1);
      }
    } else if (!strcmp(argv[2], "describeInstances")) {
      rc = cc_describeInstances(NULL, 0, env, stub);
      if (rc != 0) {
	printf("cc_describeInstances() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "describeServices")) {
      rc = cc_describeServices(env, stub);
      if (rc != 0) {
	printf("cc_describeServices() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "startService")) {
      rc = cc_startService(env, stub);
      if (rc != 0) {
	printf("cc_startService() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "stopService")) {
      rc = cc_stopService(env, stub);
      if (rc != 0) {
	printf("cc_stopService() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "enableService")) {
      rc = cc_enableService(env, stub);
      if (rc != 0) {
	printf("cc_enableService() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "disableService")) {
      rc = cc_disableService(env, stub);
      if (rc != 0) {
	printf("cc_disableService() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "shutdownService")) {
      rc = cc_shutdownService(env, stub);
      if (rc != 0) {
	printf("cc_shutdownService() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "getConsoleOutput")) {
      rc = cc_getConsoleOutput(argv[3], env, stub);
      if (rc != 0) {
	printf("cc_getConsoleOutput() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "rebootInstances")) {
      char *instIds[256];
      if (argv[3] != NULL) {
	instIds[0] = strdup(argv[3]);
      }
      rc = cc_rebootInstances(instIds, 1, env, stub);
      if (rc != 0) {
	printf("cc_rebootInstances() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "terminateInstances")) {
      char *instIds[256];
      i=3;
      while (argv[i] != NULL) {
	instIds[i-3] = strdup(argv[i]);
	i++;
      }
      if ( (i-3) > 0) {
	rc = cc_terminateInstances(instIds, i-3, env, stub);
	if (rc != 0) {
	  printf("cc_terminateInstances() failed\n");
	  exit(1);
	}
      }
    } else if (!strcmp(argv[2], "describeResources")) {
      rc = cc_describeResources(env, stub);
      if (rc != 0) {
	printf("cc_describeResources() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "startNetwork")) {
      char **ccs;
      int ccsLen=0, i;
      ccs = malloc(sizeof(char *) * 32);
      for (i=0; i<32; i++) {
	if (argv[i+5]) {
	  ccs[i] = strdup(argv[i+5]);
	  ccsLen++;
	} else {
	  i=33;
	}
      }
      rc = cc_startNetwork(atoi(argv[3]), argv[4], ccs, ccsLen, env, stub);
      if (rc != 0) {
	printf("cc_startNetwork() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "describeNetworks")) {
      char **ccs, *nameserver;
      int ccsLen=0, i;
      ccs = malloc(sizeof(char *) * 32);
      for (i=0; i<32; i++) {
	if (argv[i+3]) {
	  ccs[i] = strdup(argv[i+3]);
	  ccsLen++;
	} else {
	  i=33;
	}
      }
      nameserver = strdup("1.2.3.4");

      rc = cc_describeNetworks(nameserver, ccs, ccsLen, env, stub);
      if (rc != 0) {
	printf("cc_describeNetworks() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "configureNetwork")) {
      rc = cc_configureNetwork(argv[3], argv[4], argv[5], atoi(argv[6]), atoi(argv[7]), argv[8], env, stub);
      if (rc != 0) {
	printf("cc_configureNetwork() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "stopNetwork")) {
      rc = cc_stopNetwork(atoi(argv[3]), argv[4], env, stub);
      if (rc != 0) {
	printf("cc_stopNetwork() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "assignAddress")) {
      rc = cc_assignAddress(argv[3], argv[4], env, stub);
      if (rc != 0) {
	printf("cc_assignNetwork() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "unassignAddress")) {
      rc = cc_unassignAddress(argv[3], argv[4], env, stub);
      if (rc != 0) {
	printf("cc_unassignNetwork() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "attachVolume")) {
      rc = cc_attachVolume(argv[3], argv[4], argv[5], argv[6], env, stub);
      if (rc != 0) {
	printf("cc_attachVolume() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "detachVolume")) {
      rc = cc_detachVolume(argv[3], argv[4], argv[5], argv[6], atoi(argv[7]), env, stub);
      if (rc != 0) {
	printf("cc_unassignNetwork() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "bundleInstance")) {
      rc = cc_bundleInstance(argv[3], argv[4], argv[5], argv[6], argv[7], env, stub);
      if (rc != 0) {
	printf("cc_bundleInstance() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "createImage")) {
      rc = cc_createImage(argv[3], argv[4], argv[5], env, stub);
      if (rc != 0) {
	printf("cc_createImage() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "describePublicAddresses")) {
      rc = cc_describePublicAddresses(env, stub);
      if (rc != 0) {
	printf("cc_describePublicAddresses() failed\n");
	exit(1);
      }
    } else if (!strcmp(argv[2], "killallInstances")) {
      rc = cc_killallInstances(env, stub);
      if (rc != 0) {
	printf("cc_killallInstances() failed\n");
	exit(1);
      }
    }
  }
  
  exit(0);
}
示例#11
0
AXIS2_EXTERN axutil_log_t *AXIS2_CALL
axutil_log_create(
    axutil_allocator_t *allocator,
    axutil_log_ops_t *ops,
    const axis2_char_t *stream_name)
{
    axutil_log_impl_t *log_impl;
    axis2_char_t *path_home;
    axis2_char_t log_file_name[AXUTIL_LOG_FILE_NAME_SIZE];
    axis2_char_t log_dir[AXUTIL_LOG_FILE_NAME_SIZE];
    axis2_char_t tmp_filename[AXUTIL_LOG_FILE_NAME_SIZE];

    if (!allocator)
        return NULL;

    log_impl = (axutil_log_impl_t *) AXIS2_MALLOC(allocator,
                   sizeof(axutil_log_impl_t));

    if (!log_impl)
        return NULL;

    log_impl->mutex =
        axutil_thread_mutex_create(allocator, AXIS2_THREAD_MUTEX_DEFAULT);

    if (!log_impl->mutex)
    {
        fprintf(stderr, "cannot create log mutex \n");
        return NULL;
    }

#ifndef WIN32
    signal(SIGXFSZ, SIG_IGN);
#endif

    /* default log file is axis2.log */
    if (stream_name)
        AXIS2_SNPRINTF(tmp_filename, AXUTIL_LOG_FILE_NAME_SIZE, "%s", stream_name);
    else
        AXIS2_SNPRINTF(tmp_filename, AXUTIL_LOG_FILE_NAME_SIZE, "%s", "axis2.log");

    /* we write all logs to AXIS2C_HOME/logs if it is set otherwise
     * to the working dir
     */
    if (stream_name && !(axutil_rindex(stream_name, AXIS2_PATH_SEP_CHAR)))
    {
        path_home = AXIS2_GETENV("AXIS2C_HOME");
        if (path_home)
        {
            AXIS2_SNPRINTF(log_dir, AXUTIL_LOG_FILE_NAME_SIZE, "%s%c%s", 
                path_home, AXIS2_PATH_SEP_CHAR, "logs");
            if (AXIS2_SUCCESS ==
                axutil_file_handler_access(log_dir, AXIS2_F_OK))
            {
                AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, 
                    "%s%c%s", log_dir, AXIS2_PATH_SEP_CHAR, tmp_filename);
            }
            else
            {
                fprintf(stderr, "log folder %s does not exist - log file %s "\
                    "is written to . dir\n", log_dir, tmp_filename);
                AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s", 
                    tmp_filename);
            }
        }
        else
        {
            fprintf(stderr,
                "AXIS2C_HOME is not set - log is written to . dir\n");
            AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s", 
                tmp_filename);
        }
    }
    else
    {
        AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s", 
            tmp_filename);
    }
    log_impl->file_name = AXIS2_MALLOC(allocator, AXUTIL_LOG_FILE_NAME_SIZE);
    log_impl->log.size = AXUTIL_LOG_FILE_SIZE;
    sprintf(log_impl->file_name, "%s", log_file_name);

    axutil_thread_mutex_lock(log_impl->mutex);

    log_impl->stream = axutil_file_handler_open(log_file_name, "a+");
    axutil_log_impl_rotate((axutil_log_t *) log_impl);

    axutil_thread_mutex_unlock(log_impl->mutex);

    if (!log_impl->stream)
        log_impl->stream = stderr;

    /* by default, log is enabled */
    log_impl->log.enabled = 1;
    log_impl->log.level = AXIS2_LOG_LEVEL_DEBUG;

    if (ops)
    {
        log_impl->log.ops = ops;
    }
    else
    {
        log_impl->log.ops = &axutil_log_ops_var;
    }

    return &(log_impl->log);
}
int
main(
    int argc,
    char **argv)
{
    const axutil_env_t *env = NULL;
    const axis2_char_t *address = NULL;
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_options_t *options = NULL;
    const axis2_char_t *client_home = NULL;
    axis2_svc_client_t *svc_client = NULL;
    axiom_node_t *payload = NULL;
    axiom_node_t *ret_node = NULL;

    /* Set up the environment */
    env =
        axutil_env_create_all("echo_blocking_addr_amqp.log", AXIS2_LOG_LEVEL_TRACE);

    /* Set end point reference of echo service */
    address = "amqp://localhost:5672/axis2/services/echo";
    if (argc > 1)
        address = argv[1];
    if (axutil_strcmp(address, "-h") == 0)
    {
        printf("Usage : %s [endpoint_url]\n", argv[0]);
        printf("use -h for help\n");
        return 0;
    }
    printf("Using endpoint : %s\n", address);

    /* Create EPR with given address */
    endpoint_ref = axis2_endpoint_ref_create(env, address);

    /* Setup options */
    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);
    axis2_options_set_action(options, env,
                             "http://ws.apache.org/axis2/c/samples/echoString");

    /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
     * using the axis2.xml file.
     * In this sample client_home points to the Axis2/C default deploy folder. The client_home can 
     * be different from this folder on your system. For example, you may have a different folder 
     * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the 
     * modules that the client uses
     */
    client_home = AXIS2_GETENV("AXIS2C_HOME");
    if (!client_home || !strcmp(client_home, ""))
        client_home = "../..";

    /* Create service client */
    svc_client = axis2_svc_client_create(env, client_home);
    if (!svc_client)
    {
        printf
            ("Error creating service client, Please check AXIS2C_HOME again\n");
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        AXIS2_ERROR_GET_MESSAGE(env->error));
        return -1;
    }

    /* Set service client options */
    axis2_svc_client_set_options(svc_client, env, options);

    /* Engage addressing module */
    axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);

    /* Build the SOAP request message payload using OM API. */
    payload = build_om_payload_for_echo_svc(env);

    /* Send request */
    ret_node = axis2_svc_client_send_receive(svc_client, env, payload);

    if (ret_node)
    {
        axis2_char_t *om_str = NULL;
        om_str = axiom_node_to_string(ret_node, env);
        if (om_str)
        {
            printf("\nReceived OM : %s\n", om_str);
            AXIS2_FREE(env->allocator, om_str);
        }
        printf("\necho client invoke SUCCESSFUL!\n");
    }
    else
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        AXIS2_ERROR_GET_MESSAGE(env->error));
        printf("echo client invoke FAILED!\n");
    }

    if (svc_client)
    {
        axis2_svc_client_free(svc_client, env);
        svc_client = NULL;
    }

    if (env)
    {
        axutil_env_free((axutil_env_t *) env);
        env = NULL;
    }

    return 0;
}
示例#13
0
int
main(
    int argc,
    char **argv)
{
    const axutil_env_t *env = NULL;
    const axis2_char_t *address = NULL;
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_endpoint_ref_t *reply_to = NULL;
    axis2_options_t *options = NULL;
    const axis2_char_t *client_home = NULL;
    axis2_svc_client_t *svc_client = NULL;
    axiom_node_t *payload = NULL;
    axis2_callback_t *callback = NULL;
    int count = 0;

    /* Set up the environment */
    env =
        axutil_env_create_all("echo_non_blocking_dual.log",
                              AXIS2_LOG_LEVEL_TRACE);

    /* Set end point reference of echo service */
    address = "http://localhost:9090/axis2/services/echo";
    if (argc > 1)
        address = argv[1];
    if (axutil_strcmp(address, "-h") == 0)
    {
        printf("Usage : %s [endpoint_url]\n", argv[0]);
        printf("use -h for help\n");
        return 0;
    }
    printf("Using endpoint : %s\n", address);

    /* Create EPR with given address */
    endpoint_ref = axis2_endpoint_ref_create(env, address);

    /* Setup options */
    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);
    axis2_options_set_use_separate_listener(options, env, AXIS2_TRUE);

    /* Seperate listner needs addressing, hence addressing stuff in options */
    axis2_options_set_action(options, env,
                             "http://ws.apache.org/axis2/c/samples/echoString");
    reply_to =
        axis2_endpoint_ref_create(env,
                                  "http://localhost:6060/axis2/services/__ANONYMOUS_SERVICE__/__OPERATION_OUT_IN__");
    axis2_options_set_reply_to(options, env, reply_to);

    /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
     * using the axis2.xml file.
     * In this sample client_home points to the Axis2/C default deploy folder. The client_home can 
     * be different from this folder on your system. For example, you may have a different folder 
     * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the 
     * modules that the client uses
     */
    client_home = AXIS2_GETENV("AXIS2C_HOME");
    if (!client_home || !strcmp(client_home, ""))
        client_home = "../..";

    /* Create service client */
    svc_client = axis2_svc_client_create(env, client_home);
    if (!svc_client)
    {
        printf
            ("Error creating service client, Please check AXIS2C_HOME again\n");
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        AXIS2_ERROR_GET_MESSAGE(env->error));
        return -1;
    }

    /* Set service client options */
    axis2_svc_client_set_options(svc_client, env, options);

    axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
    /*axis2_svc_client_engage_module(svc_client, env, "sandesha2"); */

    /* Build the SOAP request message payload using OM API. */
    payload = build_om_payload_for_echo_svc(env);

    /* Create the callback object with default on_complete and on_error
       callback functions */
    callback = axis2_callback_create(env);

    /* Set our on_complete fucntion pointer to the callback object */
    axis2_callback_set_on_complete(callback, echo_callback_on_complete);

    /* Set our on_error function pointer to the callback object */
    axis2_callback_set_on_error(callback, echo_callback_on_error);

    /* Send request */
    axis2_svc_client_send_receive_non_blocking(svc_client, env,
                                               payload, callback);

    /** Wait till callback is complete. Simply keep the parent thread running
       until our on_complete or on_error is invoked */
    while (count < MAX_COUNT)
    {
        if (isComplete)
        {
            /* We are done with the callback */
            break;
        }

/*         AXIS2_SLEEP(1); */
        count++;
    }

    if (!(count < MAX_COUNT))
    {
        printf("\necho client invoke FAILED. Counter timed out.\n");
    }

    if (svc_client)
    {
        AXIS2_SLEEP(1);
        axis2_svc_client_free(svc_client, env);
        svc_client = NULL;
    }

    if (env)
    {
        axutil_env_free((axutil_env_t *) env);
        env = NULL;
    }

    return 0;
}
示例#14
0
//!
//! Handles the get keys service request.
//!
//! @param[in]  service service name identifier
//! @param[out] outCCCert output CC Certificate
//! @param[out] outNCCert output NC certificate
//!
//! @return EUCA_OK on success or the following error codes:
//!         \li EUCA_MEMORY_ERROR: if we fail to allocate memory
//!         \li EUCA_INVALID_ERROR: if any parameter does not meet the preconditions
//!
//! @pre All parameters must be non-NULLs.
//!
//! @post On success, the outCCCert, outNCCert parameters are set appropriately.
//!
int doGetKeys(char *service, char **outCCCert, char **outNCCert)
{
    int fd = -1;
    int rc = 0;
    int bufsize = 0;
    int pid = 0;
    int filedes[2] = { 0 };
    int status = 0;
    char *tmp = NULL;
    char *buf = NULL;
    char *home = NULL;
    char *ccert = NULL;
    char *ncert = NULL;
    char file[MAX_PATH] = { 0 };
    axutil_env_t *env = NULL;
    axis2_char_t *client_home = NULL;
    axis2_stub_t *stub = NULL;

    if (!service || !outCCCert || !outNCCert) {
        printf("ERROR: Invalid params: service=%s, outCCCert=%p, outNCCert=%p\n", service, outCCCert, outNCCert);
        return (EUCA_INVALID_ERROR);
    }

    *outCCCert = *outNCCert = NULL;

    bufsize = 1000 * 1024;
    if ((buf = EUCA_ALLOC(bufsize, sizeof(char))) == NULL) {
        printf("ERROR: Out of memory!\n");
        return (EUCA_MEMORY_ERROR);
    }

    if (!strcmp(service, "self")) {
        home = NULL;
        if ((tmp = getenv("EUCALYPTUS")) != NULL)
            home = strdup(tmp);

        if (!home)
            home = strdup("");

        if (!home) {
            printf("ERROR: Out of memory!\n");
            EUCA_FREE(buf);
            return (EUCA_MEMORY_ERROR);
        }

        snprintf(file, MAX_PATH, EUCALYPTUS_KEYS_DIR "/cluster-cert.pem", home);
        if ((fd = open(file, O_RDONLY)) >= 0) {
            bzero(buf, bufsize);
            lseek(fd, -1 * bufsize, SEEK_END);
            if ((rc = read(fd, buf, bufsize)) > 0) {
                *outCCCert = base64_enc(((unsigned char *)buf), strlen(buf));
            }
            close(fd);
        }

        snprintf(file, MAX_PATH, EUCALYPTUS_KEYS_DIR "/node-cert.pem", home);
        if ((fd = open(file, O_RDONLY)) >= 0) {
            bzero(buf, bufsize);
            lseek(fd, -1 * bufsize, SEEK_END);
            // make sure that buf is NULL terminated
            if ((rc = read(fd, buf, bufsize - 1)) > 0) {
                *outNCCert = base64_enc(((unsigned char *)buf), strlen(buf));
            }
            close(fd);
        }

        EUCA_FREE(home);
    } else {
        if (pipe(filedes) == 0) {
            pid = fork();
            if (pid == 0) {
                close(filedes[0]);

                env = axutil_env_create_all(NULL, 0);
                if ((client_home = AXIS2_GETENV("AXIS2C_HOME")) == NULL) {
                    printf("ERROR: cannot retrieve AXIS2_HOME environment variable.\n");
                    exit(1);
                } else {
                    if ((stub = axis2_stub_create_EucalyptusGL(env, client_home, service)) == NULL) {
                        printf("ERROR: cannot retrieve AXIS2 stub.\n");
                        exit(1);
                    }

                    ccert = ncert = NULL;
                    if ((rc = gl_getKeys("self", &ccert, &ncert, env, stub)) == EUCA_OK) {
                        bzero(buf, bufsize);
                        if (ccert)
                            snprintf(buf, bufsize, "%s", ccert);
                        rc = write(filedes[1], buf, bufsize);

                        bzero(buf, bufsize);
                        if (ncert)
                            snprintf(buf, bufsize, "%s", ncert);
                        rc = write(filedes[1], buf, bufsize);
                    }
                }
                close(filedes[1]);
                exit(0);
            } else {
                close(filedes[1]);

                rc = read(filedes[0], buf, bufsize - 1);
                if (rc) {
                    *outCCCert = strdup(buf);
                }

                rc = read(filedes[0], buf, bufsize - 1);
                if (rc) {
                    *outNCCert = strdup(buf);
                }

                close(filedes[0]);
                wait(&status);
            }
        }
    }

    EUCA_FREE(buf);
    return (EUCA_OK);
}
int main(int argc, char** argv)
{
    const axutil_env_t *env = NULL;
    const axis2_char_t *address = NULL;
    axis2_endpoint_ref_t* endpoint_ref = NULL;
    axis2_endpoint_ref_t* reply_to = NULL;
    axis2_options_t *options = NULL;
    const axis2_char_t *client_home = NULL;
    axis2_svc_client_t* svc_client = NULL;
    axiom_node_t *payload = NULL;
    axis2_listener_manager_t *listener_manager = NULL;
    int i;
    axis2_status_t status = AXIS2_FAILURE;
    axiom_node_t *result = NULL;
    neethi_policy_t *policy = NULL;
   
    /* Set up the environment */
    env = axutil_env_create_all("rm_echo_single_1_1.log", AXIS2_LOG_LEVEL_TRACE);
 

    /* Set end point reference of echo service */
    /*address = "http://127.0.0.1:9090/axis2/services/RM11SampleService";*/
    address = "http://127.0.0.1:9090/axis2/services/RM11SampleService";
    if (argc > 1)
    {
        if (axutil_strcmp(argv[1], "-h") == 0)
        {
            printf("Usage : %s [endpoint_url]\n", argv[0]);
            printf("use -h for help\n");
            return 0;
        }
        else
        {
            address = argv[1];
        }
    }
    printf ("Using endpoint : %s\n", address);
    
    /* Create EPR with given address */
    endpoint_ref = axis2_endpoint_ref_create(env, address);

    /* Setup options */
    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);
    
    /* Seperate listner needs addressing, hence addressing stuff in options */
    axis2_options_set_action(options, env,
        "http://127.0.0.1:8080/axis2/services/RM11SampleService/anonOutInOp");

    reply_to = axis2_endpoint_ref_create(env, AXIS2_WSA_ANONYMOUS_URL);
    axis2_options_set_reply_to(options, env, reply_to);

    /* Set up deploy folder. It is from the deploy folder, the configuration is 
     * picked up using the axis2.xml file.
     * In this sample client_home points to the Axis2/C default deploy folder. 
     * The client_home can be different from this folder on your system. For 
     * example, you may have a different folder (say, my_client_folder) with its 
     * own axis2.xml file. my_client_folder/modules will have the modules that 
     * the client uses
     */
    client_home = AXIS2_GETENV("AXIS2C_HOME");
    if (!client_home)
    {
        client_home = "../../deploy";
    }

    /* Create service client */
    svc_client = axis2_svc_client_create(env, client_home);
    if (!svc_client)
    {
        printf("Error creating service client\n");
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code:%d :: %s", 
                env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error));

        return -1;
    }

    policy = neethi_util_create_policy_from_file(env, "policy/rm11-policy.xml");
    if(!policy)
    {
        printf("\nPolicy creation failed from the file");
        return 0;
    }

    status = axis2_svc_client_set_policy(svc_client, env, policy);

    if(status == AXIS2_FAILURE)
    {
        printf("Policy setting failed\n");
    }


    /* Set service client options */
    axis2_svc_client_set_options(svc_client, env, options);    
    
    axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);  
    axis2_svc_client_engage_module(svc_client, env, "sandesha2");

    listener_manager = axis2_listener_manager_create(env);
    if (!listener_manager)
    {
        return AXIS2_FAILURE;
    }

    for(i = 1; i < 4; i++)
    {
        axis2_char_t echo_str[7];
        sprintf(echo_str, "%s%d", "echo", i);
        payload = build_om_payload_for_echo_svc(env, echo_str);
        result = axis2_svc_client_send_receive(svc_client, env, payload);
        if(result)
        {
            /*axis2_char_t *om_str = NULL;
            om_str = axiom_node_to_string(result, env);
            if (om_str)
            {
                printf("\nReceived OM : %s\n", om_str);
                AXIS2_FREE(env->allocator, om_str);
            }*/
            printf("\necho client two way single channel invoke SUCCESSFUL!\n");
            result = NULL;
        }
        else
        {
            printf("\necho client two way single channel invoke FAILED!\n");
        }
    }

    AXIS2_SLEEP(SANDESHA2_SLEEP); 

    axis2_svc_client_close(svc_client, env);

    AXIS2_SLEEP(6 * SANDESHA2_SLEEP);

    if (svc_client)
    {
        axis2_svc_client_free(svc_client, env);
        svc_client = NULL;
    }
    
    return 0;
}
示例#16
0
int main(int argc, char** argv)
{
    const axutil_env_t *env = NULL;
    const axis2_char_t *address = NULL;
    axis2_endpoint_ref_t* endpoint_ref = NULL;
    axis2_options_t *options = NULL;
    axis2_char_t *client_home = NULL;
    axis2_svc_client_t* svc_client = NULL;
    axutil_hash_t *savan_options = NULL;
    axis2_status_t status = AXIS2_FAILURE;
    savan_client_t *savan_client = NULL;

    /* Set up the environment */
    env = axutil_env_create_all("./subscriber.log", AXIS2_LOG_LEVEL_DEBUG);

    printf("Starting Savan subscriber...\n");

    client_home = AXIS2_GETENV("AXIS2C_HOME");
    
    /* Set end point reference of echo service */
    address = "http://localhost:9090/axis2/services/wso2";
    if (argc > 1 )
        address = argv[1];
    
    printf ("Event source endpoint : %s\n", address);
    
    /* Create EPR with given address */
    endpoint_ref = axis2_endpoint_ref_create(env, address);

    /* Setup options */
    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);
/*    axis2_options_set_action(options, env,
        "http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe");    
*/
    /* Create service client */
    svc_client = axis2_svc_client_create(env, client_home);
    if (!svc_client)
    {
        printf("Error creating service client\n");
        exit(1);
    }

    /* Set service client options */
    axis2_svc_client_set_options(svc_client, env, options);    
    
    /* Engage addressing module */
    axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
    
    /* Engage savan module */
    axis2_svc_client_engage_module(svc_client, env, "savan");

    savan_options = axutil_hash_make(env);
    axutil_hash_set(savan_options, SAVAN_OP_KEY_NOTIFY_EPR, AXIS2_HASH_KEY_STRING,
        "http://localhost:9090/axis2/services/wsfc");

    /**
     * Following commented lines show how to use filtering when savan server side is
     * built and running with filtering enabled.
     */
    /*axutil_hash_set(savan_options, SAVAN_OP_KEY_FILTER, AXIS2_HASH_KEY_STRING,
        "//wsfc");

    axutil_hash_set(savan_options, SAVAN_OP_KEY_FILTER_DIALECT, AXIS2_HASH_KEY_STRING,
        DEFAULT_FILTER_DIALECT);*/

    /* Create a savan client */
    savan_client = savan_client_create(env);

    /* Send request */
    status  = savan_client_subscribe(savan_client, env, svc_client, savan_options);
    
    if (status == AXIS2_SUCCESS)
    {
        printf("Subscribe successful\n");
        printf("Subscription ID: %s\n", savan_client_get_sub_id(savan_client));
    }
    else
    {
        printf("Subscription Failed\n");
        exit(0);
    }

    AXIS2_SLEEP(120);


    printf("Unsubscribing...\n");
    address = savan_client_get_sub_url(savan_client);
    endpoint_ref = axis2_options_get_to(options, env);
    axis2_endpoint_ref_set_address(endpoint_ref, env, address);
    axis2_svc_client_remove_all_headers(svc_client, env);
    status = savan_client_unsubscribe(savan_client, env, svc_client);
    if (status == AXIS2_SUCCESS)
    {
        printf("Unsubscribe successful\n");
    }


    if (svc_client)
    {
        axis2_svc_client_free(svc_client, env);
        svc_client = NULL;
    }
    
    return 0;
}
示例#17
0
int
main(
    int argc,
    char** argv)
{
    const axutil_env_t *env = NULL;
    const axis2_char_t *address = NULL;
    const axis2_char_t *client_home = NULL;
    axis2_char_t *file_name = NULL;
    axis2_char_t *policy_file = NULL;
    axis2_endpoint_ref_t* endpoint_ref = NULL;
    axis2_options_t *options = NULL;
    axis2_svc_client_t* svc_client = NULL;
    axiom_node_t *payload = NULL;
    axiom_node_t *ret_node = NULL;
    axis2_status_t status = AXIS2_FAILURE;
    neethi_policy_t *policy = NULL;
    /*axutil_property_t *property  = NULL;
     int i = 0;*/

    /* Set up the environment */
    env = axutil_env_create_all("echo.log", AXIS2_LOG_LEVEL_TRACE);

    /*if (argc == 4)
     AXIS2_SLEEP(10); */

    /* Set end-point-reference of echo service */
    address = "http://localhost:9090/axis2/services/echo";
    if(argc > 2)
    {
        address = argv[1];
        client_home = argv[2];
        printf("Using endpoint : %s\n", address);
        printf("Using client_home : %s\n", client_home);
    }

    if((axutil_strcmp(argv[1], "-h") == 0) || (axutil_strcmp(argv[1], "--help") == 0))
    {
        printf("Usage : %s [endpoint_url] [client_home]\n", argv[0]);
        printf("use -h for help\n");
        return 0;
    }

    /* Create end-point-reference with given address */
    endpoint_ref = axis2_endpoint_ref_create(env, address);

    /* Setup options */
    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);
    axis2_options_set_action(options, env, "http://example.com/ws/2004/09/policy/Test/EchoRequest");

    /*axis2_options_set_action(options, env,
     "http://xmlsoap.org/Ping");*/
    /*axis2_options_set_action(options, env,
     "urn:echoString");*/

    /*axis2_options_set_soap_action(options, env, axutil_string_create(env, "http://xmlsoap.org/Ping"));
     axis2_options_set_soap_version(options, env, AXIOM_SOAP11);*/
    axis2_options_set_soap_version(options, env, AXIOM_SOAP12);

    /*If the client home is not specified, use the WSFC_HOME*/
    if(!client_home)
    {
        client_home = AXIS2_GETENV("WSFC_HOME");
        printf("\nNo client_home specified. Using default %s", client_home);
    }

    /* Create service client */
    printf("client_home= %s", client_home);
    svc_client = axis2_svc_client_create(env, client_home);
    if(!svc_client)
    {
        printf("Error creating service client\n");
        return -1;
    }

    /* Set service client options */
    axis2_svc_client_set_options(svc_client, env, options);

    /* 
     property = axutil_property_create(env);
     axutil_property_set_scope(property, env, AXIS2_SCOPE_APPLICATION);
     axutil_property_set_value(property, env, AXIS2_WSA_NAMESPACE_SUBMISSION);
     axis2_options_set_property(options, env, AXIS2_WSA_VERSION, property);
     */

    /*We need to specify the client's policy file location*/
    if(client_home)
    {
        file_name = axutil_stracat(env, client_home, AXIS2_PATH_SEP_STR);
        policy_file = axutil_stracat(env, file_name, "policy.xml");
        AXIS2_FREE(env->allocator, file_name);
        file_name = NULL;
    }
    else
    {
        printf("Client Home not Specified\n");
        printf("echo client invoke FAILED!\n");
        return 0;
    }
    /*Create the policy, from file*/
    policy = neethi_util_create_policy_from_file(env, policy_file);
    if(policy_file)
    {
        AXIS2_FREE(env->allocator, policy_file);
        policy_file = NULL;
    }
    if(!policy)
    {
        printf("\nPolicy creation failed from the file. %s\n", policy_file);
    }

    status = axis2_svc_client_set_policy(svc_client, env, policy);

    if(status == AXIS2_FAILURE)
    {
        printf("Policy setting failed\n");
    }

    /* Build the SOAP request message payload using OM API.*/
    payload = build_om_payload_for_echo_svc(env);
    /*axis2_options_set_enable_mtom(options, env, AXIS2_TRUE);*/

    /*If not engaged in the client's axis2.xml, uncomment this line*/
    axis2_svc_client_engage_module(svc_client, env, "rampart");

    /* Send request */
    ret_node = axis2_svc_client_send_receive(svc_client, env, payload);

    if(axis2_svc_client_get_last_response_has_fault(svc_client, env))
    {
        axiom_soap_envelope_t *soap_envelope = NULL;
        axiom_soap_body_t *soap_body = NULL;
        axiom_soap_fault_t *soap_fault = NULL;

        printf("\nResponse has a SOAP fault\n");
        soap_envelope = axis2_svc_client_get_last_response_soap_envelope(svc_client, env);
        if(soap_envelope)
            soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
        if(soap_body)
            soap_fault = axiom_soap_body_get_fault(soap_body, env);
        if(soap_fault)
        {
            printf("\nReturned SOAP fault: %s\n", axiom_node_to_string(
                axiom_soap_fault_get_base_node(soap_fault, env), env));
        }
        printf("echo client invoke FAILED!\n");
        return -1;
    }

    if(ret_node)
    {
        axis2_char_t *om_str = NULL;
        om_str = axiom_node_to_string(ret_node, env);
        if(om_str)
        {
            printf("\nReceived OM : %s\n", om_str);
        }
        printf("\necho client invoke SUCCESSFUL!\n");
        AXIS2_FREE(env->allocator, om_str);
        ret_node = NULL;
    }
    else
    {
        printf("echo client invoke FAILED!\n");
        return -1;
    }

    if(svc_client)
    {
        axis2_svc_client_free(svc_client, env);
        svc_client = NULL;
    }
    if(env)
    {
        axutil_env_free((axutil_env_t *)env);
        env = NULL;
    }

    return 0;
}
示例#18
0
//!
//! Main entry point of the application
//!
//! @param[in] argc the number of parameter passed on the command line
//! @param[in] argv the list of arguments
//!
//! @return EUCA_OK
//!
int main(int argc, char **argv)
{
    int rc = 0;
    int i = 0;
    int port = 0;
    int use_wssec = 0;
    int ccsLen = 0;
    int resSize = 0;
    char **ccs = NULL;
    char *nameserver = NULL;
    char *euca_home = NULL;
    char buf[40960] = { 0 };
    char configFile[1024] = { 0 };
    char policyFile[1024] = { 0 };
    char *instIds[256] = { 0 };
    char *amiId = NULL;
    char *amiURL = NULL;
    char *kernelId = NULL;
    char *kernelURL = NULL;
    char *ramdiskId = NULL;
    char *ramdiskURL = NULL;
    axutil_env_t *env = NULL;
    axis2_char_t *client_home = NULL;
    axis2_char_t endpoint_uri[256] = { 0 };
    axis2_char_t *tmpstr = NULL;
    axis2_stub_t *stub = NULL;
    virtualMachine params = { 64, 1, 64, "m1.small" };
    sensorResource **res;

    bzero(&mymeta, sizeof(ncMetadata));

    mymeta.userId = strdup("admin");
    mymeta.correlationId = strdup("1234abcd");
    mymeta.epoch = 3;
    mymeta.servicesLen = 16;
    snprintf(mymeta.services[15].name, 16, "eucalyptusname");
    snprintf(mymeta.services[15].type, 16, "eucalyptustype");
    snprintf(mymeta.services[15].partition, 16, "eucalyptuspart");
    mymeta.services[15].urisLen = 1;
    snprintf(mymeta.services[15].uris[0], 512, "http://192.168.254.3:8773/services/Eucalyptus");

    if (MODE == 0) {
        if (argc != 2 || strcmp(argv[1], "-9")) {
            printf("only runnable from inside euca\n");
            exit(1);
        }
    } else {
        if (argc < 3) {
            printf("USAGE: CCclient <host:port> <command> <opts>\n");
            exit(1);
        }
    }

    euca_home = getenv("EUCALYPTUS");
    if (!euca_home) {
        euca_home = "";
    }
    snprintf(configFile, 1024, EUCALYPTUS_CONF_LOCATION, euca_home);
    snprintf(policyFile, 1024, EUCALYPTUS_KEYS_DIR "/cc-client-policy.xml", euca_home);

    rc = get_conf_var(configFile, "CC_PORT", &tmpstr);
    if (rc != 1) {
        // error
        logprintf("ERROR: parsing config file (%s) for CC_PORT\n", configFile);
        exit(1);
    } else {
        port = atoi(tmpstr);
    }

    rc = get_conf_var(configFile, "ENABLE_WS_SECURITY", &tmpstr);
    if (rc != 1) {
        /* Default to enabled */
        use_wssec = 1;
    } else {
        if (!strcmp(tmpstr, "Y")) {
            use_wssec = 1;
        } else {
            use_wssec = 0;
        }
    }

    if (MODE == 0) {
        snprintf(endpoint_uri, 256, "http://localhost:%d/axis2/services/EucalyptusCC", port);
    } else {
        snprintf(endpoint_uri, 256, "http://%s/axis2/services/EucalyptusCC", argv[1]);
    }
    env = axutil_env_create_all("/tmp/fofo", AXIS2_LOG_LEVEL_TRACE);

    client_home = AXIS2_GETENV("AXIS2C_HOME");
    if (!client_home) {
        printf("must have AXIS2C_HOME set\n");
        exit(1);
    }
    stub = axis2_stub_create_EucalyptusCC(env, client_home, endpoint_uri);

    if (use_wssec) {
        rc = InitWSSEC(env, stub, policyFile);
        if (rc) {
            printf("cannot initialize WS-SEC policy (%s)\n", policyFile);
            exit(1);
        }
    }

    if (MODE == 0) {
        rc = cc_killallInstances(env, stub);
        if (rc != 0) {
            printf("cc_killallInstances() failed\n");
            exit(1);
        }
    } else {
        if (!strcmp(argv[2], "runInstances")) {
            if (argv[3])
                amiId = argv[3];
            if (argv[4])
                amiURL = argv[4];
            if (argv[5])
                kernelId = argv[5];
            if (argv[6])
                kernelURL = argv[6];
            if (argv[10])
                ramdiskId = argv[10];
            if (argv[11])
                ramdiskURL = argv[11];

            rc = cc_runInstances(amiId, amiURL, kernelId, kernelURL, ramdiskId, ramdiskURL, atoi(argv[7]), atoi(argv[8]), argv[9], &params, env, stub);
            if (rc != 0) {
                printf("cc_runInstances() failed: in:%s out:%d\n", argv[4], rc);
                exit(1);
            }
        } else if (!strcmp(argv[2], "describeInstances")) {
            rc = cc_describeInstances(NULL, 0, env, stub);
            if (rc != 0) {
                printf("cc_describeInstances() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "describeServices")) {
            rc = cc_describeServices(env, stub);
            if (rc != 0) {
                printf("cc_describeServices() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "startService")) {
            rc = cc_startService(env, stub);
            if (rc != 0) {
                printf("cc_startService() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "stopService")) {
            rc = cc_stopService(env, stub);
            if (rc != 0) {
                printf("cc_stopService() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "enableService")) {
            rc = cc_enableService(env, stub);
            if (rc != 0) {
                printf("cc_enableService() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "disableService")) {
            rc = cc_disableService(env, stub);
            if (rc != 0) {
                printf("cc_disableService() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "shutdownService")) {
            rc = cc_shutdownService(env, stub);
            if (rc != 0) {
                printf("cc_shutdownService() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "getConsoleOutput")) {
            rc = cc_getConsoleOutput(argv[3], env, stub);
            if (rc != 0) {
                printf("cc_getConsoleOutput() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "rebootInstances")) {
            if (argv[3] != NULL) {
                instIds[0] = strdup(argv[3]);
            }
            rc = cc_rebootInstances(instIds, 1, env, stub);
            if (rc != 0) {
                printf("cc_rebootInstances() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "terminateInstances")) {
            i = 3;
            while (argv[i] != NULL) {
                instIds[i - 3] = strdup(argv[i]);
                i++;
            }
            if ((i - 3) > 0) {
                rc = cc_terminateInstances(instIds, i - 3, env, stub);
                if (rc != 0) {
                    printf("cc_terminateInstances() failed\n");
                    exit(1);
                }
            }
        } else if (!strcmp(argv[2], "describeResources")) {
            rc = cc_describeResources(env, stub);
            if (rc != 0) {
                printf("cc_describeResources() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "startNetwork")) {
            ccs = EUCA_ALLOC(32, sizeof(char *));
            for (i = 0; i < 32; i++) {
                if (argv[i + 5]) {
                    ccs[i] = strdup(argv[i + 5]);
                    ccsLen++;
                } else {
                    i = 33;
                }
            }
            rc = cc_startNetwork(atoi(argv[3]), argv[4], ccs, ccsLen, env, stub);
            if (rc != 0) {
                printf("cc_startNetwork() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "describeNetworks")) {
            ccs = EUCA_ALLOC(32, sizeof(char *));
            for (i = 0; i < 32; i++) {
                if (argv[i + 3]) {
                    ccs[i] = strdup(argv[i + 3]);
                    ccsLen++;
                } else {
                    i = 33;
                }
            }
            nameserver = strdup("1.2.3.4");

            rc = cc_describeNetworks(nameserver, ccs, ccsLen, env, stub);
            if (rc != 0) {
                printf("cc_describeNetworks() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "configureNetwork")) {
            rc = cc_configureNetwork(argv[3], argv[4], argv[5], atoi(argv[6]), atoi(argv[7]), argv[8], env, stub);
            if (rc != 0) {
                printf("cc_configureNetwork() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "stopNetwork")) {
            rc = cc_stopNetwork(atoi(argv[3]), argv[4], env, stub);
            if (rc != 0) {
                printf("cc_stopNetwork() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "broadcastNetworkInfo")) {
            rc = cc_broadcastNetworkInfo(argv[3], env, stub);
            if (rc != 0) {
                printf("cc_broadcastNetworkInfo() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "assignAddress")) {
            rc = cc_assignAddress(argv[3], argv[4], env, stub);
            if (rc != 0) {
                printf("cc_assignAddress() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "unassignAddress")) {
            rc = cc_unassignAddress(argv[3], argv[4], env, stub);
            if (rc != 0) {
                printf("cc_unassignAddress() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "attachVolume")) {
            rc = cc_attachVolume(argv[3], argv[4], argv[5], argv[6], env, stub);
            if (rc != 0) {
                printf("cc_attachVolume() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "detachVolume")) {
            rc = cc_detachVolume(argv[3], argv[4], argv[5], argv[6], atoi(argv[7]), env, stub);
            if (rc != 0) {
                printf("cc_unassignNetwork() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "bundleInstance")) {
            rc = cc_bundleInstance(argv[3], argv[4], argv[5], argv[6], argv[7], env, stub);
            if (rc != 0) {
                printf("cc_bundleInstance() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "bundleRestartInstance")) {
            rc = cc_bundleRestartInstance(argv[3], env, stub);
            if (rc != 0) {
                printf("cc_bundleRestartInstance() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "createImage")) {
            rc = cc_createImage(argv[3], argv[4], argv[5], env, stub);
            if (rc != 0) {
                printf("cc_createImage() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "describePublicAddresses")) {
            rc = cc_describePublicAddresses(env, stub);
            if (rc != 0) {
                printf("cc_describePublicAddresses() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "killallInstances")) {
            rc = cc_killallInstances(env, stub);
            if (rc != 0) {
                printf("cc_killallInstances() failed\n");
                exit(1);
            }
        } else if (!strcmp(argv[2], "describeSensors")) {
            rc = cc_describeSensors(10, 5000, NULL, 0, NULL, 0, &res, &resSize, env, stub);
            if (rc != 0) {
                printf("cc_describeSensors() failed: error=%d\n", rc);
                exit(1);
            }
            sensor_res2str(buf, sizeof(buf), res, resSize);
            printf("resources: %d\n%s\n", resSize, buf);
        } else if (!strcmp(argv[2], "modifyNode")) {
            rc = cc_modifyNode(argv[3], argv[4], env, stub);
            if (rc != 0) {
                printf("cc_modifyNode() failed: error=%d\n", rc);
                exit(1);
            }
        } else if (!strcmp(argv[2], "migrateInstances")) {
            rc = cc_migrateInstances(argv[3], env, stub);
            if (rc != 0) {
                printf("cc_migrateInstances() failed: error=%d\n", rc);
                exit(1);
            }
        } else if (!strcmp(argv[2], "startInstance")) {
            rc = cc_startInstance(argv[3], env, stub);
            if (rc != 0) {
                printf("cc_migrateInstances() failed: error=%d\n", rc);
                exit(1);
            }
        } else if (!strcmp(argv[2], "stopInstance")) {
            rc = cc_stopInstance(argv[3], env, stub);
            if (rc != 0) {
                printf("cc_migrateInstances() failed: error=%d\n", rc);
                exit(1);
            }
        } else {
            printf("unrecognized operation '%s'\n", argv[2]);
            exit(1);
        }
    }

    return (EUCA_OK);
}
示例#19
0
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");
}
ncStub * ncStubCreate (char *endpoint_uri, char *logfile, char *homedir) 
{
    axutil_env_t * env = NULL;
    axis2_char_t * client_home;
    axis2_stub_t * stub;
    ncStub * st = NULL;

    if ( logfile ) {
      env =  axutil_env_create_all (logfile, AXIS2_LOG_LEVEL_TRACE);
    } else {
      env =  axutil_env_create_all (NULL, 0);
    }
    if ( homedir ) {
        client_home = (axis2_char_t *)homedir;
    } else {
        client_home = AXIS2_GETENV("AXIS2C_HOME");
    }

    if (client_home == NULL) {
        logprintfl (EUCAERROR, "ERROR: cannot get AXIS2C_HOME");
	return NULL;
    }
    if (endpoint_uri == NULL) {
        logprintfl (EUCAERROR, "ERROR: empty endpoint_url");
	return NULL;
    }

    char * uri = endpoint_uri;

    // extract node name from the endpoint
    char * p = strstr (uri, "://"); // find "http[s]://..."
    if (p==NULL) {
      logprintfl (EUCAERROR, "ncStubCreate received invalid URI %s\n", uri);
      return NULL;
    }
    char * node_name = strdup (p+3); // copy without the protocol prefix
    if (node_name==NULL) {
      logprintfl (EUCAERROR, "ncStubCreate is out of memory\n");
      return NULL;
    }
    if ((p = strchr (node_name, ':')) != NULL) *p = '\0'; // cut off the port
    if ((p = strchr (node_name, '/')) != NULL) *p = '\0'; // if there is no port

    logprintfl (EUCADEBUG, "DEBUG: requested URI %s\n", uri);

    // see if we should redirect to the VMware broker
    if (strstr (uri, "VMwareBroker")) {
      uri = "http://localhost:8773/services/VMwareBroker";
      logprintfl (EUCADEBUG, "DEBUG: redirecting request to %s\n", uri);
    }

    // TODO: what if endpoint_uri, home, or env are NULL?
    stub = axis2_stub_create_EucalyptusNC(env, client_home, (axis2_char_t *)uri);

    if (stub && (st = malloc (sizeof(ncStub)))) {
        st->env=env;
        st->client_home=strdup((char *)client_home);
        st->endpoint_uri=(axis2_char_t *)strdup(endpoint_uri);
	st->node_name=(axis2_char_t *)strdup(node_name);
        st->stub=stub;
	if (st->client_home == NULL || st->endpoint_uri == NULL) {
            logprintfl (EUCAWARN, "WARNING: out of memory");
	}
    } else {
        logprintfl (EUCAWARN, "WARNING: out of memory");
    } 
    
    free (node_name);
    return st;
}
示例#21
0
/**
* auto generated function definition signature
* for "GetStructure|http://mopevm.ru/axis2/services/Subscribers" operation.
* @param env environment ( mandatory)* @param MessageContext the outmessage context
* @param _subscriberRequest of the adb_subscriberRequest_t*
*
* @return adb_subscriber_t*
*/
adb_subscriber_t* axis2_skel_Subscribers_GetStructure(const axutil_env_t *env , axis2_msg_ctx_t *msg_ctx,
                              adb_subscriberRequest_t* _subscriberRequest )
{
	axis2_stub_t *stub = NULL;
	const axis2_char_t *address = NULL;
	const axis2_char_t *client_home = NULL;
		
	adb_subscriberRequest_t* subscriberRequest;
	sqlite3 *db;
	sqlite3_stmt *stmt1, *stmt2;
	int rc1, rc2;
	char *query1, *query2;
	axis2_char_t* nameOfTopic;
	axis2_char_t* about;
	axis2_char_t** messages;
	int id;
	int i;
	adb_subscriber_t* subscriber;
	adb_subscriber_t* reply = adb_subscriber_create(env);

	if (SQLITE_OK == sqlite3_open("Subscribers.db", &db))
	{
		printf("Database opened\n");	
	}
	else
	{
		printf("Error opening database\n");
	}

//	query = "select t1.id, t1.topic, t1.about, t2.message from 'subscribers' as t1 inner join 'messages' as t2 on t1.topic = t2.topic";
	query1 = "select * from subscribers";

	sqlite3_prepare(db, query1, -1, &stmt1, 0);
	while(1)
	{
		printf("IN 1 CYCLE\n");
		rc1=sqlite3_step(stmt1);
		if (rc1 == SQLITE_ROW)
		{
			printf("IF 1\n");
			id = sqlite3_column_int( stmt1, 0 );
			nameOfTopic = sqlite3_column_text( stmt1, 1 );
			about = sqlite3_column_text( stmt1, 2 );
			printf("YES\n");
			query2 = "select t1.message from messages as t1 where t1.topic = ?";
			sqlite3_prepare(db, query2, -1, &stmt2, 0);
			sqlite3_bind_text(stmt2, 1, nameOfTopic, -1, SQLITE_STATIC);
			i = 0;
			while(1)
			{
				printf("IN 2 CYCLE\n");
				rc2=sqlite3_step(stmt2);
				if (rc2 == SQLITE_ROW)
				{
					messages[i] = sqlite3_column_text( stmt2, 1 );
					i++;
				}
				else
					break;
				printf("OUT 2 CYCLE\n");
			}

//			env = axutil_env_create_all("subscribers.log", AXIS2_LOG_LEVEL_TRACE);

			client_home = AXIS2_GETENV("AXIS2C_HOME");
			if (!client_home || !strcmp(client_home, ""))
			client_home = "../..";    
			printf("SETTING PARAMS\n");
			adb_subscriber_set_id(reply, env, id);
			adb_subscriber_set_nameOfTopic(reply, env, nameOfTopic);
			adb_subscriber_set_about(reply, env, about);
			adb_subscriber_set_messages(reply, env, messages);
			adb_subscriber_set_subscriber(reply, env, subscriber);
			printf("%d\n", id);
			printf("%s\n", nameOfTopic);
			printf("%s\n", about);
			printf("SETTING PARAMS SUCCESSFULLY\n");
			address = sqlite3_column_text( stmt1, 3 );
			stub = axis2_stub_create_Subscribers(env, client_home, address);
			printf("STUB CREATED\n");
			subscriber = axis2_stub_op_Subscribers_GetStructure(stub, env, adb_subscriberRequest_create_with_values(env, 0));

		}
		else
			break;

	}
printf("OUT 1 CYCLE\n");
//	sqlite3_finalize(stmt1);
//	sqlite3_finalize(stmt2);
	sqlite3_close(db);

printf("CLOSE DB\n");
	return reply;	
}
示例#22
0
int
main(
    int argc,
    char **argv)
{
    const axutil_env_t *env = NULL;
    const axis2_char_t *address = NULL;
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_options_t *options = NULL;
    const axis2_char_t *client_home = NULL;
    axis2_svc_client_t *svc_client = NULL;
    axiom_node_t *payload = NULL;
    axiom_node_t *ret_node = NULL;
    axis2_bool_t method_get = AXIS2_FALSE;
    axis2_bool_t method_head = AXIS2_FALSE;
    axis2_bool_t method_put = AXIS2_FALSE;
    axis2_bool_t method_delete = AXIS2_FALSE;

    /* Set up the environment */
    env = axutil_env_create_all("echo_rest.log", AXIS2_LOG_LEVEL_TRACE);

    /* Set end point reference of echo service */
    address = "http://localhost:9090/axis2/services/echo/echoString";
    if (argc > 1)
    {
        if (0 == strncmp(argv[1], "-mGET", 5))
        {
            method_get = AXIS2_TRUE;
        }
        else if (0 == strncmp(argv[1], "-mHEAD", 6))
        {
            method_head = AXIS2_TRUE;
        }
        else if (0 == strncmp(argv[1], "-mPUT", 5))
        {
            method_put = AXIS2_TRUE;
        }
        else if (0 == strncmp(argv[1], "-mDELETE",8 ))
        {
            method_delete = AXIS2_TRUE;
        }
        else if (0 == axutil_strcmp(argv[1], "-h"))
        {
            printf("Usage : %s [endpoint_url] \n", argv[0]);
            printf("\nNOTE: You can test for other HTTP methods by changing the");
            printf(" services.xml of the echo service\n and providing the correct REST HTTP method");
            printf(" and the location to be used for operation.\n");
            printf(" Also note that you have to restart the server after changing the services.xml.\n");
            printf(" use %s -mGET for HTTP GET\n", argv[0]);
            printf(" use %s -mHEAD for HTTP HEAD\n", argv[0]);
            printf(" use %s -mDELETE for HTTP DELETE\n", argv[0]);
            printf(" use %s -mPUT for HTTP PUT\n", argv[0]);
            printf(" use -h for help\n");
            return 0;
        }
        else
        {
            address = argv[1];
        }
    }

    if (argc > 2)
    {
        if (0 == strncmp(argv[2], "-mGET", 5))
        {
            method_get = AXIS2_TRUE;
        }
        else if (0 == strncmp(argv[2], "-mHEAD", 6))
        {
            method_head = AXIS2_TRUE;
        }
        else if (0 == strncmp(argv[2], "-mPUT", 5))
        {
            method_put = AXIS2_TRUE;
        }
        else if (0 == strncmp(argv[2], "-mDELETE",8 ))
        {
            method_delete = AXIS2_TRUE;
        }
        else
        {
            address = argv[2];
        }
    }

    printf("Using endpoint : %s\n", address);

    /* Create EPR with given address */
    endpoint_ref = axis2_endpoint_ref_create(env, address);

    /* Setup options */
    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);
    /* Enable REST at the client side */
    axis2_options_set_enable_rest(options, env, AXIS2_TRUE);

    if (AXIS2_TRUE == method_get)
    {
        axis2_options_set_http_method(options, env, AXIS2_HTTP_GET);
    }
    else if (AXIS2_TRUE == method_head)
    {
        axis2_options_set_http_method(options, env, AXIS2_HTTP_HEAD);
    }
    else if (AXIS2_TRUE == method_put)
    {
        axis2_options_set_http_method(options, env, AXIS2_HTTP_PUT);
    }
    else if (AXIS2_TRUE == method_delete)
    {
        axis2_options_set_http_method(options, env, AXIS2_HTTP_DELETE);
    }
    /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
     * using the axis2.xml file.
     * In this sample client_home points to the Axis2/C default deploy folder. The client_home can 
     * be different from this folder on your system. For example, you may have a different folder 
     * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the 
     * modules that the client uses
     */
    client_home = AXIS2_GETENV("WSFC_HOME");
    if (!client_home || !strcmp(client_home, ""))
        client_home = "../..";

    /* Create service client */
    svc_client = axis2_svc_client_create(env, client_home);
    if (!svc_client)
    {
        printf
            ("Error creating service client, Please check WSFC_HOME again\n");
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        AXIS2_ERROR_GET_MESSAGE(env->error));
        return -1;
    }

    /* Set service client options */
    axis2_svc_client_set_options(svc_client, env, options);

    /* Build the SOAP request message payload using OM API. */
    payload = build_om_payload_for_echo_svc(env);

    /* Send request */
    ret_node = axis2_svc_client_send_receive(svc_client, env, payload);

    if (ret_node && 
        axis2_svc_client_get_last_response_has_fault(svc_client, env))
    {
        axis2_char_t *om_str = NULL;
        om_str = axiom_node_to_string(ret_node, env);
        if (om_str)
        {
            printf("\nReceived OM : %s\n", om_str);
            AXIS2_FREE(env->allocator, om_str);
        }
        printf("\necho client invoke FAILED!\n");
    }
    else if (ret_node)
    {
        axis2_char_t *om_str = NULL;
        om_str = axiom_node_to_string(ret_node, env);
        if (om_str)
        {
            printf("\nReceived OM : %s\n", om_str);
            AXIS2_FREE(env->allocator, om_str);
        }
        printf("\necho client invoke SUCCESSFUL!\n");
    }
    else if (method_head &&
        axis2_svc_client_get_last_response_has_fault(svc_client, env))
    {
        /* HEAD request should probably be removed from this file,
         * and be relocated to transport unit tests.
         */
        printf("\necho client invoke FAILED!\n");
    }
    else if (method_head)
    {
        /* HEAD request should probably be removed from this file,
         * and be relocated to transport unit tests.
         */
        printf("\necho client invoke SUCCESSFUL!\n");
    }
    else
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        AXIS2_ERROR_GET_MESSAGE(env->error));
        printf("echo client invoke FAILED!\n");
    }

    if (svc_client)
    {
        axis2_svc_client_free(svc_client, env);
        svc_client = NULL;
    }

    if (env)
    {
        axutil_env_free((axutil_env_t *) env);
        env = NULL;
    }
    return 0;
}
示例#23
0
int
main(
    int argc,
    char **argv)
{
    axutil_env_t *env = NULL;
    axis2_char_t *client_home = NULL;

    axis2_char_t *endpoint_uri = NULL;

    axis2_stub_t *stub = NULL;

    /* variables use databinding */
    adb_echoStruct_t *echo_in = NULL;
    adb_echoStructResponse_t *echo_out = NULL;
    adb_SOAPStruct_t *struct_in = NULL;
    adb_SOAPStruct_t *struct_out = NULL;

    float float_val = 11;
    int int_val = 10;
    char *string_val = "hello struct";

    int ret_int_val = 0;
    float ret_float_val = 0;
    char *ret_string_val = "";

    endpoint_uri = "http://localhost:9090/axis2/services/interop_doc2";

    env =
        axutil_env_create_all("codegen_utest_blocking.log",
                              AXIS2_LOG_LEVEL_TRACE);

    /* Set up deploy folder. */
    client_home = AXIS2_GETENV("WSFC_HOME");
    if (!client_home)
        client_home = "../../../deploy";

    stub = axis2_stub_create_WSDLInteropTestDocLitService(env,
                                                          client_home,
                                                          endpoint_uri);

    /* create the struct */
    struct_in = adb_SOAPStruct_create(env);
    adb_SOAPStruct_set_varFloat(struct_in, env, float_val);
    adb_SOAPStruct_set_varInt(struct_in, env, int_val);
    adb_SOAPStruct_set_varString(struct_in, env, string_val);

    /* create the input params using databinding */
    echo_in = adb_echoStruct_create(env);
    adb_echoStruct_set_param0(echo_in, env, struct_in);

    /* invoke the web service method */
    echo_out = axis2_stub_op_WSDLInteropTestDocLitService_echoStruct(stub, env, echo_in);

    /* return the output params using databinding */
    struct_out = adb_echoStructResponse_get_return(echo_out, env);
    /*struct_out = adb_echostruct_get_param0( ret_val, env ); */

    ret_float_val = adb_SOAPStruct_get_varFloat(struct_out, env);
    ret_int_val = adb_SOAPStruct_get_varInt(struct_out, env);
    ret_string_val = adb_SOAPStruct_get_varString(struct_out, env);

    printf("returned values \n");
    printf(" float %f\n", ret_float_val);
    printf(" int %d \n", ret_int_val);
    printf(" string %s \n", ret_string_val);

    return 0;
}
示例#24
0
文件: util.c 项目: AdrianRys/wsf
axis2_status_t
wsclient_get_attachment (const axutil_env_t *env,
						 axiom_node_t *node,
						 axis2_char_t *base_dir,
						 int is_mtom_enabled)
{
	axiom_node_t *child_node = NULL;
	axiom_element_t *element;
	if (!node || !env)
		return AXIS2_FAILURE;

	if (axiom_node_get_node_type (node, env) == AXIOM_ELEMENT)
	{
		axis2_char_t *local_name;
		axiom_namespace_t *ns;
		axis2_char_t *ns_uri;
		element = (axiom_element_t *) axiom_node_get_data_element (node, env);
		local_name = axiom_element_get_localname (element, env);
		if (local_name)
		{
			if (!strcmp (local_name, "Include"))
			{
				ns = axiom_element_get_namespace(element, env, node);
				if (ns && (ns_uri = axiom_namespace_get_uri (ns, env))
					&& (!strcmp (ns_uri, "http://www.w3.org/2004/08/xop/include")))
				{
					axiom_node_t *text_node;
					axiom_text_t *text;
					axiom_data_handler_t *data_handler;
					axis2_char_t *write_file = NULL;
					axis2_char_t *pwd;
					axis2_char_t *relative;
					axutil_qname_t *attribute_qname;
					axiom_attribute_t *href = NULL;
					axis2_char_t *cid_value;

                    #if defined(WIN32)
						char path[256];
						GetCurrentDirectory(256, path);
						pwd = path;
                    #else
                        pwd = AXIS2_GETENV ("PWD");
                    #endif

					relative = wsclient_get_relative_path (env, pwd, base_dir);

					attribute_qname = axutil_qname_create (env, "href", NULL, NULL);

					if (attribute_qname)
						href = axiom_element_get_attribute (element, env, attribute_qname);
					else 
						return AXIS2_FAILURE;

					if (href)
					{
						cid_value = axiom_attribute_get_value (href, env);
						cid_value = cid_value + 4;
					}
					else
						return AXIS2_FAILURE;

					axiom_attribute_set_value (href, env, relative);

					text_node = axiom_node_get_first_child (node, env);
					if (text_node && (axiom_node_get_node_type (text_node, env) == AXIOM_TEXT))
					{
						text = (axiom_text_t *) axiom_node_get_data_element (text_node, env);
						data_handler = axiom_text_get_data_handler(text, env);
                        if (data_handler && text)
                        {
							if (base_dir)
							{
								int len = 0;
								len = strlen (base_dir);
								if (base_dir [len - 1] != '/')
									strcat (base_dir, "/");
								if (cid_value)
									write_file = strcat (base_dir, cid_value);
								else 
									return AXIS2_FAILURE;
							}

							if (write_file)
								axiom_data_handler_set_file_name(data_handler, 
																 env, 
																 write_file);
                            axiom_data_handler_write_to(data_handler, env);
						}
					}
				}
			}
		}

		child_node = axiom_node_get_first_element (node, env);
		while (child_node)
		{
			wsclient_get_attachment (env, 
									 child_node, 
									 base_dir,
									 is_mtom_enabled); 
			child_node = axiom_node_get_next_sibling (child_node, env);
		}
	}
	else
		return AXIS2_FAILURE;
	return AXIS2_SUCCESS;
}
示例#25
0
int main(int argc, char** argv)
{
    const axutil_env_t *env = NULL;
    const axis2_char_t *address = NULL;
    const axis2_char_t *client_home = NULL;
    axis2_char_t *file_name = NULL;
    axis2_char_t *policy_file = NULL;
    axis2_endpoint_ref_t* endpoint_ref = NULL;
    axis2_options_t *options = NULL;
    axis2_svc_client_t* svc_client = NULL;
    axiom_node_t *payload = NULL;
    axiom_node_t *ret_node = NULL;
    axis2_status_t status = AXIS2_FAILURE;
    neethi_policy_t *policy = NULL;
    rampart_config_t* client_config = NULL;
    axutil_property_t *property = NULL;
    rampart_saml_token_t *saml = NULL;
    axiom_node_t *assertion = NULL;
	/* Set up the environment */
    env = axutil_env_create_all("echo.log", AXIS2_LOG_LEVEL_TRACE);

    /* Set end-point-reference of echo service */
    address = "http://localhost:9090/axis2/services/echo";
    if (argc > 2)
    {
        address = argv[1];
        client_home = argv[2];
        printf("Using endpoint : %s\n", address);
        printf("Using client_home : %s\n", client_home);
    }

    if ((axutil_strcmp(argv[1], "-h") == 0) || (axutil_strcmp(argv[1], "--help") == 0))
    {
        printf("Usage : %s [endpoint_url] [client_home]\n", argv[0]);
        printf("use -h for help\n");
        return 0;
    }

    /* Create end-point-reference with given address */
    endpoint_ref = axis2_endpoint_ref_create(env, address);

    /* Setup options */
    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);
    axis2_options_set_action(options, env,
            "http://example.com/ws/2004/09/policy/Test/EchoRequest");
    /*axis2_options_set_action(options, env,
            "urn:echo");*/


    /*If the client home is not specified, use the AXIS2C_HOME*/
    if (!client_home)
    {
        client_home = AXIS2_GETENV("AXIS2C_HOME");
        printf("\nNo client_home specified. Using default %s", client_home);
    }

    /* Create service client */
    printf("client_home= %s", client_home);
    svc_client = axis2_svc_client_create(env, client_home);
    if (!svc_client)
    {
        printf("Error creating service client\n");
        return -1;
    }

    client_config = rampart_config_create(env);
    if(!client_config)
    {
        printf("Cannot create rampart config\n");
        return 0;
    }
    assertion = create_saml_assertion(env);
    saml = rampart_saml_token_create(env, assertion, RAMPART_ST_CONFIR_TYPE_SENDER_VOUCHES);
	rampart_saml_token_set_token_type(saml, env, RAMPART_ST_TYPE_SIGNED_SUPPORTING_TOKEN);
    rampart_config_add_saml_token(client_config, env, saml);

    property = axutil_property_create_with_args(env, AXIS2_SCOPE_REQUEST ,
        AXIS2_TRUE, (void *)rampart_config_free, client_config);
    axis2_options_set_property(options, env, RAMPART_CLIENT_CONFIGURATION, property);

    /* Set service client options */
    axis2_svc_client_set_options(svc_client, env, options);

    /*We need to specify the client's policy file location*/
    if(client_home)
    {
        file_name = axutil_stracat(env, client_home, AXIS2_PATH_SEP_STR);
        policy_file = axutil_stracat(env, file_name, "policy.xml" );
        AXIS2_FREE(env->allocator, file_name);
        file_name = NULL;        
    }else{
        printf("Client Home not Specified\n");
        printf("echo client invoke FAILED!\n");
        return 0;
    }
    /*Create the policy, from file*/   
    policy = neethi_util_create_policy_from_file(env, policy_file);
    if(!policy)
    {
        printf("\nPolicy creation failed from the file. %s\n", policy_file);
    }
	if(policy_file){
        AXIS2_FREE(env->allocator, policy_file);
        policy_file = NULL;
    }

    status = axis2_svc_client_set_policy(svc_client, env, policy);

    if(status == AXIS2_FAILURE)
    {
        printf("Policy setting failed\n");
    }
    
    /* Build the SOAP request message payload using OM API.*/
    payload = build_om_payload_for_echo_svc(env);
    
    /*If not engaged in the client's axis2.xml, uncomment this line*/
    axis2_svc_client_engage_module(svc_client, env, "rampart");
    
    /* Send request */
    ret_node = axis2_svc_client_send_receive(svc_client, env, payload);


    if (axis2_svc_client_get_last_response_has_fault(svc_client, env))
    {
        axiom_soap_envelope_t *soap_envelope = NULL;
        axiom_soap_body_t *soap_body = NULL;
        axiom_soap_fault_t *soap_fault = NULL;

        printf ("\nResponse has a SOAP fault\n");
        soap_envelope =
            axis2_svc_client_get_last_response_soap_envelope(svc_client, env);
        if (soap_envelope)
            soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
        if (soap_body)
            soap_fault = axiom_soap_body_get_fault(soap_body, env);
        if (soap_fault)
        {
            printf("\nReturned SOAP fault: %s\n",
            axiom_node_to_string(axiom_soap_fault_get_base_node(soap_fault,env),
                env));
        }
            printf("echo client invoke FAILED!\n");
            return -1;
    }
    
    if (ret_node)
    {
        axis2_char_t *om_str = NULL;
        om_str = axiom_node_to_string(ret_node, env);
        if (om_str)
        {
            printf("\nReceived OM : %s\n", om_str);
        }
        printf("\necho client invoke SUCCESSFUL!\n");
        AXIS2_FREE(env->allocator, om_str);
        ret_node = NULL;
    }
    else
    {
        printf("echo client invoke FAILED!\n");
        return -1;
    }

    if (svc_client)
    {
        axis2_svc_client_free(svc_client, env);
        svc_client = NULL;
    }
    if (env)
    {
        axutil_env_free((axutil_env_t *) env);
        env = NULL;
    }
    
    return 0;
}
示例#26
0
int
main(
    int argc,
    char **argv)
{
    axis2_stub_t *stub = NULL;
    axiom_node_t *node = NULL;
    axis2_status_t status = AXIS2_FAILURE;
    const axutil_env_t *env = NULL;
    const axis2_char_t *address = NULL;
    const axis2_char_t *client_home = NULL;
    axiom_node_t *ret_node = NULL;

    const axis2_char_t *operation = "get_version";
    const axis2_char_t *param1 = "40";
    const axis2_char_t *param2 = "8";

    env = axutil_env_create_all("version_blocking.log", AXIS2_LOG_LEVEL_TRACE);

    client_home = AXIS2_GETENV("AXIS2C_HOME");
    if (!client_home || !strcmp(client_home, ""))
        client_home = "../..";

    address = "http://localhost:9090/axis2/services/version";
    if (argc > 1)
        operation = argv[1];
    if (axutil_strcmp(operation, "-h") == 0)
    {
        printf("Usage : %s [operation] [param1] [param2] [endpoint_url]\n",
               argv[0]);
        printf("use -h for help\n");
        printf("default operation get_version\n");
        printf("default param1 %s\n", param1);
        printf("default param2 %s\n", param2);
        printf("default endpoint_url %s\n", address);
        printf
            ("NOTE: command line arguments must appear in given order, with trailing ones being optional\n");
        return 0;
    }
    if (argc > 2)
        param1 = argv[2];
    if (argc > 3)
        param2 = argv[3];
    if (argc > 4)
        address = argv[4];

    printf("Using endpoint : %s\n", address);
    printf("\nInvoking operation %s\n", operation);

    node = build_om_programatically(env);
    stub =
        axis2_version_stub_create_with_endpoint_uri_and_client_home(env, address,
                                                                 client_home);

    /* create node and invoke version */
    if (stub)
    {
        ret_node = axis2_version_stub_get_version(stub, env, node);
    }

    if (ret_node)
    {
        if (axiom_node_get_node_type(ret_node, env) == AXIOM_ELEMENT)
        {
            axis2_char_t *result = NULL;
            axiom_element_t *result_ele =
                (axiom_element_t *) axiom_node_get_data_element(ret_node, env);

            result = axiom_element_get_text(result_ele, env, ret_node);
            printf("\nResult = %s\n", result);
        }
        else
        {
            axiom_xml_writer_t *writer = NULL;
            axiom_output_t *om_output = NULL;
            axis2_char_t *buffer = NULL;
            writer =
                axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0,
                                                   AXIS2_XML_PARSER_TYPE_BUFFER);
            om_output = axiom_output_create(env, writer);

            axiom_node_serialize(ret_node, env, om_output);
            buffer = (axis2_char_t *) axiom_xml_writer_get_xml(writer, env);
            printf("\nReceived invalid OM as result : %s\n", buffer);
            if (buffer)
            {
                AXIS2_FREE(env->allocator, buffer);
                buffer = NULL;
            }
            if (om_output)
            {
                axiom_output_free(om_output, env);
                om_output = NULL;
            }
            axiom_xml_writer_free(writer, env);
        }
    }
    else
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        AXIS2_ERROR_GET_MESSAGE(env->error));
        printf("version stub invoke FAILED!\n");
    }

    if (stub)
    {
        axis2_stub_free(stub, env);
    }

    if (env)
    {
        axutil_env_free((axutil_env_t *) env);
        env = NULL;
    }

    return status;
}
示例#27
0
//!
//! Creates and initialize an NC stub entry
//!
//! @param[in] endpoint_uri the endpoint URI string
//! @param[in] logfile the log file name string
//! @param[in] homedir the home directory path string
//!
//! @return a pointer to the newly created NC stub structure
//!
ncStub *ncStubCreate(char *endpoint_uri, char *logfile, char *homedir)
{
    char *uri = NULL;
    char *p = NULL;
    char *node_name = NULL;
    axutil_env_t *env = NULL;
    axis2_char_t *client_home = NULL;
    axis2_stub_t *stub = NULL;
    ncStub *st = NULL;

    if (logfile) {
        env = axutil_env_create_all(logfile, AXIS2_LOG_LEVEL_TRACE);
    } else {
        env = axutil_env_create_all(NULL, 0);
    }

    if (homedir) {
        client_home = (axis2_char_t *) homedir;
    } else {
        client_home = AXIS2_GETENV("AXIS2C_HOME");
    }

    if (client_home == NULL) {
        LOGERROR("fakeNC: ERROR: cannot get AXIS2C_HOME");
        return NULL;
    }

    if (endpoint_uri == NULL) {
        LOGERROR("fakeNC: ERROR: empty endpoint_url");
        return NULL;
    }

    uri = endpoint_uri;

    // extract node name from the endpoint
    p = strstr(uri, "://");            // find "http[s]://..."
    if (p == NULL) {
        LOGERROR("fakeNC: ncStubCreate received invalid URI %s\n", uri);
        return NULL;
    }

    node_name = strdup(p + 3);         // copy without the protocol prefix
    if (node_name == NULL) {
        LOGERROR("fakeNC: ncStubCreate is out of memory\n");
        return NULL;
    }

    if ((p = strchr(node_name, ':')) != NULL)
        *p = '\0';                     // cut off the port

    if ((p = strchr(node_name, '/')) != NULL)
        *p = '\0';                     // if there is no port

    LOGDEBUG("fakeNC: DEBUG: requested URI %s\n", uri);

    // see if we should redirect to a local broker
    if (strstr(uri, "EucalyptusBroker")) {
        uri = "http://localhost:8773/services/EucalyptusBroker";
        LOGDEBUG("fakeNC: DEBUG: redirecting request to %s\n", uri);
    }
    //! @todo what if endpoint_uri, home, or env are NULL?
    stub = axis2_stub_create_EucalyptusNC(env, client_home, (axis2_char_t *) uri);

    if (stub && (st = EUCA_ZALLOC(1, sizeof(ncStub)))) {
        st->env = env;
        st->client_home = strdup((char *)client_home);
        st->endpoint_uri = (axis2_char_t *) strdup(endpoint_uri);
        st->node_name = (axis2_char_t *) strdup(node_name);
        st->stub = stub;
        if (st->client_home == NULL || st->endpoint_uri == NULL) {
            LOGWARN("fakeNC: WARNING: out of memory");
        }
    } else {
        LOGWARN("fakeNC: WARNING: out of memory");
    }

    EUCA_FREE(node_name);
    return (st);
}
示例#28
0
int main(int argc, char** argv)
{
    const axutil_env_t *env = NULL;
    const axis2_char_t *address = NULL;
    axis2_endpoint_ref_t* endpoint_ref = NULL;
    axis2_endpoint_ref_t* reply_to = NULL;
    axis2_options_t *options = NULL;
    const axis2_char_t *client_home = NULL;
    axis2_svc_client_t* svc_client = NULL;
    axiom_node_t *payload = NULL;
    axis2_callback_t *callback = NULL;
    axis2_callback_t *callback2 = NULL;
    axis2_callback_t *callback3 = NULL;
    axutil_property_t *property = NULL;
    axis2_char_t *offered_seq_id = NULL;
    axis2_bool_t offer = AXIS2_TRUE;
    neethi_policy_t *policy = NULL;
    axis2_status_t status = AXIS2_FAILURE;
   
    /* Set up the environment */
    env = axutil_env_create_all("rm_echo_1_1_amqp.log", AXIS2_LOG_LEVEL_TRACE);

    /* Set end point reference of echo service */
    address = "amqp://127.0.0.1:5672/axis2/services/RM11SampleService";
    if (argc > 1)
    {
        if (axutil_strcmp(argv[1], "-h") == 0)
        {
            printf("Usage : %s [endpoint_url]\n", argv[0]);
            printf("use -h for help\n");
            return 0;
        }
        else
        {
            address = argv[1];
        }
    }
    printf ("Using endpoint : %s\n", address);
    
    /* Create EPR with given address */
    endpoint_ref = axis2_endpoint_ref_create(env, address);

    /* Setup options */
    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);
    axis2_options_set_use_separate_listener(options, env, AXIS2_TRUE);
    
    /* Seperate listner needs addressing, hence addressing stuff in options */
    /*axis2_options_set_action(options, env,
        "http://127.0.0.1:8080/axis2/services/RM11SampleService/anonOutInOp");*/
    axis2_options_set_action(options, env, "urn:wsrm:EchoString");
    reply_to = axis2_endpoint_ref_create(env, 
            "amqp://localhost:5672/axis2/services/__ANONYMOUS_SERVICE__");
    axis2_options_set_reply_to(options, env, reply_to);

	axis2_options_set_transport_in_protocol(options, env, AXIS2_TRANSPORT_ENUM_AMQP);

    /* Set up deploy folder. It is from the deploy folder, the configuration is 
     * picked up using the axis2.xml file.
     * In this sample client_home points to the Axis2/C default deploy folder. 
     * The client_home can be different from this folder on your system. For 
     * example, you may have a different folder (say, my_client_folder) with its 
     * own axis2.xml file. my_client_folder/modules will have the modules that 
     * the client uses
     */
    client_home = AXIS2_GETENV("AXIS2C_HOME");
    if (!client_home)
    {
        client_home = "../../..";
    }

    /* Create service client */
    svc_client = axis2_svc_client_create(env, client_home);
    if (!svc_client)
    {
        printf("Error creating service client\n");
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code: %d :: %s", 
                env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error));
        return -1;
    }

    /*Create the policy, from file*/
    policy = neethi_util_create_policy_from_file(env, "../policy/rm11-policy.xml");
    if(!policy)
    {
        printf("\nPolicy creation failed from the file");
        return 0;
    }

    status = axis2_svc_client_set_policy(svc_client, env, policy);

    if(status == AXIS2_FAILURE)
    {
        printf("Policy setting failed\n");
    }


    /* Set service client options */
    axis2_svc_client_set_options(svc_client, env, options);    
    
    axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);  
    axis2_svc_client_engage_module(svc_client, env, "sandesha2");

    /* Offer sequence */
    if(offer)
    {
        offered_seq_id = axutil_uuid_gen(env);
        property = axutil_property_create(env);
        if(property)
        {
            axutil_property_set_value(property, env, axutil_strdup(env, offered_seq_id));
            axis2_options_set_property(options, env, SANDESHA2_CLIENT_OFFERED_SEQ_ID, property);
        }
    }

    /* RM Version 1.1 */
    property = axutil_property_create_with_args(env, 3, 0, 0, SANDESHA2_SPEC_VERSION_1_1);
    if(property)
    {
        axis2_options_set_property(options, env, SANDESHA2_CLIENT_RM_SPEC_VERSION, property);
    }
    
    payload = build_om_payload_for_echo_svc(env, "echo1");
    callback = axis2_callback_create(env);
    axis2_callback_set_on_complete(callback, rm_echo_callback_on_complete);
    axis2_callback_set_on_error(callback, rm_echo_callback_on_error);
    axis2_svc_client_send_receive_non_blocking(svc_client, env, payload, callback);
    wait_on_callback(env, callback);

    payload = build_om_payload_for_echo_svc(env, "echo2");
    callback2 = axis2_callback_create(env);
    axis2_callback_set_on_complete(callback2, rm_echo_callback_on_complete);
    axis2_callback_set_on_error(callback2, rm_echo_callback_on_error);
    axis2_svc_client_send_receive_non_blocking(svc_client, env, payload, callback2);
    wait_on_callback(env, callback2);

    AXIS2_SLEEP(SANDESHA2_MAX_COUNT); 
    callback3 = axis2_callback_create(env);
    axis2_callback_set_on_complete(callback3, rm_echo_callback_on_complete);
    axis2_callback_set_on_error(callback3, rm_echo_callback_on_error);
    sandesha2_client_terminate_seq_with_svc_client(env, svc_client, callback3);

    AXIS2_SLEEP(SANDESHA2_MAX_COUNT);

    if (svc_client)
    {
        axis2_svc_client_free(svc_client, env);
        svc_client = NULL;
    }
    
    return 0;
}
示例#29
0
int
main(
    int argc,
    char **argv)
{
    const axutil_env_t *env = NULL;
    const axis2_char_t *address = NULL;
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_options_t *options = NULL;
    const axis2_char_t *client_home = NULL;
    axis2_svc_client_t *svc_client = NULL;
    axiom_node_t *payload = NULL;
    axiom_node_t *ret_node = NULL;

    const axis2_char_t *google_key = NULL;
    const axis2_char_t *word_to_spell = NULL;
    const axis2_char_t *operation = NULL;

    operation = "doSpellingSuggestion";
    google_key = "00000000000000000000000000000000";
    word_to_spell = "salvasion";

    /* Set up the environment */
    env = axutil_env_create_all("google_client.log", AXIS2_LOG_LEVEL_TRACE);

    /* Set end point reference of google service */
    address = "http://api.google.com/search/beta2";

    if ((argc > 1) && (axutil_strcmp("-h", argv[1]) == 0))
    {
        printf("\nUsage : %s [google_key] [word_to_spell] \n", argv[0]);
        printf
            ("\tgoogle_key Your Google license key. Default value won't work. You must use your key here.\n");
        printf
            ("\tword_to_spell Word to be spelled by Google service. Default is %s\n",
             word_to_spell);
        printf
            ("NOTE: command line arguments must appear in given order, with trailing ones being optional\n");
        printf("\tUse -h for help\n");
        return 0;
    }

    if (argc > 1)
        google_key = argv[1];
    if (argc > 2)
        word_to_spell = argv[2];
    if (argc > 3)
        address = argv[3];

    printf("Using endpoint : %s\n", address);
    printf("\nInvoking operation %s with params %s and %s\n", operation,
           google_key, word_to_spell);

    /* Create EPR with given address */
    endpoint_ref = axis2_endpoint_ref_create(env, address);

    /* Setup options */
    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);
    axis2_options_set_soap_version(options, env, AXIOM_SOAP11);

    /* Set up deploy folder. */
    client_home = AXIS2_GETENV("WSFC_HOME");
    if (!client_home || !strcmp(client_home, ""))
        client_home = "../..";

    /* Create service client */
    svc_client = axis2_svc_client_create(env, client_home);
    if (!svc_client)
    {
        printf
            ("Error creating service client, Please check WSFC_HOME again\n");
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        AXIS2_ERROR_GET_MESSAGE(env->error));
        return -1;
    }

    /* Set service client options */
    axis2_svc_client_set_options(svc_client, env, options);

    /* Build the SOAP request message payload using OM API. */
    payload =
        build_soap_body_content(env, operation, google_key, word_to_spell);

    /* Send request */
    ret_node = axis2_svc_client_send_receive(svc_client, env, payload);

    if (axis2_svc_client_get_last_response_has_fault(svc_client, env))
    {
        axiom_soap_envelope_t *soap_envelope = NULL;
        axiom_soap_body_t *soap_body = NULL;
        axiom_soap_fault_t *soap_fault = NULL;
        axis2_char_t *fault_string = NULL;

        printf("\nResponse has a SOAP fault\n");
        soap_envelope =
            axis2_svc_client_get_last_response_soap_envelope(svc_client, env);
        if (soap_envelope)
        {
            soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
        }

        if (soap_body)
        {
            soap_fault = axiom_soap_body_get_fault(soap_body, env);
        }

        if (soap_fault)
        {
            fault_string = axiom_node_to_string(axiom_soap_fault_get_base_node
                                                (soap_fault, env), env);
            printf("\nReturned SOAP fault: %s\n", fault_string);
            AXIS2_FREE (env->allocator, fault_string);
        }

        if (svc_client)
        {
            axis2_svc_client_free(svc_client, env);
            svc_client = NULL;
        }

        if (env)
        {
            axutil_env_free((axutil_env_t *) env);
            env = NULL;
        }

        return -1;
    }

    if (ret_node)
    {
        if (axiom_node_get_node_type(ret_node, env) == AXIOM_ELEMENT)
        {
            axis2_char_t *result = NULL;
            axiom_element_t *result_ele = NULL;
            axiom_node_t *ret_node1 = NULL;

            result_ele =
                (axiom_element_t *) axiom_node_get_data_element(ret_node, env);
            if (axutil_strcmp
                (axiom_element_get_localname(result_ele, env),
                 "doSpellingSuggestionResponse") != 0)
            {
                print_invalid_om(env, ret_node);
                return AXIS2_FAILURE;
            }

            ret_node1 = axiom_node_get_first_element(ret_node, env);    /*return */
            if (!ret_node1)
            {
                print_invalid_om(env, ret_node);
                return AXIS2_FAILURE;
            }
            result_ele =
                (axiom_element_t *) axiom_node_get_data_element(ret_node1, env);
            result = axiom_element_get_text(result_ele, env, ret_node1);
            printf("\nResult = %s\n", result);
        }
        else
        {
            print_invalid_om(env, ret_node);
            return AXIS2_FAILURE;
        }
    }
    else
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Stub invoke FAILED: Error code:" " %d :: %s",
                        env->error->error_number,
                        AXIS2_ERROR_GET_MESSAGE(env->error));
        printf("Google client invoke FAILED!\n");
    }

    if (svc_client)
    {
        axis2_svc_client_free(svc_client, env);
        svc_client = NULL;
    }

    if (env)
    {
        axutil_env_free((axutil_env_t *) env);
        env = NULL;
    }

    return 0;
}
示例#30
0
int
main (int argc, char **argv)
{
    const axutil_env_t* env = NULL;
    const axis2_char_t* address = NULL;
    axis2_endpoint_ref_t* endpoint_ref = NULL;
    axis2_options_t* options = NULL;
    const axis2_char_t* client_home = NULL;
    axis2_svc_client_t* svc_client = NULL;
    axiom_node_t* payload = NULL;
    axiom_node_t* ret_node = NULL;

    /* Set up the environment */
    env = axutil_env_create_all ("echo_blocking_amqp.log", AXIS2_LOG_LEVEL_TRACE);

    /* Set end point reference of echo service */
    address = "amqp://localhost:5672/axis2/services/echo";
    if (argc > 1)
        address = argv[1];

    if (axutil_strcmp (address, "-h") == 0)
    {
        printf ("Usage : %s [endpoint_url]\n", argv[0]);
        printf ("use -h for help\n");

        return 0;
    }

    printf ("Using endpoint : %s\n", address);

    /* Create EPR with given address */
    endpoint_ref = axis2_endpoint_ref_create (env, address);

    /* Setup options */
    options = axis2_options_create (env);
    axis2_options_set_to (options, env, endpoint_ref);

    /* Set up deploy folder */
    client_home = AXIS2_GETENV ("AXIS2C_HOME");
    if (!client_home || !strcmp (client_home, ""))
        client_home = "../..";

    /* Create service client */
    svc_client = axis2_svc_client_create (env, client_home);
    if (!svc_client)
    {
        printf ("Error creating service client, Please check AXIS2C_HOME again\n");
        AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
                         "Stub invoke FAILED: Error code:" " %d :: %s",
                         env->error->error_number,
                         AXIS2_ERROR_GET_MESSAGE (env->error));
        return -1;
    }

    /* Set service client options */
    axis2_svc_client_set_options (svc_client, env, options);

    /* Build the SOAP request message payload using OM API. */
    payload = build_om_payload_for_echo_svc (env);

    /* Send request and get response */
    ret_node = axis2_svc_client_send_receive (svc_client, env, payload);

    if (ret_node)
    {
        axis2_char_t *om_str = NULL;
        om_str = axiom_node_to_string (ret_node, env);
        if (om_str)
        {
            printf ("\nReceived OM : %s\n", om_str);
            AXIS2_FREE (env->allocator, om_str);
        }

        printf ("\necho client invoke SUCCESSFUL!\n");
    }
    else
    {
        AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
                         "Stub invoke FAILED: Error code:" " %d :: %s",
                         env->error->error_number,
                         AXIS2_ERROR_GET_MESSAGE (env->error));

        printf ("echo client invoke FAILED!\n");
    }

    if (svc_client)
    {
        axis2_svc_client_free (svc_client, env);
        svc_client = NULL;
    }

    if (env)
    {
        axutil_env_free ((axutil_env_t*)env);
        env = NULL;
    }

    return 0;
}