void fts_xml_repr_free(fts_xml_repr_t* self, const axutil_env_t* env) { if (self) { axiom_node_free_tree(self->node, env); free(self); } }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axiom_stax_builder_discard_current_element( axiom_stax_builder_t * om_builder, const axutil_env_t * env) { axiom_node_t *element = NULL; axiom_node_t *prev_node = NULL; axiom_node_t *parent = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); element = om_builder->lastnode; if(axiom_node_is_complete(element, env) || !(om_builder->cache)) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_BUILDER_STATE_CANNOT_DISCARD, AXIS2_FAILURE); return AXIS2_FAILURE; } om_builder->cache = AXIS2_FALSE; do { while(axiom_xml_reader_next(om_builder->parser, env) != AXIOM_XML_READER_END_ELEMENT) ; } while(!(axiom_node_is_complete(element, env))); /*All children of this element is pulled now */ prev_node = axiom_node_get_previous_sibling(element, env); if(prev_node) { axiom_node_free_tree(axiom_node_get_next_sibling(prev_node, env), env); axiom_node_set_next_sibling(prev_node, env, NULL); } else { parent = axiom_node_get_parent(element, env); axiom_node_free_tree(axiom_node_get_first_child(parent, env), env); axiom_node_set_first_child(parent, env, NULL); om_builder->lastnode = parent; } om_builder->cache = AXIS2_TRUE; return AXIS2_SUCCESS; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL oxs_xml_enc_decrypt_node( const axutil_env_t *env, oxs_ctx_t * enc_ctx, axiom_node_t *enc_type_node, axiom_node_t **decrypted_node) { axiom_node_t *deserialized_node = NULL; axiom_node_t *parent_of_enc_node = NULL; oxs_buffer_t *result_buf = NULL; axis2_char_t *decrypted_data = NULL;/*Can be either am XML-Element or XML-Content*/ axis2_status_t status = AXIS2_FAILURE; /*Create an empty buffer for results*/ result_buf = oxs_buffer_create(env); /*Decrypt*/ status = oxs_xml_enc_decrypt_data(env, enc_ctx, enc_type_node, result_buf); if(AXIS2_FAILURE == status) { oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_ENCRYPT_FAILED, "Data encryption failed"); return AXIS2_FAILURE; } decrypted_data = axutil_strmemdup(oxs_buffer_get_data(result_buf, env), oxs_buffer_get_size( result_buf, env), env); /*De-serialize the decrypted content to build the node*/ deserialized_node = (axiom_node_t*)oxs_axiom_deserialize_node(env, decrypted_data); if(!deserialized_node) { oxs_error(env, OXS_ERROR_LOCATION, OXS_ERROR_ENCRYPT_FAILED, "Cannot deserialize a node from the content.\n%s", decrypted_data); return AXIS2_FAILURE; } /*Assign deserialized_node to the reference passed*/ *decrypted_node = deserialized_node; /*Replace the encrypted node with the de-serialized node*/ parent_of_enc_node = axiom_node_get_parent(enc_type_node, env); axiom_node_insert_sibling_after(enc_type_node, env, deserialized_node); axiom_node_free_tree(enc_type_node, env); enc_type_node = NULL; /*Free result buf*/ oxs_buffer_free(result_buf, env); result_buf = NULL; AXIS2_FREE(env->allocator, decrypted_data); decrypted_data = NULL; return AXIS2_SUCCESS; }
/** * Delete the first child of 'root_node' with a matching 'local_name'. * @param env * @param root_node * @param local_name */ void rp_delete_named_child( const axutil_env_t * env, axiom_node_t *root_node, const axis2_char_t *local_name ) { axiom_node_t *del_node = rp_find_named_child(env, root_node, local_name, 1); if (NULL != del_node) { axiom_node_detach (del_node, env); axiom_node_free_tree (del_node, env); } }
AXIS2_EXTERN axis2_status_t AXIS2_CALL neethi_assertion_set_node( neethi_assertion_t *neethi_assertion, const axutil_env_t *env, axiom_node_t * node) { if(neethi_assertion->node) { axiom_node_free_tree(neethi_assertion->node, env); neethi_assertion->node = NULL; } if(node) { neethi_assertion->node = axiom_util_clone_node(env, node); } return AXIS2_SUCCESS; }
AXIS2_EXTERN void AXIS2_CALL neethi_assertion_free( neethi_assertion_t *neethi_assertion, const axutil_env_t *env) { if(neethi_assertion) { if(neethi_assertion->policy_components) { int i = 0; for(i = 0; i < axutil_array_list_size(neethi_assertion->policy_components, env); i++) { neethi_operator_t *operator = NULL; operator = (neethi_operator_t *)axutil_array_list_get( neethi_assertion->policy_components, env, i); if(operator) neethi_operator_free(operator, env); operator = NULL; } axutil_array_list_free(neethi_assertion->policy_components, env); neethi_assertion->policy_components = NULL; } if(neethi_assertion->value) { if(neethi_assertion->free_func) { neethi_assertion->free_func(neethi_assertion->value, env); } } if(neethi_assertion->node) { axiom_node_free_tree(neethi_assertion->node, env); neethi_assertion->node = NULL; } AXIS2_FREE(env->allocator, neethi_assertion); neethi_assertion = NULL; } return; }
/** * resetter for extraElement */ axis2_status_t AXIS2_CALL adb_CanonicalizationMethodType_reset_extraElement( adb_CanonicalizationMethodType_t* _CanonicalizationMethodType, const axutil_env_t *env) { int i = 0; int count = 0; void *element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _CanonicalizationMethodType, AXIS2_FAILURE); if (_CanonicalizationMethodType->property_extraElement != NULL) { count = axutil_array_list_size(_CanonicalizationMethodType->property_extraElement, env); for(i = 0; i < count; i ++) { element = axutil_array_list_get(_CanonicalizationMethodType->property_extraElement, env, i); if(element != NULL) { axiom_node_free_tree ((axiom_node_t*)element, env); element = NULL; } } axutil_array_list_free(_CanonicalizationMethodType->property_extraElement, env); } _CanonicalizationMethodType->is_valid_extraElement = AXIS2_FALSE; return AXIS2_SUCCESS; }
AXIS2_EXTERN remote_registry_resource_t *AXIS2_CALL remote_registry_resource_create_from_feed( const axutil_env_t *env, axis2_char_t *buffer, axis2_char_t *content_type) { axiom_node_t *root = NULL; axiom_element_t *root_ele = NULL; remote_registry_resource_t *resource = NULL; if(!buffer) { return NULL; } root = axiom_node_create_from_buffer(env, buffer); if(!root) { return NULL; } resource = remote_registry_resource_create(env); if(!resource) { axiom_node_free_tree(root, env); return NULL; } /* distinguising whether it s a collection or entry */ if(!axutil_strcmp(content_type, REMOTE_REGISTRY_FEED_ENTRY_CONTENT_TYPE)) { resource->is_collection = 0; } else { resource->is_collection = 1; } remote_registry_resource_load_metadata_from_feed_node(env, resource, root); return resource; }
/*public functions*/ AXIS2_EXTERN axis2_status_t AXIS2_CALL oxs_xml_enc_encrypt_node( const axutil_env_t *env, oxs_ctx_t * enc_ctx, axiom_node_t *node, axiom_node_t **enc_type_node, axiom_node_t *security_token_reference) { axis2_char_t *serialized_data = NULL; oxs_buffer_t *serialized_buf = NULL; axis2_status_t ret = AXIS2_FAILURE; /*Serialize node*/ /*serialized_data = axiom_node_to_string(node, env);*/ serialized_data = axiom_node_to_string_non_optimized(node, env); serialized_buf = oxs_buffer_create(env); ret = oxs_buffer_populate(serialized_buf, env, (unsigned char *)serialized_data, axutil_strlen( serialized_data)); /*We call encrypt_data*/ ret = oxs_xml_enc_encrypt_data(env, enc_ctx, serialized_buf, enc_type_node, security_token_reference); /*Remove the node from the parent*/ if(AXIS2_SUCCESS == ret) { axiom_node_free_tree(node, env); node = NULL; } /*Free*/ oxs_buffer_free(serialized_buf, env); serialized_buf = NULL; AXIS2_FREE(env->allocator, serialized_data); serialized_data = NULL; /*Return success*/ return AXIS2_SUCCESS; }
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; }
/** * Set the ith element of extraElement. */ axis2_status_t AXIS2_CALL adb_CanonicalizationMethodType_set_extraElement_at( adb_CanonicalizationMethodType_t* _CanonicalizationMethodType, const axutil_env_t *env, int i, axiom_node_t* arg_extraElement) { void *element = NULL; int size = 0; int j; int non_nil_count; axis2_bool_t non_nil_exists = AXIS2_FALSE; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _CanonicalizationMethodType, AXIS2_FAILURE); if( _CanonicalizationMethodType->is_valid_extraElement && _CanonicalizationMethodType->property_extraElement && arg_extraElement == (axiom_node_t*)axutil_array_list_get(_CanonicalizationMethodType->property_extraElement, env, i)) { return AXIS2_SUCCESS; } if(NULL != arg_extraElement) { non_nil_exists = AXIS2_TRUE; } else { if(_CanonicalizationMethodType->property_extraElement != NULL) { size = axutil_array_list_size(_CanonicalizationMethodType->property_extraElement, env); for(j = 0, non_nil_count = 0; j < size; j ++ ) { if(i == j) continue; if(NULL != axutil_array_list_get(_CanonicalizationMethodType->property_extraElement, env, i)) { non_nil_count ++; non_nil_exists = AXIS2_TRUE; if(non_nil_count >= 0) { break; } } } } } if(_CanonicalizationMethodType->property_extraElement == NULL) { _CanonicalizationMethodType->property_extraElement = axutil_array_list_create(env, 10); } /* check whether there already exist an element */ element = axutil_array_list_get(_CanonicalizationMethodType->property_extraElement, env, i); if(NULL != element) { axiom_node_free_tree ((axiom_node_t*)element, env); } if(!non_nil_exists) { _CanonicalizationMethodType->is_valid_extraElement = AXIS2_FALSE; axutil_array_list_set(_CanonicalizationMethodType->property_extraElement , env, i, NULL); return AXIS2_SUCCESS; } axutil_array_list_set(_CanonicalizationMethodType->property_extraElement , env, i, arg_extraElement); _CanonicalizationMethodType->is_valid_extraElement = AXIS2_TRUE; return AXIS2_SUCCESS; }
/** * Set extraElement to nill at i */ axis2_status_t AXIS2_CALL adb_CanonicalizationMethodType_set_extraElement_nil_at( adb_CanonicalizationMethodType_t* _CanonicalizationMethodType, const axutil_env_t *env, int i) { void *element = NULL; int size = 0; int j; axis2_bool_t non_nil_exists = AXIS2_FALSE; int k = 0; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _CanonicalizationMethodType, AXIS2_FAILURE); if(_CanonicalizationMethodType->property_extraElement == NULL || _CanonicalizationMethodType->is_valid_extraElement == AXIS2_FALSE) { non_nil_exists = AXIS2_FALSE; } else { size = axutil_array_list_size(_CanonicalizationMethodType->property_extraElement, env); for(j = 0, k = 0; j < size; j ++ ) { if(i == j) continue; if(NULL != axutil_array_list_get(_CanonicalizationMethodType->property_extraElement, env, i)) { k ++; non_nil_exists = AXIS2_TRUE; if( k >= 0) { break; } } } } if( k < 0) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Size of the array of extraElement is beinng set to be smaller than the specificed number of minOccurs(0)"); return AXIS2_FAILURE; } if(_CanonicalizationMethodType->property_extraElement == NULL) { _CanonicalizationMethodType->is_valid_extraElement = AXIS2_FALSE; return AXIS2_SUCCESS; } /* check whether there already exist an element */ element = axutil_array_list_get(_CanonicalizationMethodType->property_extraElement, env, i); if(NULL != element) { axiom_node_free_tree ((axiom_node_t*)element, env); } if(!non_nil_exists) { _CanonicalizationMethodType->is_valid_extraElement = AXIS2_FALSE; axutil_array_list_set(_CanonicalizationMethodType->property_extraElement , env, i, NULL); return AXIS2_SUCCESS; } axutil_array_list_set(_CanonicalizationMethodType->property_extraElement , env, i, NULL); return AXIS2_SUCCESS; }
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; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axiom_soap_header_remove_header_block( axiom_soap_header_t * soap_header, const axutil_env_t * env, axutil_qname_t * qname) { axis2_char_t *qn_localname = NULL; axis2_char_t *qname_ns = NULL; axis2_char_t *qname_prefix = NULL; axutil_hash_index_t *hi = NULL; AXIS2_PARAM_CHECK(env->error, qname, AXIS2_FAILURE); qn_localname = axutil_qname_get_localpart(qname, env); qname_ns = axutil_qname_get_uri(qname, env); qname_prefix = axutil_qname_get_prefix(qname, env); if(!soap_header->header_blocks) { return AXIS2_FAILURE; } for(hi = axutil_hash_first(soap_header->header_blocks, env); hi; hi = axutil_hash_next(env, hi)) { const void *key = NULL; void *val = NULL; axutil_hash_this(hi, &key, NULL, &val); if(val) { axiom_soap_header_block_t *header_block = NULL; axiom_element_t *ele = NULL; axiom_node_t *node = NULL; header_block = (axiom_soap_header_block_t *)val; node = axiom_soap_header_block_get_base_node(header_block, env); if(node) { axutil_qname_t *element_qname = NULL; ele = (axiom_element_t *)axiom_node_get_data_element(node, env); element_qname = axiom_element_get_qname(ele, env, node); if(axiom_soap_header_qname_matches(env, element_qname, qname) == AXIS2_TRUE) { axiom_node_detach(node, env); /* axiom_node_free_tree(node, env); */ axutil_hash_set(soap_header->header_blocks, key, AXIS2_HASH_KEY_STRING, NULL); axiom_soap_header_block_free(header_block, env); axiom_node_free_tree(node, env); break; } } } } if(hi) { AXIS2_FREE(env->allocator, hi); } return AXIS2_SUCCESS; }
//----------------------------------------------------------------------------- void sp_update_lineage( const axutil_env_t * env, const sp_props *props, axiom_node_t *return_node, axiom_node_t *request_node, time_t request_time) { axiom_node_t *eom_node = rp_find_named_child(env, return_node, "EOMetadata", 1); if (NULL == eom_node) { rp_log_error(env, "*Warning S2P(%s:%d): %s node not found.\n", __FILE__, __LINE__, "EOMetadata"); return; } time_t lineage_time = 0; axiom_node_t *curr_lineage = sp_latest_named(env, eom_node, "lineage", &lineage_time); // TODO: should improve handling of insignificant whitespace. // grab some whitespace for future use axiom_node_t *lin_whsp_node = sp_get_last_text_node(curr_lineage, env); axiom_node_t *eom_whsp_node = sp_get_last_text_node(eom_node, env); const axis2_char_t *lin_whsp_str = sp_get_text_text(lin_whsp_node, env); const axis2_char_t *eom_whsp_str = sp_get_text_text(eom_whsp_node, env); int whspace_indent = SP_DEFAULT_WHSPACE; if (NULL != lin_whsp_str && NULL != eom_whsp_str) { whspace_indent = axutil_strlen(lin_whsp_str) - axutil_strlen(eom_whsp_str); if (whspace_indent < 0 || whspace_indent >12) { rp_log_error(env, "*Warning S2P: funny whitespace indent (%d) calculated.\n", whspace_indent); whspace_indent = SP_DEFAULT_WHSPACE; } } axis2_char_t curr_whspace[SP_MAX_LOCAL_STR_LEN]; strncpy(curr_whspace, lin_whsp_str, SP_MAX_LOCAL_STR_LEN-1); curr_whspace[SP_MAX_LOCAL_STR_LEN-1] = '\0'; // The most recent Lineage data is deleted only if it has been added // in the time period since we started processing this request. if (NULL != curr_lineage && lineage_time >= request_time) { // OK to delete lineage axiom_node_detach (curr_lineage, env); axiom_node_free_tree (curr_lineage, env); curr_lineage = NULL; lin_whsp_node = NULL; lin_whsp_str = NULL; } else { sp_add_whspace(env, eom_node, curr_whspace); } // Add a new lineage. here is an example: // <wcseo:lineage> // <wcseo:referenceGetCoverage> // <ows:ServiceReference xlink:href="http://www.someWCS.org"> // <ows:RequestMessage> // <wcs:GetCoverage service="WCS" version="2.0.0"> // <wcs:format>application/gml+xml</wcs:format> // <wcs:CoverageId>someEOCoverage1</wcs:CoverageId> // </wcs:GetCoverage> // </ows:RequestMessage> // </ows:ServiceReference> // </wcseo:referenceGetCoverage> // <gml:timePosition>2011-08-24T14:18:52Z</gml:timePosition> // </wcseo:lineage> // <wcseo:lineage> axiom_node_t *lineage_node = rp_add_child_el(env, eom_node, "lineage", NULL); sp_inc_whspace(curr_whspace, whspace_indent); sp_add_whspace(env, lineage_node, curr_whspace); // comment axiom_node_t *comment = axiom_node_create(env); axiom_comment_create ( env, lineage_node, "POST GetCoverage request added by SOAP-TO-POST proxy.", &comment); //<wcseo:referenceGetCoverage> axiom_node_t *ref_g1_node = rp_add_child_el(env, lineage_node, "referenceGetCoverage", curr_whspace); // <ows:ServiceReference xlink:href="http://www.someWCS.org"> sp_inc_whspace(curr_whspace, whspace_indent); sp_add_whspace(env, ref_g1_node, curr_whspace); axiom_namespace_t *ows_ns = sp_find_or_create_ns(env, return_node, SP_OWS_NAMESPACE_STR, "ows"); axiom_node_t *service_ref_node = axiom_node_create(env); axiom_element_t *service_ref_el = axiom_element_create( env, ref_g1_node, "ServiceReference", ows_ns, &service_ref_node); axiom_namespace_t *xlink_ns = sp_find_or_create_ns( env, return_node, SP_XLINK_NAMESPACE_STR, "xlink"); axiom_attribute_t *attr = axiom_attribute_create (env, "type", "simple", xlink_ns); axiom_element_add_attribute (service_ref_el, env, attr, service_ref_node); attr = axiom_attribute_create (env, "href", rp_getSoapOpsURL(env, props), xlink_ns); axiom_element_add_attribute (service_ref_el, env, attr, service_ref_node); //<ows:RequestMessage> axiom_node_t *req_msg_node = rp_add_child_el(env, service_ref_node, "RequestMessage", curr_whspace); sp_inc_whspace(curr_whspace, whspace_indent); // Detach the request GetCoverage element from its parent // and attach it here. axiom_node_t *gc_node = rp_find_named_node(env, request_node, "GetCoverage", 1); if (gc_node) { // TODO - pretty-up the the indentation to match current. sp_add_whspace(env, req_msg_node, curr_whspace); axiom_node_detach (gc_node, env); axiom_node_add_child (req_msg_node, env, gc_node); } // Adjust the indentation of closing tags sp_inc_whspace(curr_whspace, -whspace_indent); sp_add_whspace(env, req_msg_node, curr_whspace); sp_inc_whspace(curr_whspace, -whspace_indent); sp_add_whspace(env, service_ref_node, curr_whspace); sp_inc_whspace(curr_whspace, -whspace_indent); sp_add_whspace(env, ref_g1_node, curr_whspace); sp_inc_whspace(curr_whspace, -whspace_indent); //<gml:timePosition>2011-08-24T14:18:52Z</gml:timePosition> sp_add_whspace(env, lineage_node, curr_whspace); axiom_namespace_t *gml_ns = sp_find_or_create_ns( env, return_node, SP_GML_NAMESPACE_STR, "gml"); axiom_node_t *time_pos_node = axiom_node_create(env); axiom_element_t *time_pos_el = axiom_element_create( env, lineage_node, "timePosition", gml_ns, &time_pos_node); char tmbuf[22]; sp_time_str(tmbuf, time(NULL)); axiom_element_set_text(time_pos_el, env, tmbuf, time_pos_node); // Adjust the indentation of remaining closing tags sp_inc_whspace(curr_whspace, -whspace_indent); sp_add_whspace(env, lineage_node, curr_whspace); // Adjust whitespace before the element // that follows our new lineage element, whatever it may be. sp_add_whspace(env, eom_node, eom_whsp_str); // Delete the whitespace before any our insertions. axiom_node_detach (eom_whsp_node, env); axiom_node_free_tree (eom_whsp_node, env); }