_endpoint_ref_t* endpoint_ref = NULL; 17 axis2_options_t *options = NULL; 18 const axis2_char_t *client_home = NULL; 19 axis2_svc_client_t* svc_client = NULL; 20 axiom_node_t *payload = NULL; 21 axiom_node_t *ret_node = NULL; 22 23 env = axutil_env_create_all("hello_client.log", AXIS2_LOG_LEVEL_TRACE); 24 options = axis2_options_create(env); 25 address = "http://localhost:9090/axis2/services/hello"; 26 27 if (argc > 1) 28 address = argv[1]; 29 30 if (axutil_strcmp(address, "-h") == 0) 31 { 32 printf("Usage : %s [endpoint_url] ", argv[0]); 33 printf("use -h for help "); 34 return 0; 35 } 36 37 printf("Using endpoint : %s ", address); 38 endpoint_ref = axis2_endpoint_ref_create(env, address); 39 axis2_options_set_to(options, env, endpoint_ref); 40 axis2_options_set_action(options, env, "http://ws.apache.org/axis2/c/samples/hello"); 41 42 client_home = "E:\mengli\axis2c-bin-1.6.0-win32";//AXIS2_GETENV("AXIS2C_HOME"); 43 if (!client_home && !strcmp(client_home, "")) 44 client_home = "../.."; 45 46 svc_client = axis2_svc_client_create(env, client_home); 47 if (!svc_client) 48 { 49 printf("Error creating service client "); 50 AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code:" 51 " %d :: %s", env->error->error_number, 52 AXIS2_ERROR_GET_MESSAGE(env->error)); 53 return -1; 54 } 55 56 axis2_svc_client_set_options(svc_client, env, options); 57 payload = build_om_request(env); 58 ret_node = axis2_svc_client_send_receive(svc_client, env, payload); 59 60 if (ret_node) 61 { 62 const axis2_char_t *greeting = process_om_response(env, ret_node); 63 if (greeting) 64 printf(" Received greeting: "%s" from service ", greeting); 65 66 axiom_node_free_tree(ret_node, env); 67 ret_node = NULL; 68 } 69 else 70 { 71 AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code:" 72 " %d :: %s", env->error->error_number, 73 AXIS2_ERROR_GET_MESSAGE(env->error)); 74 printf("hello client invoke FAILED! "); 75 } 76 77 if (svc_client) 78 { 79 axis2_svc_client_free(svc_client, env); 80 svc_client = NULL; 81 } 82 83 if (env) 84 { 85 axutil_env_free((axutil_env_t *) env); 86 env = NULL; 87 } 88 89 return 0; 90 91 } 92 93 axiom_node_t * 94 build_om_request(const axutil_env_t *env) 95 { 96 axiom_node_t* greet_om_node = NULL; 97 axiom_element_t * greet_om_ele = NULL; 98 99 greet_om_ele = axiom_element_create(env, NULL, "greet", NULL, &greet_om_node); 100 axiom_element_set_text(greet_om_ele, env, "Hello Server!", greet_om_node); 101 102 return greet_om_node; 103 } 104 105 106 107 const axis2_char_t * 108 process_om_response(const axutil_env_t *env, 109 axiom_node_t *node) 110 { 111 axiom_node_t *service_greeting_node = NULL; 112 axiom_node_t *return_node = NULL; 113 114 if (node) 115 { 116 service_greeting_node = axiom_node_get_first_child(node, env); 117 118 if (service_greeting_node && 119 |