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[]) { int c; axutil_allocator_t *allocator; guththila_reader_t *red; axutil_env_t *environment; guththila_t *parser; char *xml_buffer; allocator = axutil_allocator_init(NULL); xml_buffer = "<?xml version = \"1.0\"?><test a=\"din\">addddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd123</test>"; environment = axutil_env_create(allocator); if(argc > 1) red = guththila_reader_create_for_file(environment, argv[1]); else { if(xml_buffer) { int size = 0; size = strlen(xml_buffer); red = guththila_reader_create_for_memory(environment, (void *)xml_buffer, size, NULL); } } parser = guththila_create(environment, red); guththila_read(environment, parser); while((c = guththila_next(environment, parser)) != -1) { switch(c) { case GUTHTHILA_START_DOCUMENT: { int ix; printf("<?xml "); ix = guththila_get_attribute_count(environment, parser); for(; ix > 0; ix--) { guththila_attribute_t *a; char *p; a = guththila_get_attribute(environment, parser); p = guththila_get_attribute_name(environment, parser, a); printf("%s=\"", p); AXIS2_FREE(allocator, p); p = guththila_get_attribute_value(environment, parser, a); printf("%s\" ", p); AXIS2_FREE(allocator, p); guththila_attribute_free(environment, a); } printf("?>\n"); } break; case GUTHTHILA_START_ELEMENT: case GUTHTHILA_EMPTY_ELEMENT: { int ia; int d; char *p; guththila_depth_t *depth; printf("<"); p = guththila_get_prefix(environment, parser); if(p) { printf("%s:", p); AXIS2_FREE(allocator, p); } p = guththila_get_name(environment, parser); printf("%s", p); AXIS2_FREE(allocator, p); ia = guththila_get_attribute_count(environment, parser); for(; ia > 0; ia--) { /* p = guththila_get_attribute_prefix_by_number (parser, ia); */ p = guththila_get_attribute_prefix_by_number(environment, parser, ia); if(p) { printf(" %s:", p); AXIS2_FREE(allocator, p); p = guththila_get_attribute_name_by_number(environment, parser, ia); printf("%s=\"", p); AXIS2_FREE(allocator, p); p = guththila_get_attribute_value_by_number(environment, parser, ia); printf("%s\"", p); AXIS2_FREE(allocator, p); } else { p = guththila_get_attribute_name_by_number(environment, parser, ia); printf(" %s=\"", p); AXIS2_FREE(allocator, p); p = guththila_get_attribute_value_by_number(environment, parser, ia); printf("%s\"", p); AXIS2_FREE(allocator, p); } } depth = (guththila_depth_t *)axutil_stack_get(parser->dep, environment); d = depth->count; for(; d > 0; d--) { p = guththila_get_namespace_prefix_by_number(environment, parser, d); if(strncmp(p, "xmlns", 5)) { printf(" xmlns:"); printf("%s=\"", p); } else printf(" xmlns=\""); AXIS2_FREE(allocator, p); p = guththila_get_namespace_uri_by_number(environment, parser, d); printf("%s\"", p); AXIS2_FREE(allocator, p); } if(parser->guththila_event == GUTHTHILA_START_ELEMENT) printf(">"); else if(parser->guththila_event == GUTHTHILA_EMPTY_ELEMENT) printf("/>"); else printf("error \n"); } break; case GUTHTHILA_END_ELEMENT: { char *p; printf("</"); p = guththila_get_prefix(environment, parser); if(p) { printf("%s:", p); AXIS2_FREE(allocator, p); } p = guththila_get_name(environment, parser); printf("%s", p); AXIS2_FREE(allocator, p); printf(">"); } break; case GUTHTHILA_CHARACTER: { char *p = NULL; p = guththila_get_value(environment, parser); /* if (!parser->is_whitespace) */ /* { */ /* printf(p); */ /* } */ printf("%s", p); AXIS2_FREE(allocator, p); } break; case GUTHTHILA_COMMENT: break; }; } guththila_reader_free(environment, red); guththila_free(environment, parser); axutil_env_free(environment); return 0; }
int axis2_test_msg_info_headers( ) { axis2_endpoint_ref_t *to = NULL; axis2_endpoint_ref_t *from = NULL; axis2_endpoint_ref_t *reply_to = NULL; axis2_endpoint_ref_t *fault_to = NULL; axis2_endpoint_ref_t *axis2_endpoint_ref = NULL; axis2_status_t status = AXIS2_FAILURE; axis2_msg_info_headers_t *axis2_msg_info_headers = NULL; axutil_allocator_t *allocator = axutil_allocator_init(NULL); const axutil_env_t *env = axutil_env_create(allocator); const axis2_char_t *action = "test action"; const axis2_char_t *get_action = NULL; to = axis2_endpoint_ref_create(env, "to"); from = axis2_endpoint_ref_create(env, "from"); reply_to = axis2_endpoint_ref_create(env, "reply to"); fault_to = axis2_endpoint_ref_create(env, "fault to"); axis2_msg_info_headers = axis2_msg_info_headers_create(env, NULL, action); if (axis2_msg_info_headers) printf("SUCCESS axis2_msg_info_headers_create\n"); else { printf("ERROR AXIS2_MSG_INFO_HEADERS_CREATE\n"); return -1; } status = axis2_msg_info_headers_set_to(axis2_msg_info_headers, env, to); if (status == AXIS2_SUCCESS) printf("SUCCESS axis2_msg_info_headers_set_to\n"); else { printf("ERROR axis2_msg_info_headers_set_to"); return -1; } axis2_endpoint_ref = axis2_msg_info_headers_get_to(axis2_msg_info_headers, env); if (axis2_endpoint_ref) printf("SUCCESS axis2_msg_info_headers_get_to\n"); else { printf("ERROR axis2_msg_info_headers_get_to\n"); return -1; } status = AXIS2_FAILURE; status = axis2_msg_info_headers_set_from(axis2_msg_info_headers, env, from); if (status) printf("SUCCESS axis2_msg_info_headers_set_from\n"); else { printf("ERROR axis2_msg_info_headers_set_from\n"); return -1; } axis2_endpoint_ref = NULL; axis2_endpoint_ref = axis2_msg_info_headers_get_from(axis2_msg_info_headers, env); if (axis2_endpoint_ref) printf("SUCCESS axis2_msg_info_headers_get_from\n"); else { printf("ERROR axis2_msg_info_headers_get_from\n"); return -1; } axis2_endpoint_ref = NULL; axis2_endpoint_ref = axis2_msg_info_headers_get_reply_to(axis2_msg_info_headers, env); if (status) printf("SUCCESS axis2_msg_info_headers_get_reply_to\n"); else { printf("ERROR axis2_msg_info_headers_get_reply_to\n"); return -1; } status = AXIS2_FAILURE; status = axis2_msg_info_headers_set_reply_to(axis2_msg_info_headers, env, reply_to); if (status) printf("SUCCESS axis2_msg_info_headers_set_reply_to\n"); else { printf("ERROR axis2_msg_info_headers_set_reply_to\n"); return -1; } status = AXIS2_FAILURE; status = axis2_msg_info_headers_set_fault_to(axis2_msg_info_headers, env, fault_to); if (status) printf("SUCCESS axis2_msg_info_headers_set_fault_to\n"); else { printf("ERROR axis2_msg_info_headers_set_fault_to\n"); return -1; } axis2_endpoint_ref = NULL; axis2_endpoint_ref = axis2_msg_info_headers_get_fault_to(axis2_msg_info_headers, env); if (axis2_endpoint_ref) printf("SUCCESS axis2_msg_info_headers_get_fault_to\n"); else { printf("ERROR axis2_msg_info_headers_get_fault_to\n"); return -1; } get_action = axis2_msg_info_headers_get_action(axis2_msg_info_headers, env); if (get_action) printf("SUCCESS axis2_msg_info_headers_get_action\n"); else { printf("ERROR axis2_msg_info_headers_get_action\n"); return -1; } status = AXIS2_FAILURE; status = axis2_msg_info_headers_set_action(axis2_msg_info_headers, env, action); if (status) printf("SUCCESS axis2_msg_info_headers_set_action\n"); else { printf("ERROR axis2_msg_info_headers_set_action\n"); } status = AXIS2_FAILURE; /* status = axis2_msg_info_headers_free(axis2_msg_info_headers, env); */ if (status) printf("SUCCESS axis2_msg_info_headers_free\n"); else { printf("ERROR axis2_msg_info_headers_free\n"); } return 0; }