AXIS2_EXTERN axis2_status_t AXIS2_CALL axis2_options_set_fault_to( axis2_options_t * options, const axutil_env_t * env, axis2_endpoint_ref_t * fault_to) { axis2_msg_info_headers_set_fault_to(options->msg_info_headers, env, fault_to); return AXIS2_SUCCESS; }
axis2_status_t axis2_addr_in_extract_addr_params( const axutil_env_t * env, axiom_soap_header_t * soap_header, axis2_msg_info_headers_t ** msg_info_headers_p, axutil_array_list_t * addr_headers, const axis2_char_t * addr_ns_str, axis2_msg_ctx_t * msg_ctx) { axutil_hash_t *header_block_ht = NULL; axutil_hash_index_t *hash_index = NULL; axis2_msg_info_headers_t *msg_info_headers = *(msg_info_headers_p); axis2_status_t status = AXIS2_SUCCESS; axis2_bool_t to_found = AXIS2_FALSE; axis2_bool_t reply_to_found = AXIS2_FALSE; axis2_bool_t fault_to_found = AXIS2_FALSE; axis2_bool_t action_found = AXIS2_FALSE; axis2_bool_t msg_id_found = AXIS2_FALSE; AXIS2_PARAM_CHECK(env->error, soap_header, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, msg_info_headers_p, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, addr_headers, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, addr_ns_str, AXIS2_FAILURE); if (!msg_info_headers) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No messgae info header. Creating new"); msg_info_headers = axis2_msg_info_headers_create(env, NULL, NULL); if (!msg_info_headers) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MSG_INFO_HEADERS, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No message information headers available"); return AXIS2_FAILURE; } } header_block_ht = axiom_soap_header_get_all_header_blocks(soap_header, env); if (!header_block_ht) { return AXIS2_FAILURE; } /* Iterate thru header blocks */ for (hash_index = axutil_hash_first(header_block_ht, env); hash_index; hash_index = axutil_hash_next(env, hash_index)) { void *hb = NULL; axiom_soap_header_block_t *header_block = NULL; axiom_node_t *header_block_node = NULL; axiom_element_t *header_block_ele = NULL; axis2_char_t *ele_localname = NULL; axis2_endpoint_ref_t *epr = NULL; axis2_char_t *role = NULL; axutil_hash_this(hash_index, NULL, NULL, &hb); header_block = (axiom_soap_header_block_t *) hb; header_block_node = axiom_soap_header_block_get_base_node(header_block, env); header_block_ele = (axiom_element_t *) axiom_node_get_data_element(header_block_node, env); ele_localname = axiom_element_get_localname(header_block_ele, env); role = axiom_soap_header_block_get_role(header_block, env); if (role && !axutil_strcmp(role, AXIOM_SOAP12_SOAP_ROLE_NONE)) { /* Role is none, no need of processing */ continue; } if (!axutil_strcmp(ele_localname, AXIS2_WSA_TO)) { /* Here the addressing epr overidde what ever already there in the message context */ epr = axis2_endpoint_ref_create(env, axiom_element_get_text (header_block_ele, env, header_block_node)); if (AXIS2_TRUE == to_found) { /* Duplicate To */ axis2_addr_in_create_fault_envelope(env, AXIS2_WSA_PREFIX_TO, addr_ns_str, msg_ctx); status = AXIS2_FAILURE; continue; } axis2_msg_info_headers_set_to(msg_info_headers, env, epr); axis2_addr_in_extract_to_epr_ref_params(env, epr, soap_header, addr_ns_str); axiom_soap_header_block_set_processed(header_block, env); to_found = AXIS2_TRUE; } else if (!axutil_strcmp(ele_localname, AXIS2_WSA_FROM)) { epr = axis2_msg_info_headers_get_from(msg_info_headers, env); if (!epr) { /* The address is not known now. Pass the empty string and fill this once the element under this is processed. */ epr = axis2_endpoint_ref_create(env, ""); axis2_msg_info_headers_set_from(msg_info_headers, env, epr); } axis2_addr_in_extract_epr_information(env, header_block, epr, addr_ns_str); axiom_soap_header_block_set_processed(header_block, env); } else if (!axutil_strcmp(ele_localname, AXIS2_WSA_REPLY_TO)) { epr = axis2_msg_info_headers_get_reply_to(msg_info_headers, env); if (reply_to_found == AXIS2_TRUE) { /* Duplicate Reply To */ axis2_addr_in_create_fault_envelope(env, AXIS2_WSA_PREFIX_REPLY_TO, addr_ns_str, msg_ctx); status = AXIS2_FAILURE; continue; } if (!epr) { epr = axis2_endpoint_ref_create(env, ""); axis2_msg_info_headers_set_reply_to(msg_info_headers, env, epr); } axis2_addr_in_extract_epr_information(env, header_block, epr, addr_ns_str); axiom_soap_header_block_set_processed(header_block, env); reply_to_found = AXIS2_TRUE; } else if (!axutil_strcmp(ele_localname, AXIS2_WSA_FAULT_TO)) { epr = axis2_msg_info_headers_get_fault_to(msg_info_headers, env); if (fault_to_found == AXIS2_TRUE) { /* Duplicate Fault To */ axis2_addr_in_create_fault_envelope(env, AXIS2_WSA_PREFIX_FAULT_TO, addr_ns_str, msg_ctx); status = AXIS2_FAILURE; axis2_msg_info_headers_set_fault_to(msg_info_headers, env, NULL); continue; } if (!epr) { epr = axis2_endpoint_ref_create(env, ""); axis2_msg_info_headers_set_fault_to(msg_info_headers, env, epr); } axis2_addr_in_extract_epr_information(env, header_block, epr, addr_ns_str); axiom_soap_header_block_set_processed(header_block, env); fault_to_found = AXIS2_TRUE; } else if (!axutil_strcmp(ele_localname, AXIS2_WSA_MESSAGE_ID)) { axis2_char_t *text = NULL; if (msg_id_found == AXIS2_TRUE) { /* Duplicate Message ID */ axis2_addr_in_create_fault_envelope(env, AXIS2_WSA_PREFIX_MESSAGE_ID, addr_ns_str, msg_ctx); status = AXIS2_FAILURE; continue; } text = axiom_element_get_text(header_block_ele, env, header_block_node); axis2_msg_info_headers_set_in_message_id(msg_info_headers, env, text); axiom_soap_header_block_set_processed(header_block, env); msg_id_found = AXIS2_TRUE; } else if (!axutil_strcmp(ele_localname, AXIS2_WSA_ACTION)) { axis2_char_t *text = NULL; if (action_found == AXIS2_TRUE) { /* Duplicate Action */ axis2_addr_in_create_fault_envelope(env, AXIS2_WSA_PREFIX_ACTION, addr_ns_str, msg_ctx); status = AXIS2_FAILURE; continue; } text = axiom_element_get_text(header_block_ele, env, header_block_node); axis2_msg_info_headers_set_action(msg_info_headers, env, text); axiom_soap_header_block_set_processed(header_block, env); action_found = AXIS2_TRUE; } else if (!axutil_strcmp(ele_localname, AXIS2_WSA_RELATES_TO)) { axis2_char_t *address = NULL; axutil_qname_t *rqn = NULL; axiom_attribute_t *relationship_type = NULL; const axis2_char_t *relationship_type_default_value = NULL; const axis2_char_t *relationship_type_value = NULL; axis2_relates_to_t *relates_to = NULL; if (!axutil_strcmp(AXIS2_WSA_NAMESPACE_SUBMISSION, addr_ns_str)) { relationship_type_default_value = AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE_SUBMISSION; } else { relationship_type_default_value = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION; } rqn = axutil_qname_create(env, AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE, NULL, NULL); relationship_type = axiom_element_get_attribute(header_block_ele, env, rqn); if (!relationship_type) { relationship_type_value = AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE_SUBMISSION; } else { relationship_type_value = axiom_attribute_get_value(relationship_type, env); } address = axiom_element_get_text(header_block_ele, env, header_block_node); relates_to = axis2_relates_to_create(env, address, relationship_type_value); axis2_msg_info_headers_set_relates_to(msg_info_headers, env, relates_to); axiom_soap_header_block_set_processed(header_block, env); axutil_qname_free(rqn, env); } } /* If an action is not found, it's a false*/ if (action_found == AXIS2_FALSE) { axis2_addr_in_create_fault_envelope(env, AXIS2_WSA_PREFIX_ACTION, addr_ns_str, msg_ctx); status = AXIS2_FAILURE; } return status; }
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; }