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; }
WSF_WSDL_EXTERN axis2_bool_t WSF_WSDL_CALL wsf_wsdl_request( const axutil_env_t* env, axis2_char_t* wsdl_file_name, const axis2_char_t* operation_name, wsf_wsdl_data_t* parameters, axis2_char_t* script_binding_home, axis2_svc_client_t* svc_client, axutil_hash_t* svc_client_user_options, axis2_char_t* service_name, axis2_char_t* port_name, wsf_wsdl_data_t** response) { int soap_version = 2; int has_fault = AXIS2_FALSE; int binding_style = WSDL_BINDING_STYLE_DOC_LIT_W; axis2_char_t* payload = NULL; axiom_node_t* payload_node = NULL; axis2_char_t* request_buffer = NULL; axiom_node_t* type_map = NULL; axis2_char_t *res_text = NULL; axiom_node_t* sig_axiom = NULL; axiom_node_t *fault_node = NULL; axiom_node_t* wsdl_axiom = NULL; axiom_node_t* params_node = NULL; axiom_node_t* returns_node = NULL; axiom_soap_body_t *soap_body = NULL; axiom_node_t *body_base_node = NULL; /*axis2_char_t *wrapper_element = NULL;*/ axiom_node_t* operation_axiom = NULL; axiom_soap_fault_t *soap_fault = NULL; axis2_options_t *client_options = NULL; /*axis2_char_t *wrapper_element_ns = NULL;*/ /*axiom_node_t *axiom_soap_base_node = NULL; */ axiom_soap_envelope_t *response_envelope = NULL; wsf_wsdl_data_template_t* input_template = NULL; wsf_wsdl_data_template_t* output_template = NULL; axis2_bool_t is_version1_wsdl = AXIS2_FALSE; axis2_char_t* xslt_location = NULL; axis2_char_t* type_map_file = NULL; AXIS2_LOG_TRACE_MSG(env->log, "Starting execution of wsf_wsdl_request..."); xslt_location = axutil_strcat(env, script_binding_home, WSF_WSDL_XSLT_LOCATION_POSTFIX, NULL); type_map_file = axutil_strcat(env, script_binding_home, WSF_WSDL_TYPE_MAP_POSTFIX, NULL); client_options = (axis2_options_t *)axis2_svc_client_get_options(svc_client, env); axis2_options_set_xml_parser_reset(client_options, env, AXIS2_FALSE); if (!wsf_wsdl_parser_load_wsdl(env, wsdl_file_name, xslt_location, &wsdl_axiom, &sig_axiom, &is_version1_wsdl, AXIS2_FALSE)) return AXIS2_FALSE; wsdl_util_create_type_map(env, type_map_file, &type_map); wsdl_util_manage_client_options(env, svc_client, svc_client_user_options, client_options, operation_name, wsdl_axiom, is_version1_wsdl, sig_axiom, service_name, port_name, &operation_axiom, &soap_version); wsdl_util_identify_binding_style(env, operation_axiom, &binding_style); if (!operation_axiom) { AXIS2_LOG_ERROR_MSG(env->log, "Operation axiom is NULL"); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } wsdl_util_get_params_node(env, operation_axiom, ¶ms_node); wsdl_util_get_returns_node(env, operation_axiom, &returns_node); wsdl_data_util_axiom_to_template(env, params_node, &input_template); wsdl_data_util_axiom_to_template(env, returns_node, &output_template); #ifdef WSDL_DEBUG_MODE { axis2_char_t* buffer = NULL; wsdl_data_util_serialize_data(env, parameters, &buffer); AXIS2_LOG_DEBUG_MSG(env->log, buffer); AXIS2_FREE(env->allocator, buffer); wsdl_data_util_serialize_template(env, input_template, &buffer); AXIS2_LOG_DEBUG_MSG(env->log, buffer); AXIS2_FREE(env->allocator, buffer); buffer = NULL; } #endif if (wsdl_data_util_validate_data(env, type_map, input_template, parameters, VALIDATION_CRITERIA_REQUEST_MODE_TYPE) == AXIS2_TRUE) { payload_node = wsdl_data_util_create_payload(env, parameters, binding_style); payload = payload_node? axiom_node_to_string(payload_node, env) : NULL; // axiom_node_free_tree(payload_node, env); } else { AXIS2_LOG_ERROR_MSG(env->log, "User data is not valid or not in proper format"); if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } if (!payload_node) { AXIS2_LOG_ERROR_MSG(env->log, "Request payload is not found"); if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } request_buffer = (axis2_char_t*)wsdl_util_create_request_envelope(env, payload_node, soap_version); if (!request_buffer) { AXIS2_LOG_ERROR_MSG(env->log, "Error in creating request payload dom"); if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } response_envelope = (axiom_soap_envelope_t*)wsdl_util_send_receive_soap_envelope_with_op_client(env, svc_client, client_options, request_buffer); if (response_envelope) { has_fault = AXIS2_TRUE; soap_body = axiom_soap_envelope_get_body (response_envelope, env); if (soap_body) { soap_fault = axiom_soap_body_get_fault (soap_body, env); } if (soap_fault) { soap_version = axis2_options_get_soap_version(client_options, env); fault_node = axiom_soap_fault_get_base_node(soap_fault, env); if (fault_node) { res_text = axiom_node_to_string(fault_node, env); AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI, "Fault payload is %s", res_text); if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } } if (soap_body) { body_base_node = axiom_soap_body_get_base_node(soap_body, env); } if (body_base_node && !soap_fault) { axis2_char_t *response_buffer = NULL; wsf_wsdl_data_t *response_data = NULL; response_buffer = axiom_node_to_string(body_base_node, env); AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI, "Response buffer is %s", response_buffer); AXIS2_FREE(env->allocator, response_buffer); wsdl_data_util_axiom_to_data(env, body_base_node, &response_data); #ifdef WSDL_DEBUG_MODE { axis2_char_t* buffer = NULL; wsdl_data_util_serialize_data(env, response_data, &buffer); AXIS2_LOG_DEBUG_MSG(env->log, buffer); AXIS2_FREE(env->allocator, buffer); wsdl_data_util_serialize_template(env, output_template, &buffer); AXIS2_LOG_DEBUG_MSG(env->log, buffer); AXIS2_FREE(env->allocator, buffer); buffer = NULL; } #endif if (wsdl_data_util_validate_data(env, type_map, output_template, response_data, VALIDATION_CRITERIA_RESPONSE_MODE) == AXIS2_TRUE) { AXIS2_LOG_DEBUG_MSG(env->log, "Valid response!!!"); *response = response_data; if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_TRUE; } else { AXIS2_LOG_ERROR_MSG(env->log, "Response data is not valid or not in proper format"); if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } } } else /* response_envelope == NULL */ { AXIS2_LOG_ERROR_MSG(env->log, "Response envelope not found"); } if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axiom_soap_body_convert_fault_to_soap11( axiom_soap_body_t * soap_body, const axutil_env_t * env) { if(soap_body) { axiom_soap_fault_t *soap_fault = NULL; if(axiom_soap_body_has_fault(soap_body, env)) { soap_fault = axiom_soap_body_get_fault(soap_body, env); if(soap_fault) { axiom_soap_fault_code_t *fault_code = NULL; axiom_soap_fault_reason_t *fault_reason = NULL; axiom_soap_fault_detail_t *fault_detail = NULL; axiom_soap_fault_role_t *fault_role = NULL; fault_code = axiom_soap_fault_get_code(soap_fault, env); if(fault_code) { axiom_node_t *fault_code_om_node = NULL; axiom_element_t *fault_code_om_ele = NULL; axiom_node_t *fault_value_om_node = NULL; axiom_element_t *fault_value_om_ele = NULL; axiom_soap_fault_value_t *fault_value = NULL; axis2_char_t *text = NULL; fault_code_om_node = axiom_soap_fault_code_get_base_node(fault_code, env); if(fault_code_om_node) { fault_code_om_ele = (axiom_element_t *)axiom_node_get_data_element( fault_code_om_node, env); if(fault_code_om_ele) { axiom_element_set_localname(fault_code_om_ele, env, AXIOM_SOAP11_SOAP_FAULT_CODE_LOCAL_NAME); fault_value = axiom_soap_fault_code_get_value(fault_code, env); if(fault_value) { fault_value_om_node = axiom_soap_fault_value_get_base_node( fault_value, env); if(fault_value_om_node) { fault_value_om_ele = (axiom_element_t *)axiom_node_get_data_element( fault_value_om_node, env); if(fault_value_om_ele) { text = axiom_element_get_text(fault_value_om_ele, env, fault_value_om_node); if(text) { axiom_element_set_text(fault_code_om_ele, env, text, fault_code_om_node); } } axiom_node_free_tree(fault_value_om_node, env); axiom_soap_fault_value_set_base_node(fault_value, env, NULL); } } } } } fault_reason = axiom_soap_fault_get_reason(soap_fault, env); if(fault_reason) { axiom_node_t *fault_reason_om_node = NULL; axiom_element_t *fault_reason_om_ele = NULL; axiom_node_t *fault_text_om_node = NULL; axiom_element_t *fault_text_om_ele = NULL; axiom_soap_fault_text_t *fault_text = NULL; axis2_char_t *text = NULL; fault_reason_om_node = axiom_soap_fault_reason_get_base_node(fault_reason, env); if(fault_reason_om_node) { fault_reason_om_ele = (axiom_element_t *)axiom_node_get_data_element( fault_reason_om_node, env); if(fault_reason_om_ele) { axiom_element_set_localname(fault_reason_om_ele, env, AXIOM_SOAP11_SOAP_FAULT_STRING_LOCAL_NAME); fault_text = axiom_soap_fault_reason_get_first_soap_fault_text( fault_reason, env); if(fault_text) { fault_text_om_node = axiom_soap_fault_text_get_base_node( fault_text, env); if(fault_text_om_node) { fault_text_om_ele = (axiom_element_t *)axiom_node_get_data_element( fault_text_om_node, env); if(fault_text_om_ele) { text = axiom_element_get_text(fault_text_om_ele, env, fault_text_om_node); if(text) { axiom_element_set_text(fault_reason_om_ele, env, text, fault_reason_om_node); } } axiom_node_free_tree(fault_text_om_node, env); axiom_soap_fault_text_set_base_node(fault_text, env, NULL); } } } } } fault_role = axiom_soap_fault_get_role(soap_fault, env); if(fault_role) { axiom_node_t *fault_role_om_node = NULL; axiom_element_t *fault_role_om_ele = NULL; fault_role_om_node = axiom_soap_fault_role_get_base_node(fault_role, env); if(fault_role_om_node) { fault_role_om_ele = (axiom_element_t *)axiom_node_get_data_element( fault_role_om_node, env); if(fault_role_om_ele) { axiom_element_set_localname(fault_role_om_ele, env, AXIOM_SOAP11_SOAP_FAULT_ACTOR_LOCAL_NAME); } } } fault_detail = axiom_soap_fault_get_detail(soap_fault, env); if(fault_detail) { axiom_node_t *fault_detail_om_node = NULL; axiom_element_t *fault_detail_om_ele = NULL; fault_detail_om_node = axiom_soap_fault_detail_get_base_node(fault_detail, env); if(fault_detail_om_node) { fault_detail_om_ele = (axiom_element_t *)axiom_node_get_data_element( fault_detail_om_node, env); if(fault_detail_om_ele) { axiom_element_set_localname(fault_detail_om_ele, env, AXIOM_SOAP11_SOAP_FAULT_DETAIL_LOCAL_NAME); } } } } } } return AXIS2_SUCCESS; }
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; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axiom_soap11_builder_helper_handle_event( axiom_soap11_builder_helper_t * builder_helper, const axutil_env_t * env, axiom_node_t * om_element_node, int element_level) { axiom_element_t *om_ele = NULL; axis2_char_t *ele_localname = NULL; axiom_soap_envelope_t *soap_envelope = NULL; axiom_soap_body_t *soap_body = NULL; axiom_soap_fault_t *soap_fault = NULL; AXIS2_PARAM_CHECK(env->error, om_element_node, AXIS2_FAILURE); om_ele = (axiom_element_t *)axiom_node_get_data_element(om_element_node, env); ele_localname = axiom_element_get_localname(om_ele, env); if(!ele_localname) { return AXIS2_FAILURE; } soap_envelope = axiom_soap_builder_get_soap_envelope(builder_helper->soap_builder, env); if(!soap_envelope) { return AXIS2_FAILURE; } soap_body = axiom_soap_envelope_get_body(soap_envelope, env); if(!soap_body) { return AXIS2_FAILURE; } soap_fault = axiom_soap_body_get_fault(soap_body, env); if(!soap_fault) { return AXIS2_FAILURE; } if(element_level == 4) { axiom_soap_fault_code_t *fault_code = NULL; axiom_soap_fault_value_t *fault_value = NULL; axiom_node_t *fault_value_node = NULL; axiom_element_t *fault_value_ele = NULL; if(axutil_strcmp(ele_localname, AXIOM_SOAP11_SOAP_FAULT_CODE_LOCAL_NAME) == 0) { axis2_status_t status = AXIS2_SUCCESS; if(builder_helper->fault_string_present) { axiom_soap_builder_set_bool_processing_mandatory_fault_elements( builder_helper->soap_builder, env, AXIS2_FALSE); } fault_code = axiom_soap_fault_code_create(env); if(!fault_code) { return AXIS2_FAILURE; } axiom_soap_fault_code_set_base_node(fault_code, env, om_element_node); axiom_soap_fault_set_code(soap_fault, env, fault_code); axiom_soap_fault_code_set_builder(fault_code, env, builder_helper->soap_builder); axiom_element_set_localname(om_ele, env, AXIOM_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME); fault_value = axiom_soap_fault_value_create_with_code(env, fault_code); if(!fault_value) { return AXIS2_FAILURE; } fault_value_node = axiom_soap_fault_value_get_base_node(fault_value, env); if(!fault_value_node) { return AXIS2_FAILURE; } fault_value_ele = (axiom_element_t *)axiom_node_get_data_element(fault_value_node, env); axiom_stax_builder_set_lastnode(builder_helper->om_builder, env, fault_value_node); status = axiom_soap11_builder_helper_process_text(builder_helper, env); if(status == AXIS2_FAILURE) { return AXIS2_FAILURE; } axiom_stax_builder_set_lastnode(builder_helper->om_builder, env, om_element_node); axiom_node_set_complete(om_element_node, env, AXIS2_TRUE); axiom_stax_builder_set_element_level(builder_helper->om_builder, env, (element_level - 1)); builder_helper->fault_code_present = AXIS2_TRUE; } else if(axutil_strcmp(AXIOM_SOAP11_SOAP_FAULT_STRING_LOCAL_NAME, ele_localname) == 0) { axiom_soap_fault_reason_t *fault_reason = NULL; axiom_soap_fault_text_t *fault_text = NULL; axiom_node_t *fault_text_node = NULL; int status = AXIS2_SUCCESS; if(builder_helper->fault_code_present) { axiom_soap_builder_set_bool_processing_mandatory_fault_elements( builder_helper->soap_builder, env, AXIS2_FALSE); } axiom_element_set_localname(om_ele, env, AXIOM_SOAP12_SOAP_FAULT_REASON_LOCAL_NAME); fault_reason = axiom_soap_fault_reason_create(env); if(!fault_reason) { return AXIS2_FAILURE; } axiom_soap_fault_reason_set_base_node(fault_reason, env, om_element_node); axiom_soap_fault_set_reason(soap_fault, env, fault_reason); fault_text = axiom_soap_fault_text_create_with_parent(env, fault_reason); if(!fault_text) { return AXIS2_FAILURE; } fault_text_node = axiom_soap_fault_text_get_base_node(fault_text, env); if(!fault_text_node) { return AXIS2_FAILURE; } axiom_stax_builder_set_lastnode(builder_helper->om_builder, env, fault_text_node); status = axiom_soap11_builder_helper_process_text(builder_helper, env); if(status == AXIS2_FAILURE) { return AXIS2_FAILURE; } axiom_stax_builder_set_lastnode(builder_helper->om_builder, env, om_element_node); axiom_node_set_complete(om_element_node, env, AXIS2_TRUE); axiom_stax_builder_set_element_level(builder_helper->om_builder, env, (element_level - 1)); builder_helper->fault_string_present = AXIS2_TRUE; } else if(axutil_strcmp(AXIOM_SOAP11_SOAP_FAULT_ACTOR_LOCAL_NAME, ele_localname) == 0) { axiom_soap_fault_role_t *fault_role = NULL; fault_role = axiom_soap_fault_role_create(env); if(!fault_role) { return AXIS2_FAILURE; } axiom_element_set_localname(om_ele, env, AXIOM_SOAP12_SOAP_FAULT_ROLE_LOCAL_NAME); axiom_soap_fault_role_set_base_node(fault_role, env, om_element_node); axiom_soap_fault_set_role(soap_fault, env, fault_role); /* Role element may not have a namespace associated, hence commented, else it segfaults here - Samisa status = axiom_soap_builder_process_namespace_data( builder_helper->soap_builder, env, om_element_node, AXIS2_TRUE); if(status == AXIS2_FAILURE) return AXIS2_FAILURE; */ } else if(axutil_strcmp(AXIOM_SOAP11_SOAP_FAULT_DETAIL_LOCAL_NAME, ele_localname) == 0) { axiom_soap_fault_detail_t *fault_detail = NULL; fault_detail = axiom_soap_fault_detail_create(env); if(!fault_detail) { return AXIS2_FAILURE; } axiom_element_set_localname(om_ele, env, AXIOM_SOAP12_SOAP_FAULT_DETAIL_LOCAL_NAME); axiom_soap_fault_detail_set_base_node(fault_detail, env, om_element_node); axiom_soap_fault_set_detail(soap_fault, env, fault_detail); } else { return AXIS2_SUCCESS; } } else if(element_level == 5) { axiom_node_t *parent_node = NULL; axiom_element_t *parent_element = NULL; axis2_char_t *parent_localname = NULL; parent_node = axiom_node_get_parent(om_element_node, env); if(!parent_node) { return AXIS2_FAILURE; } parent_element = (axiom_element_t *)axiom_node_get_data_element(om_element_node, env); parent_localname = axiom_element_get_localname(parent_element, env); if(!parent_localname) { return AXIS2_FAILURE; } if(axutil_strcmp(parent_localname, AXIOM_SOAP12_SOAP_FAULT_ROLE_LOCAL_NAME) == 0) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP11_FAULT_ACTOR_SHOULD_NOT_HAVE_CHILD_ELEMENTS, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "SOAP 1.1 Actor should not have child elements"); return AXIS2_FAILURE; } } return AXIS2_SUCCESS; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axiom_soap12_builder_helper_handle_event( axiom_soap12_builder_helper_t * builder_helper, const axutil_env_t * env, axiom_node_t * om_ele_node, int element_level) { axis2_char_t *ele_localname = NULL; axiom_element_t *om_ele = NULL; axiom_soap_body_t *soap_body = NULL; axiom_soap_fault_t *soap_fault = NULL; axiom_soap_envelope_t *soap_envelope = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, om_ele_node, AXIS2_FAILURE); om_ele = (axiom_element_t *) axiom_node_get_data_element(om_ele_node, env); if (!om_ele) { return AXIS2_FAILURE; } ele_localname = axiom_element_get_localname(om_ele, env); if (!ele_localname) { return AXIS2_FAILURE; } soap_envelope = axiom_soap_builder_get_soap_envelope(builder_helper->soap_builder, env); if (!soap_envelope) { return AXIS2_FAILURE; } soap_body = axiom_soap_envelope_get_body(soap_envelope, env); if (!soap_body) { return AXIS2_FAILURE; } soap_fault = axiom_soap_body_get_fault(soap_body, env); if (!soap_fault) { return AXIS2_FAILURE; } if (element_level == 4) { if (axutil_strcmp (AXIOM_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME, ele_localname) == 0) { if (builder_helper->code_present) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MULTIPLE_CODE_ELEMENTS_ENCOUNTERED, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Multiple fault code elements encountered in SOAP fault"); return AXIS2_FAILURE; } else { axiom_soap_fault_code_t *soap_fault_code = NULL; soap_fault_code = axiom_soap_fault_code_create(env); if (!soap_fault_code) { return AXIS2_FAILURE; } axiom_soap_fault_code_set_base_node(soap_fault_code, env, om_ele_node); axiom_soap_fault_code_set_builder(soap_fault_code, env, builder_helper->soap_builder); axiom_soap_fault_set_code(soap_fault, env, soap_fault_code); builder_helper->code_present = AXIS2_TRUE; builder_helper->code_processing = AXIS2_TRUE; } } else if (axutil_strcmp (AXIOM_SOAP12_SOAP_FAULT_REASON_LOCAL_NAME, ele_localname) == 0) { if (!(builder_helper->code_processing) && !(builder_helper->sub_code_processing)) { if (builder_helper->code_present) { if (builder_helper->reason_present) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MULTIPLE_REASON_ELEMENTS_ENCOUNTERED, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Multiple fault reason elements encountered in SOAP fault"); return AXIS2_FAILURE; } else { axiom_soap_fault_reason_t *fault_reason = NULL; fault_reason = axiom_soap_fault_reason_create(env); if (!fault_reason) { return AXIS2_FAILURE; } axiom_soap_fault_reason_set_base_node(fault_reason, env, om_ele_node); axiom_soap_fault_set_reason(soap_fault, env, fault_reason); axiom_soap_fault_reason_set_builder(fault_reason, env, builder_helper-> soap_builder); builder_helper->reason_present = AXIS2_TRUE; builder_helper->reason_processing = AXIS2_TRUE; } } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_WRONG_ELEMENT_ORDER_ENCOUNTERED, AXIS2_FAILURE); return AXIS2_FAILURE; } } else { if (builder_helper->code_processing) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_FAULT_CODE_DOES_NOT_HAVE_A_VALUE, AXIS2_FAILURE); return AXIS2_FAILURE; } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_FAULT_CODE_DOES_NOT_HAVE_A_VALUE, AXIS2_FAILURE); return AXIS2_FAILURE; } } } else if (axutil_strcmp (ele_localname, AXIOM_SOAP12_SOAP_FAULT_NODE_LOCAL_NAME) == 0) { if (!(builder_helper->reason_processing)) { if (builder_helper->reason_present && !(builder_helper->role_present) && !(builder_helper->detail_present)) { if (builder_helper->node_present) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MULTIPLE_NODE_ELEMENTS_ENCOUNTERED, AXIS2_FAILURE); return AXIS2_FAILURE; } else { axiom_soap_fault_node_t *soap_fault_node = NULL; soap_fault_node = axiom_soap_fault_node_create(env); if (!soap_fault_node) { return AXIS2_FAILURE; } axiom_soap_fault_node_set_base_node(soap_fault_node, env, om_ele_node); axiom_soap_fault_set_node(soap_fault, env, soap_fault_node); builder_helper->node_present = AXIS2_TRUE; } } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_WRONG_ELEMENT_ORDER_ENCOUNTERED, AXIS2_FALSE); return AXIS2_FAILURE; } } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_FAULT_REASON_ELEMENT_SHOULD_HAVE_A_TEXT, AXIS2_FALSE); return AXIS2_FAILURE; } } else if (axutil_strcmp (ele_localname, AXIOM_SOAP12_SOAP_FAULT_ROLE_LOCAL_NAME) == 0) { if (!(builder_helper->reason_processing)) { if (builder_helper->reason_present && !(builder_helper->detail_present)) { if (builder_helper->role_present) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MULTIPLE_ROLE_ELEMENTS_ENCOUNTERED, AXIS2_FAILURE); return AXIS2_FAILURE; } else { axiom_soap_fault_role_t *soap_fault_role = NULL; soap_fault_role = axiom_soap_fault_role_create(env); if (!soap_fault_role) return AXIS2_FAILURE; axiom_soap_fault_role_set_base_node(soap_fault_role, env, om_ele_node); axiom_soap_fault_set_role(soap_fault, env, soap_fault_role); builder_helper->role_present = AXIS2_TRUE; } } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_WRONG_ELEMENT_ORDER_ENCOUNTERED, AXIS2_FAILURE); return AXIS2_FAILURE; } } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_FAULT_ROLE_ELEMENT_SHOULD_HAVE_A_TEXT, AXIS2_FAILURE); return AXIS2_FAILURE; } } else if (axutil_strcmp (ele_localname, AXIOM_SOAP12_SOAP_FAULT_DETAIL_LOCAL_NAME) == 0) { if (!(builder_helper->reason_processing)) { if (builder_helper->reason_present) { if (builder_helper->detail_present) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MULTIPLE_DETAIL_ELEMENTS_ENCOUNTERED, AXIS2_FAILURE); return AXIS2_FAILURE; } else { axiom_soap_fault_detail_t *soap_fault_detail = NULL; soap_fault_detail = axiom_soap_fault_detail_create(env); if (!soap_fault_detail) return AXIS2_FAILURE; axiom_soap_fault_detail_set_base_node(soap_fault_detail, env, om_ele_node); axiom_soap_fault_set_detail(soap_fault, env, soap_fault_detail); builder_helper->detail_present = AXIS2_TRUE; } } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_WRONG_ELEMENT_ORDER_ENCOUNTERED, AXIS2_FAILURE); return AXIS2_FAILURE; } } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_FAULT_REASON_ELEMENT_SHOULD_HAVE_A_TEXT, AXIS2_FAILURE); return AXIS2_FAILURE; } } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_UNSUPPORTED_ELEMENT_IN_SOAP_FAULT_ELEMENT, AXIS2_FAILURE); return AXIS2_FAILURE; } } else if (element_level == 5) { axiom_node_t *parent_node = NULL; axiom_element_t *parent_ele = NULL; axis2_char_t *parent_localname = NULL; parent_node = axiom_node_get_parent(om_ele_node, env); if (!parent_node) { return AXIS2_FAILURE; } parent_ele = (axiom_element_t *) axiom_node_get_data_element(parent_node, env); if (!parent_ele) { return AXIS2_FAILURE; } parent_localname = axiom_element_get_localname(parent_ele, env); if (!parent_localname) { return AXIS2_FAILURE; } if (axutil_strcmp(parent_localname, AXIOM_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME) == 0) { if (axutil_strcmp (ele_localname, AXIOM_SOAP12_SOAP_FAULT_VALUE_LOCAL_NAME) == 0) { if (!(builder_helper->value_present)) { axiom_soap_fault_value_t *soap_fault_value = NULL; axiom_soap_fault_code_t *parent_fcode = NULL; soap_fault_value = axiom_soap_fault_value_create(env); if (!soap_fault_value) { return AXIS2_FAILURE; } axiom_soap_fault_value_set_base_node(soap_fault_value, env, om_ele_node); parent_fcode = axiom_soap_fault_get_code(soap_fault, env); if (!parent_fcode) { return AXIS2_FAILURE; } axiom_soap_fault_code_set_value(parent_fcode, env, soap_fault_value); builder_helper->value_present = AXIS2_TRUE; builder_helper->code_processing = AXIS2_FALSE; } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MULTIPLE_VALUE_ENCOUNTERED_IN_CODE_ELEMENT, AXIS2_FAILURE); return AXIS2_FAILURE; } } else if (axutil_strcmp(ele_localname, AXIOM_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME) == 0) { if (!(builder_helper->sub_code_present)) { if (builder_helper->value_present) { axiom_soap_fault_sub_code_t *fault_subcode = NULL; axiom_soap_fault_code_t *fault_code = NULL; fault_subcode = axiom_soap_fault_sub_code_create(env); if (!fault_subcode) { return AXIS2_FAILURE; } axiom_soap_fault_sub_code_set_base_node(fault_subcode, env, om_ele_node); fault_code = axiom_soap_fault_get_code(soap_fault, env); if (!fault_code) { return AXIS2_FAILURE; } axiom_soap_fault_code_set_sub_code(fault_code, env, fault_subcode); axiom_soap_fault_sub_code_set_builder(fault_subcode, env, builder_helper-> soap_builder); builder_helper->sub_code_present = AXIS2_TRUE; builder_helper->sub_code_processing = AXIS2_TRUE; } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_FAULT_VALUE_SHOULD_BE_PRESENT_BEFORE_SUB_CODE, AXIS2_FAILURE); return AXIS2_FAILURE; } } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MULTIPLE_SUB_CODE_VALUES_ENCOUNTERED, AXIS2_FAILURE); return AXIS2_FAILURE; } } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_THIS_LOCALNAME_NOT_SUPPORTED_INSIDE_THE_CODE_ELEMENT, AXIS2_FAILURE); return AXIS2_FAILURE; } } else if (axutil_strcmp (parent_localname, AXIOM_SOAP12_SOAP_FAULT_REASON_LOCAL_NAME) == 0) { if (axutil_strcmp (ele_localname, AXIOM_SOAP12_SOAP_FAULT_TEXT_LOCAL_NAME) == 0) { axiom_soap_fault_text_t *soap_fault_text = NULL; axiom_soap_fault_reason_t *fault_reason = NULL; soap_fault_text = axiom_soap_fault_text_create(env); if (!soap_fault_text) { return AXIS2_FAILURE; } axiom_soap_fault_text_set_base_node(soap_fault_text, env, om_ele_node); fault_reason = axiom_soap_fault_get_reason(soap_fault, env); if (!fault_reason) { return AXIS2_FAILURE; } axiom_soap_fault_reason_add_soap_fault_text(fault_reason, env, soap_fault_text); builder_helper->reason_processing = AXIS2_FALSE; axiom_soap_builder_set_bool_processing_mandatory_fault_elements (builder_helper->soap_builder, env, AXIS2_FALSE); } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_THIS_LOCALNAME_IS_NOT_SUPPORTED_INSIDE_THE_REASON_ELEMENT, AXIS2_FAILURE); return AXIS2_FAILURE; } } else if (axutil_strcmp (parent_localname, AXIOM_SOAP12_SOAP_FAULT_DETAIL_LOCAL_NAME) == 0) { axiom_soap_builder_set_processing_detail_elements(builder_helper-> soap_builder, env, AXIS2_TRUE); if (!(builder_helper->detail_element_names)) { builder_helper->detail_element_names = axutil_array_list_create(env, 20); } axutil_array_list_add(builder_helper->detail_element_names, env, ele_localname); } else { return AXIS2_FAILURE; } } else if (element_level > 5) { axiom_node_t *parent_node = NULL; axiom_element_t *parent_ele = NULL; axis2_char_t *parent_localname = NULL; parent_node = axiom_node_get_parent(om_ele_node, env); if (!parent_node) { return AXIS2_FAILURE; } parent_ele = (axiom_element_t *) axiom_node_get_data_element(parent_node, env); if (!parent_ele) { return AXIS2_FAILURE; } parent_localname = axiom_element_get_localname(parent_ele, env); if (!parent_localname) { return AXIS2_FAILURE; } if (axutil_strcmp (parent_localname, AXIOM_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME) == 0) { if (axutil_strcmp (ele_localname, AXIOM_SOAP12_SOAP_FAULT_VALUE_LOCAL_NAME) == 0) { if (builder_helper->subcode_value_present) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MULTIPLE_SUB_CODE_VALUES_ENCOUNTERED, AXIS2_FAILURE); return AXIS2_FAILURE; } else { axiom_soap_fault_sub_code_t *sub_code = NULL; axiom_soap_fault_code_t *code = NULL; axiom_soap_fault_value_t *value = NULL; code = axiom_soap_fault_get_code(soap_fault, env); if (!code) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "fault code null when it should not be null"); return AXIS2_FAILURE; } sub_code = axiom_soap_fault_code_get_sub_code(code, env); if (!sub_code) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "fault subcode null when it should not be null"); return AXIS2_FAILURE; } value = axiom_soap_fault_value_create(env); if (!value) { return AXIS2_FAILURE; } axiom_soap_fault_value_set_base_node(value, env, om_ele_node); axiom_soap_fault_sub_code_set_value(sub_code, env, value); builder_helper->subcode_value_present = AXIS2_TRUE; builder_helper->sub_sub_code_present = AXIS2_FALSE; builder_helper->sub_code_processing = AXIS2_FALSE; } } else if (axutil_strcmp (ele_localname, AXIOM_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME) == 0) { if (builder_helper->subcode_value_present) { if (!(builder_helper->sub_sub_code_present)) { axiom_soap_fault_code_t *fault_code = NULL; axiom_soap_fault_sub_code_t *parent_subcode = NULL; axiom_soap_fault_sub_code_t *subcode = NULL; subcode = axiom_soap_fault_sub_code_create(env); if (!subcode) { return AXIS2_FAILURE; } axiom_soap_fault_sub_code_set_base_node(subcode, env, om_ele_node); fault_code = axiom_soap_fault_get_code(soap_fault, env); if (!fault_code) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "fault code null when it should not be null"); return AXIS2_FAILURE; } parent_subcode = axiom_soap_fault_code_get_sub_code(fault_code, env); if (!parent_subcode) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "fault subcode null when it should not be null"); return AXIS2_FAILURE; } axiom_soap_fault_sub_code_set_sub_code(parent_subcode, env, subcode); builder_helper->subcode_value_present = AXIS2_FALSE; builder_helper->sub_sub_code_present = AXIS2_TRUE; builder_helper->sub_code_processing = AXIS2_TRUE; } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MULTIPLE_SUB_CODE_VALUES_ENCOUNTERED, AXIS2_FAILURE); return AXIS2_FAILURE; } } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_FAULT_VALUE_SHOULD_BE_PRESENT_BEFORE_SUB_CODE, AXIS2_FAILURE); return AXIS2_FAILURE; } } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_THIS_LOCALNAME_IS_NOT_SUPPORTED_INSIDE_THE_SUB_CODE_ELEMENT, AXIS2_FAILURE); return AXIS2_FAILURE; } } else if (axiom_soap_builder_is_processing_detail_elements (builder_helper->soap_builder, env)) { int detail_element_level = 0; axis2_bool_t local_name_exists = AXIS2_FALSE; int i = 0; if (!(builder_helper->detail_element_names)) { return AXIS2_FAILURE; } for (i = 0; i < axutil_array_list_size(builder_helper->detail_element_names, env); i++) { if (axutil_strcmp (parent_localname, axutil_array_list_get(builder_helper->detail_element_names, env, i)) == 0) { local_name_exists = AXIS2_TRUE; detail_element_level = i + 1; } } if (local_name_exists) { axutil_array_list_add(builder_helper->detail_element_names, env, ele_localname); } else { return AXIS2_FAILURE; } } } return AXIS2_SUCCESS; }
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; }