char *test_endpoint_serialize() { axiom_namespace_t *ns = NULL; axiom_node_t *subs_node = NULL; axiom_element_t *subs_elem = NULL; axiom_node_t *endpoint_node = NULL; axiom_element_t *endpoint_elem = NULL; axiom_node_t *addr_node = NULL; axiom_element_t *addr_elem = NULL; axiom_attribute_t *url_attr = NULL; char *content = NULL; const axutil_env_t *env = NULL; axis2_char_t *nsurl = "http://ws.apache.org/ns/synapse"; axis2_char_t *ns_prefix = "syn"; axis2_char_t *notifyto = "http://localhost:9000/services/SimpleStockQuoteService"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); /* Format of the message is as * <subscription><syn:endpoint xmlns:syn="http://ws.apache.org/ns/synapse"><syn:address uri= * "http://localhost:9000/services/SimpleStockQuoteService" /></syn:endpoint></subscription> */ printf("\ncontent1:<subscription><syn:endpoint xmlns:syn=\"http://ws.apache.org/ns/synapse\"><syn:address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" /></syn:endpoint></subscription>"); ns = axiom_namespace_create (env, nsurl, ns_prefix); subs_elem = axiom_element_create(env, NULL, "subscription", NULL, &subs_node); endpoint_elem = axiom_element_create(env, subs_node, "endpoint", ns, &endpoint_node); addr_elem = axiom_element_create(env, endpoint_node, "address", ns, &addr_node); url_attr = axiom_attribute_create(env, "url", notifyto, NULL); axiom_element_add_attribute(addr_elem, env, url_attr, addr_node); content = (char *) axiom_node_to_string(subs_node, env); printf("\n\ncontent2:%s\n\n", content); return content; }
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; }
static void topic_index_init() { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; remote_registry_resource_t *res = NULL; axis2_char_t *id = NULL; axis2_char_t *reg_url = "http://localhost:9762/registry"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); remote_registry = remote_registry_create(env, reg_url, "admin", "admin"); res = remote_registry_get(remote_registry, env, TOPIC_INDEX, NULL); if(!res) { res = remote_registry_resource_create(env); id = axutil_strcat(env, reg_url, TOPIC_INDEX, NULL); remote_registry_resource_set_properties(res, env, axutil_hash_make(env)); /*remote_registry_resource_set_author_name(res, env, "admin"); */ remote_registry_resource_set_description(res, env, ""); /*remote_registry_resource_set_last_modified_time(res, env, axutil_date_time_create(env));*/ remote_registry_put(remote_registry, env, TOPIC_INDEX, res); return; } }
/** * This method initializes the axis2 engine. All the required variables are set to * their initial values in this method. */ axis2_status_t AXIS2_CALL init_axis2() { /* * These are the varibles required to initialize axis. */ axis2_status_t status = FALSE; /* We need to init xml readers before we go into threaded env */ if (!is_inited) { axiom_xml_reader_init(); status = read_registery_init_data(); if (status == AXIS2_FAILURE) { return AXIS2_FAILURE; } axutil_error_init(); /* Initialize the environement */ axutil_env = axutil_env_create_all(log_file, log_level); if (!axutil_env) { return AXIS2_FAILURE; } axis2_worker = axis2_iis_worker_create(axutil_env, repo_path); if (!axis2_worker) { return AXIS2_FAILURE; } is_inited = AXIS2_TRUE; return AXIS2_SUCCESS; } return AXIS2_FAILURE; }
static axutil_env_t* CreateAxis2Env(const axis2_char_t* szLogName) { static axis2_bool_t bEnableLog = !getenv("STAFF_AXIS2C_DISABLE_LOG") ? AXIS2_TRUE : AXIS2_FALSE; axutil_env_t* pEnv = axutil_env_create_all(szLogName, GetAxis2LogLevel()); axutil_env_enable_log(pEnv, bEnableLog); return pEnv; }
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; }
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; }
int main(void) { axutil_env_t *env = NULL; const axis2_char_t *filename = "atom_data.xml"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); reg_client_util_populate_resource(env, filename); return 0; }
int get_test_main() { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; axis2_char_t *path = "/test/10000.txt"; remote_registry_resource_t *res = NULL; remote_registry_resource_t *resource = NULL; axis2_status_t status; axis2_char_t *content = NULL; int i = 0; axutil_array_list_t *child_paths = NULL; int res_len = 0; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); remote_registry = remote_registry_create(env, "http://localhost:9762/registry", "admin", "admin"); // getting the resource resource = remote_registry_get(remote_registry, env, path, NULL); content = remote_registry_resource_get_content(resource, env); printf("%s\n", content); resource = remote_registry_get(remote_registry, env, path, NULL); content = remote_registry_resource_get_content(resource, env); printf("%s\n", content); path = "/test/"; resource = remote_registry_get(remote_registry, env, path, NULL); child_paths = remote_registry_resource_get_children(resource, env); for(i = 0; i < axutil_array_list_size(child_paths, env); i ++) { axis2_char_t *child_path = axutil_array_list_get(child_paths, env, i); printf("%d: %s\n", i, child_path); } resource = remote_registry_get(remote_registry, env, path, NULL); child_paths = remote_registry_resource_get_children(resource, env); for(i = 0; i < axutil_array_list_size(child_paths, env); i ++) { axis2_char_t *child_path = axutil_array_list_get(child_paths, env, i); printf("%d: %s\n", i, child_path); } return 0; }
void remove_subscriber(axis2_char_t *id) { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; remote_registry_resource_t *res = NULL; axis2_char_t *val; axis2_char_t *index_path = NULL; axis2_status_t status = AXIS2_FAILURE; axis2_char_t *path = NULL; axis2_char_t *reg_url = "http://localhost:9762/registry"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); remote_registry = remote_registry_create(env, reg_url, "admin", "admin"); res = remote_registry_get(remote_registry, env, TOPIC_INDEX, NULL); if(!res) { return; } printf("\n\nroot resource id:%s\n\n",remote_registry_resource_get_id(res, env)); val = remote_registry_resource_get_property(res, env, id); if(val) { path = axutil_strcat(env, val, "/", id, NULL); printf("path:%s\n", path); status = remote_registry_delete(remote_registry, env, path); } if(AXIS2_SUCCESS != status) { printf("\nSubscription deletion failed\n"); } res = remote_registry_get(remote_registry, env, TOPIC_INDEX, NULL); if(!res) { return; } printf("\n\nroot resource id:%s\n\n",remote_registry_resource_get_id(res, env)); /*remote_registry_resource_remove_property(res, env, id); remote_registry_resource_set_content(res, env, NULL); remote_registry_resource_set_content_len(res, env, 0); remote_registry_resource_set_parent_path(res, env, "/eventing/index"); index_path = axutil_strcat(env, TOPIC_INDEX, "/TopicIndex", NULL); remote_registry_put(remote_registry, env, index_path, res);*/ remote_registry_resource_free(res, env); }
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; }
axutil_env_t* ajSoapAxis2GetEnv(void) { axutil_env_t* env = NULL; AjPStr ax2log = NULL; ax2log = ajStrNew(); /* If debug mode is on, an extra log-file with .ax2log extension * is created in current working directory. Otherwise axis2 log * messages are not recorded */ ajFmtPrintS(&ax2log, "%s%S.ax2log", CURRENT_DIR, ajUtilGetProgram()); if(ajDebugOn()) env = axutil_env_create_all(ajStrGetPtr(ax2log), AXIS2_LOG_LEVEL_DEBUG); else env = axutil_env_create_all(_BLACKHOLE, AXIS2_LOG_LEVEL_ERROR); ajStrDel(&ax2log); return env; }
int main(int argc, char *argv[]) { axutil_env_t *env = NULL; axis2_char_t *filename = NULL; axis2_char_t *certfile = NULL; axis2_char_t *prvkeyfile = NULL; axis2_char_t *operation = NULL; openssl_pkey_t *prvkey = NULL; oxs_x509_cert_t *cert = NULL; if (argc > 2){ filename = argv[1]; operation = argv[2]; certfile = argv[3]; prvkeyfile = argv[4]; }else{ printf("Usage ./test inputfile operation[S/V] certificate prvkey \n"); return -1; } env = axutil_env_create_all("./oxs.log", AXIS2_LOG_LEVEL_TRACE); printf("--Testing started--------------------------------------------\n"); /*Load private key*/ prvkey = oxs_key_mgr_load_private_key_from_pem_file(env, prvkeyfile, ""); if(!prvkey){ printf("Cannot load private key"); } /*Load certificate*/ cert = oxs_key_mgr_load_x509_cert_from_pem_file(env, certfile); if(!cert){ printf("Cannot load certificate"); } if(0 == axutil_strcmp(operation, "S")){ sign(env, filename, prvkey, cert); }else{ verify(env, filename, prvkey, cert); } printf("\nDONE\n"); return 0; }
void get_all_subscribers() { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; remote_registry_resource_t *res = NULL; axutil_hash_t *properties = NULL; axis2_char_t *path = NULL; axis2_char_t *reg_url = "http://localhost:9762/registry"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); remote_registry = remote_registry_create(env, reg_url, "admin", "admin"); res = remote_registry_get(remote_registry, env, TOPIC_INDEX, NULL); if(!res) { return; } properties = remote_registry_resource_get_properties(res, env); if(properties) { axutil_hash_index_t *hi; void *val; void *key; for (hi = axutil_hash_first(properties, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, (const void**)&key, NULL, &val); path = axutil_strcat(env, val, "/", key, NULL); res = remote_registry_get(remote_registry, env, path, NULL); if(res) { if(res) { printf("\n\nresource id:%s\n\n",remote_registry_resource_get_id(res, env)); } } remove_subscriber((axis2_char_t *) key); } } remote_registry_resource_free(res, env); }
void get_all_subscribers_for_topic(axis2_char_t *topic) { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; remote_registry_resource_t *res = NULL; axutil_hash_t *properties = NULL; remote_registry_resource_t *topic_resource = NULL; axis2_char_t *path = NULL; axis2_char_t *reg_url = "http://localhost:9762/registry"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); remote_registry = remote_registry_create(env, reg_url, "admin", "admin"); topic_resource = remote_registry_get(remote_registry, env, topic, NULL); if(topic_resource) { axutil_array_list_t *child_entries = NULL; int i = 0; child_entries = remote_registry_resource_get_entries(topic_resource, env); if(child_entries) { /* load the child entries recursively */ for(i = 0; i < axutil_array_list_size(child_entries, env); i ++) { remote_registry_resource_t *child_resource = NULL; child_resource = (remote_registry_resource_t*)axutil_array_list_get(child_entries, env, i); /* loading the resources */ /*remote_registry_load_content_for_resource(remote_registry, env, child_resource); */ if(child_resource) { printf("\n\nresource id:%s\n\n",remote_registry_resource_get_id(child_resource, 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; 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 comment_test_main() { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; axis2_char_t *path = "/"; axutil_array_list_t *comments = NULL; int res_len = 0; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); remote_registry = remote_registry_create(env, "http://localhost:9762/registry", "admin", "admin"); comments = remote_registry_get_comments(remote_registry, env, path); if(comments) { print_comments(env, comments); } printf("-----------------------------------------------------------------------\n"); printf("Return the resources from the cache\n"); printf("-----------------------------------------------------------------------\n"); comments = remote_registry_get_comments(remote_registry, env, path); if(comments) { print_comments(env, comments); } return 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; }
//! //! 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); }
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; }
int main() { int sock, bytes_recieved; char recv_data[10024]; struct hostent *host; struct sockaddr_in server_addr; const axis2_char_t *header = NULL; axis2_char_t *header_value = NULL; char *type3_header = NULL; char *type1_header = NULL; const char *user = "******", *domain = "mydomain", *password = "******", *workstation = "workstation"; axis2_status_t status = AXIS2_FAILURE; const axutil_env_t *env = NULL; env = axutil_env_create_all("mock_client.log", AXIS2_LOG_LEVEL_TRACE); host = gethostbyname(hostname); if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { perror("Socket"); exit(1); } server_addr.sin_family = AF_INET; server_addr.sin_port = htons(port); server_addr.sin_addr = *((struct in_addr *)host->h_addr); bzero(&(server_addr.sin_zero),8); /* Create a normal message */ char *init_send = axutil_strdup(env, "HEAD /myservice/Service1.asmx HTTP/1.1\n"\ "Host: 172.16.176.132:8080\n"\ "User-Agent: Axis2C/1.7.0\n\n"); if (connect(sock, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) == -1) { perror("Connect"); exit(1); } /* Send a normal message */ send(sock, init_send, strlen(init_send), 0); while(1) { bytes_recieved=recv(sock,recv_data,10024,0); recv_data[bytes_recieved] = '\0'; header = axutil_strstr(recv_data, "WWW-Authenticate: NTLM "); /* Process the challange */ if(header) { int i = 22; while(header[i] && isspace((unsigned char) header[i])) { i++; } if (header[i] != '\0') { int len = axutil_strlen(&header[i]); if (len == 0) { printf("invalid Negotiate token\n"); } else { header_value = axutil_strdup(env, &header[i]); } } if(header_value) { axis2_char_t *temp = strstr(header_value, "=="); temp = temp + 3; *temp = '\0'; header_value = axutil_strdup(env, header_value); } } if(!header_value) /* printf("unauth_header:\n%s\n", unauth_header); */ { axis2_char_t *encoded = NULL; int elen = 0; int flags = 0; axis2_ntlm_t *ntlm = NULL; ntlm = axis2_ntlm_create(env); status = axis2_ntlm_auth_create_type1_message(ntlm, env, &encoded, &elen, user, password, flags, domain); if(AXIS2_SUCCESS != status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "axis2_ntlm_auth_create_type1_message call failed"); printf("axis2_ntlm_auth_create_type1_message call failed\n"); return 1; } /* Ceate type 1(negotiation) header message from the recieved header */ type1_header = create_type1_header(env, encoded); /* Send netotiation message */ send(sock, type1_header,strlen(type1_header), 0); printf("sent:\n%s\n", type1_header); free(type1_header); continue; } if(header_value) { /*printf("header_value:\n***%s***\n", header_value);*/ int elen = 0; axis2_char_t *encoded = NULL; axis2_char_t *header_value = NULL; axis2_ntlm_t *ntlm = NULL; ntlm = axis2_ntlm_create(env); status = axis2_ntlm_auth_create_type3_message(ntlm, env, header_value, &encoded, &elen, user, password, domain, workstation); if(AXIS2_SUCCESS != status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "axis2_ntlm_auth_create_type3_message call failed"); printf("axis2_ntlm_auth_create_type3_message call failed\n"); return 1; } /* Create Type3 (authentication) header */ type3_header = create_type3_header(env, encoded); break; } } /* Send Type3(authentication) message */ send(sock, type3_header, strlen(type3_header), 0); bytes_recieved=recv(sock,recv_data,10024,0); recv_data[bytes_recieved] = '\0'; printf("\nRecieved data:\n%s \n" , recv_data); close(sock); 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; 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; }
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; }
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; }
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; }
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], ¶ms, 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); }
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; }
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; }
int add_subscriber() { remote_registry_t *remote_registry = NULL; const axutil_env_t *env = NULL; axis2_char_t *subscription_id = NULL; axis2_char_t *id = NULL; axis2_char_t *path = NULL; axis2_char_t *index_path = NULL; remote_registry_resource_t *res = NULL; axutil_hash_t *properties = NULL; char *content = (char *) strdup("<subscription><syn:endpoint xmlns:syn=\"http://ws.apache.org/ns/synapse\"><syn:address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" /></syn:endpoint></subscription>"); axis2_char_t *epr_type = "application/vnd.epr"; axis2_char_t *filter = "/weather/4/"; axis2_char_t *reg_url = "http://localhost:9762/registry"; env = axutil_env_create_all("test.log", AXIS2_LOG_LEVEL_TRACE); subscription_id = axutil_strcat(env, "urn:uuid:", axutil_uuid_gen(env), NULL); path = axutil_strcat(env, filter, SUBSCRIPTION_COLLECTION_NAME, "/", subscription_id, NULL); id = axutil_strcat(env, reg_url, filter, SUBSCRIPTION_COLLECTION_NAME, "/", subscription_id, NULL); remote_registry = remote_registry_create(env, reg_url, "admin", "admin"); topic_index_init(); res = remote_registry_resource_create(env); remote_registry_resource_set_content(res, env, content); remote_registry_resource_set_content_len(res, env, axutil_strlen(content)); remote_registry_resource_set_media_type(res, env, epr_type); remote_registry_resource_set_description(res, env, ""); properties = axutil_hash_make(env); if(properties) { axutil_hash_set(properties, axutil_strdup(env, "expires"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "*")); axutil_hash_set(properties, axutil_strdup(env, "staticFlag"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "false")); axutil_hash_set(properties, axutil_strdup(env, "filterValue"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, filter)); axutil_hash_set(properties, axutil_strdup(env, "subManagerURI"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "http://10.100.1.44:8280/services/SampleEventSource")); axutil_hash_set(properties, axutil_strdup(env, "filterDialect"), AXIS2_HASH_KEY_STRING, axutil_strdup(env, "http://synapse.apache.org/eventing/dialect/topicFilter")); remote_registry_resource_set_properties(res, env, properties); } remote_registry_put(remote_registry, env, path, res); if(id) { AXIS2_FREE(env->allocator, id); } if(path) { AXIS2_FREE(env->allocator, path); path = NULL; } if(res) { remote_registry_resource_free(res, env); res = NULL; } res = remote_registry_get(remote_registry, env, TOPIC_INDEX, NULL); if(!res) { return 0; } id = axutil_strcat(env, reg_url, TOPIC_INDEX, NULL); properties = remote_registry_resource_get_properties(res, env); if(properties) { path = axutil_strcat(env, filter, SUBSCRIPTION_COLLECTION_NAME, NULL); axutil_hash_set(properties, subscription_id, AXIS2_HASH_KEY_STRING, path); remote_registry_resource_set_properties(res, env, properties); } remote_registry_resource_set_content(res, env, NULL); remote_registry_resource_set_content_len(res, env, 0); index_path = axutil_strcat(env, TOPIC_INDEX, "/TopicIndex", NULL); remote_registry_put(remote_registry, env, TOPIC_INDEX, res); if(id) { AXIS2_FREE(env->allocator, id); } if(res) { remote_registry_resource_free(res, env); res = NULL; } printf("\n"); 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; /* 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; }