axiom_node_t * axis2_echo_echo( const axutil_env_t * env, axiom_node_t * node) { axiom_node_t *text_parent_node = NULL; axiom_node_t *text_node = NULL; axiom_node_t *ret_node = NULL; AXIS2_ENV_CHECK(env, NULL); /* Expected request format is :- * <ns1:echoString xmlns:ns1="http://ws.apache.org/axis2/c/samples"> * <text>echo5</text> * </ns1:echoString> */ if (!node) /* 'echoString' node */ { set_custom_error(env, "Invalid payload; echoString node is NULL"); return NULL; } text_parent_node = axiom_node_get_first_element(node, env); if (!text_parent_node) { set_custom_error(env, "Invalid payload; text node is NULL"); return NULL; } text_node = axiom_node_get_first_child(text_parent_node, env); if (!text_node) /* actual text to echo */ { set_custom_error(env, "Invalid payload; text to be echoed is NULL"); return NULL; } if (axiom_node_get_node_type(text_node, env) == AXIOM_TEXT) { axiom_text_t *text = (axiom_text_t *) axiom_node_get_data_element(text_node, env); if (text && axiom_text_get_value(text, env)) { axis2_char_t *text_str = (axis2_char_t *) axiom_text_get_value(text, env); ret_node = build_om_programatically(env, text_str); } } else { set_custom_error(env, "Invalid payload; invalid XML in request"); return NULL; } return ret_node; }
axiom_node_t * axis2_publisher_start(const axutil_env_t *env, axiom_node_t *node) { axiom_node_t *ret_node = NULL; printf("Publisher service start called.\n"); AXIS2_ENV_CHECK(env, NULL); ret_node = build_om_programatically(env, "Publisher started"); return ret_node; }
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) { 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) { 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; axis2_status_t status = AXIS2_FAILURE; /* Set up the environment */ env = axutil_env_create_all("notify_amqp.log", AXIS2_LOG_LEVEL_TRACE); /* Set end point reference of echo service */ address = "amqp://localhost:5672/axis2/services/notify"; 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://example.org/action/notify"); /* 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); /* Send request */ status = axis2_svc_client_send_robust(svc_client, env, payload); if (status == AXIS2_SUCCESS) { printf("\nnotify 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("notify 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; axis2_status_t status = AXIS2_FAILURE; axutil_property_t *property = NULL; axis2_char_t *seq_key = NULL; neethi_policy_t *policy = NULL; /* Set up the environment */ env = axutil_env_create_all("rm_ping_1_0_amqp.log", AXIS2_LOG_LEVEL_TRACE); /* Set end point reference of echo service */ address = "amqp://127.0.0.1:5672/axis2/services/RM10SampleService"; 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_xml_parser_reset(options, env, AXIS2_FALSE); if(endpoint_ref) { axis2_options_set_to(options, env, endpoint_ref); } axis2_options_set_action(options, env, "urn:wsrm:Ping"); /* 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)); } /*Create the policy, from file*/ policy = neethi_util_create_policy_from_file(env, "../policy/rm10-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); /* Engage addressing module */ axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); axis2_svc_client_engage_module(svc_client, env, "sandesha2"); /* RM Version 1.0 */ property = axutil_property_create_with_args(env, 0, 0, 0, SANDESHA2_SPEC_VERSION_1_0); if(property) { axis2_options_set_property(options, env, SANDESHA2_CLIENT_RM_SPEC_VERSION, property); } seq_key = axutil_uuid_gen(env); property = axutil_property_create_with_args(env, 0, 0, 0, seq_key); if(property) { axis2_options_set_property(options, env, SANDESHA2_CLIENT_SEQ_KEY, property); } /* Send request */ payload = build_om_programatically(env, "ping1", seq_key); status = axis2_svc_client_send_robust(svc_client, env, payload); if(status) { printf("\nping client invoke SUCCESSFUL!\n"); } payload = NULL; payload = build_om_programatically(env, "ping2", seq_key); status = axis2_svc_client_send_robust(svc_client, env, payload); if(status) { printf("\nping client invoke SUCCESSFUL!\n"); } payload = NULL; property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE); axis2_options_set_property(options, env, "Sandesha2LastMessage", property); payload = build_om_programatically(env, "ping3", seq_key); status = axis2_svc_client_send_robust(svc_client, env, payload); if(status) { printf("\nping client invoke SUCCESSFUL!\n"); } /** Wait till callback is complete. Simply keep the parent thread running until our on_complete or on_error is invoked */ /*This sleep is for wait the main thread until sandesha sends the terminatesequence *messages. */ AXIS2_SLEEP(SANDESHA2_SLEEP); AXIS2_FREE(env->allocator, seq_key); 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; }