AXIS2_EXTERN axis2_char_t *AXIS2_CALL axiom_soap_fault_text_get_lang( axiom_soap_fault_text_t * fault_text, const axutil_env_t * env) { axiom_element_t *om_ele = NULL; axutil_qname_t *tmp_qname = NULL; if(!fault_text->om_ele_node) { return NULL; } om_ele = (axiom_element_t *)axiom_node_get_data_element(fault_text->om_ele_node, env); if(!om_ele) { return NULL; } if(!(fault_text->lang_attribute)) { /* this logic need to be rechecked */ tmp_qname = axutil_qname_create(env, AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME, AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_NS_URI, AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_NS_PREFIX); fault_text->lang_attribute = axiom_element_get_attribute(om_ele, env, tmp_qname); axutil_qname_free(tmp_qname, env); } if(fault_text->lang_attribute) { return axiom_attribute_get_value(fault_text->lang_attribute, env); } else return NULL; }
axis2_status_t axis2_addr_in_extract_ref_params( const axutil_env_t * env, axiom_soap_header_t * soap_header, axis2_msg_info_headers_t * msg_info_headers) { axutil_hash_t *header_block_ht = NULL; axutil_hash_index_t *hash_index = NULL; axutil_qname_t *wsa_qname = NULL; AXIS2_PARAM_CHECK(env->error, soap_header, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, msg_info_headers, AXIS2_FAILURE); header_block_ht = axiom_soap_header_get_all_header_blocks(soap_header, env); if(!header_block_ht) { return AXIS2_FAILURE; } wsa_qname = axutil_qname_create(env, AXIS2_WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE, AXIS2_WSA_NAMESPACE, NULL); 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; 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); if(header_block_node && (axiom_node_get_node_type(header_block_node, env) == AXIOM_ELEMENT)) { axiom_attribute_t *om_attr = NULL; axis2_char_t *attr_value = NULL; header_block_ele = (axiom_element_t *)axiom_node_get_data_element(header_block_node, env); om_attr = axiom_element_get_attribute(header_block_ele, env, wsa_qname); if(om_attr) { attr_value = axiom_attribute_get_value(om_attr, env); if(!axutil_strcmp(attr_value, AXIS2_WSA_TYPE_ATTRIBUTE_VALUE)) { axis2_msg_info_headers_add_ref_param(msg_info_headers, env, header_block_node); } } } } axutil_qname_free(wsa_qname, env); return AXIS2_SUCCESS; }
axiom_node_t * axis2_listener_notify(const axutil_env_t *env, axiom_node_t *node) { axiom_node_t *pres_node = NULL; axiom_node_t *status_node = NULL; axiom_element_t *body_elem = NULL; axiom_element_t *pres_elem = NULL; axiom_element_t *status_elem = NULL; axiom_attribute_t *attr_from = NULL; axutil_qname_t *qname= NULL; axis2_char_t *str = NULL; axis2_char_t *from = NULL; axis2_char_t *status = NULL; AXIS2_ENV_CHECK(env, NULL); str = axiom_node_to_string(node, env); body_elem = axiom_node_get_data_element(node, env); qname = axutil_qname_create(env, "presence", NULL, NULL); pres_elem = axiom_element_get_first_child_with_qname(body_elem, env, qname, node, &pres_node); axutil_qname_free(qname, env); if (pres_elem) { qname = axutil_qname_create(env, "from", NULL, NULL); attr_from = axiom_element_get_attribute(pres_elem, env, qname); axutil_qname_free(qname, env); if (attr_from) { from = axiom_attribute_get_value(attr_from, env); } qname = axutil_qname_create(env, "status", NULL, NULL); status_elem = axiom_element_get_first_child_with_qname(pres_elem, env, qname, pres_node, &status_node); axutil_qname_free(qname, env); if (status_elem) { status = axiom_element_get_text(status_elem, env, status_node); } } printf("\n************************************************************\n"); printf("Received presence notification:\n\n"); printf("From: %s\n", from); printf("Status: %s\n", status); printf("\nFull notification:\n%s\n\n", str); return NULL; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axis2_svc_grp_builder_process_module_refs( axis2_svc_grp_builder_t * svc_grp_builder, const axutil_env_t * env, axiom_children_qname_iterator_t * module_refs, axis2_svc_grp_t * svc_grp) { AXIS2_PARAM_CHECK(env->error, module_refs, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, svc_grp, AXIS2_FAILURE); while(axiom_children_qname_iterator_has_next(module_refs, env)) { axiom_node_t *module_ref_node = NULL; axiom_element_t *module_ref_element = NULL; axiom_attribute_t *module_ref_att = NULL; axutil_qname_t *qref = NULL; module_ref_node = (axiom_node_t *)axiom_children_qname_iterator_next(module_refs, env); module_ref_element = axiom_node_get_data_element(module_ref_node, env); qref = axutil_qname_create(env, AXIS2_REF, NULL, NULL); module_ref_att = axiom_element_get_attribute(module_ref_element, env, qref); if(module_ref_att) { axis2_char_t *ref_name = NULL; axutil_qname_t *qrefname = NULL; axis2_module_desc_t *module = NULL; ref_name = axiom_attribute_get_value(module_ref_att, env); qrefname = axutil_qname_create(env, ref_name, NULL, NULL); module = axis2_dep_engine_get_module(axis2_desc_builder_get_dep_engine( svc_grp_builder->desc_builder, env), env, qrefname); if(!module) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MODULE_NOT_FOUND, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Module %s not found in deployment engine.", ref_name); return AXIS2_FAILURE; } else { axis2_svc_grp_add_module_ref(svc_grp, env, qrefname); } axutil_qname_free(qrefname, env); } axutil_qname_free(qref, env); } return AXIS2_SUCCESS; }
axis2_char_t * get_policy_ref( axiom_node_t * node, const axutil_env_t * env) { axiom_element_t *policy_element = NULL; axiom_children_iterator_t *children_iter = NULL; axiom_node_t *child_node = NULL; axutil_qname_t *qname = NULL; axis2_char_t *value = NULL; axis2_char_t *val = NULL; axiom_attribute_t *attr = NULL; policy_element = (axiom_element_t *) axiom_node_get_data_element(node, env); children_iter = axiom_element_get_children(policy_element, env, node); while (axiom_children_iterator_has_next(children_iter, env)) { child_node = axiom_children_iterator_next(children_iter, env); if (axiom_node_get_node_type(child_node, env) == AXIOM_ELEMENT) { policy_element = (axiom_element_t *) axiom_node_get_data_element(child_node, env); if (axutil_strcmp (axiom_element_get_localname(policy_element, env), "PolicyReference") == 0) { qname = axutil_qname_create(env, "URI", NULL, NULL); attr = axiom_element_get_attribute(policy_element, env, qname); if (attr) { value = axiom_attribute_get_value(attr, env); val = axutil_string_substring_starting_at(value, 1); return val; } } } } return NULL; }
axis2_status_t axis2_addr_in_extract_to_epr_ref_params( const axutil_env_t * env, axis2_endpoint_ref_t * to_epr, axiom_soap_header_t * soap_header, const axis2_char_t * addr_ns_str) { axutil_hash_t *header_blocks_ht = NULL; axutil_hash_index_t *hash_index = NULL; axutil_qname_t *is_ref_qn = NULL; AXIS2_PARAM_CHECK(env->error, to_epr, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, soap_header, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, addr_ns_str, AXIS2_FAILURE); header_blocks_ht = axiom_soap_header_get_all_header_blocks(soap_header, env); if (!header_blocks_ht) { return AXIS2_FAILURE; } is_ref_qn = axutil_qname_create(env, "IsReferenceParameter", addr_ns_str, NULL); if (!is_ref_qn) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create qname for %s", addr_ns_str); return AXIS2_FAILURE; } for (hash_index = axutil_hash_first(header_blocks_ht, env); hash_index; hash_index = axutil_hash_next(env, hash_index)) { axiom_element_t *header_block_ele = NULL; axiom_node_t *header_block_node = NULL; axiom_soap_header_block_t *header_block = NULL; void *hb = NULL; axiom_attribute_t *is_ref_param_attr = NULL; axis2_char_t *attr_value = NULL; axutil_hash_this(hash_index, NULL, NULL, &hb); if (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); is_ref_param_attr = axiom_element_get_attribute(header_block_ele, env, is_ref_qn); if (is_ref_param_attr) { attr_value = axiom_attribute_get_localname(is_ref_param_attr, env); if (!axutil_strcmp("true", attr_value)) { axis2_endpoint_ref_add_ref_param(to_epr, env, header_block_node); } } } } axutil_qname_free(is_ref_qn, env); 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; }
/** * Traverse thru the node and its children. Check if the element has the * given qname and has a id attribute equal to the given value. * @param env Environment. MUST NOT be NULL, * @param node the node to be searched * @param e_name element name * @param e_ns element namespace. If NULL doesn't consider the namespaces * @param attr_name the attribute name of the node * @param attr_val the attribute value of the node * @param attr_ns the attribute namespace. If NULL doesn't consider namespaces. * @return the node if found, else NULL */ AXIS2_EXTERN axiom_node_t* AXIS2_CALL oxs_axiom_get_first_node_by_name_and_attr_val( const axutil_env_t *env, axiom_node_t *node, axis2_char_t *e_name, axis2_char_t *e_ns, axis2_char_t *attr_name, axis2_char_t *attr_val, axis2_char_t *attr_ns) { axis2_char_t *attribute_value = NULL; axis2_char_t *localname = NULL; axiom_namespace_t *nmsp = NULL; axiom_element_t *element = NULL; axis2_bool_t element_match = AXIS2_FALSE; axiom_node_t *temp_node = NULL; if(axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) { return NULL; } element = axiom_node_get_data_element(node, env); localname = axiom_element_get_localname(element, env); if(localname && !axutil_strcmp(localname, e_name)) { element_match = AXIS2_TRUE; if(e_ns) { nmsp = axiom_element_get_namespace(element, env, node); if(nmsp) { axis2_char_t *namespacea = NULL; namespacea = axiom_namespace_get_uri(nmsp, env); if(axutil_strcmp(e_ns, namespacea)) { element_match = AXIS2_FALSE; } } } /* element is ok. So, we have to check the attribute value */ if(element_match) { if(attr_ns) { axiom_attribute_t *attr = NULL; axutil_qname_t *qname = axutil_qname_create(env, attr_name, attr_ns, NULL); attr = axiom_element_get_attribute(element, env, qname); if(attr) { attribute_value = axiom_attribute_get_value(attr, env); } axutil_qname_free(qname, env); } else { attribute_value = axiom_element_get_attribute_value_by_name( element, env, attr_name); } } if (attribute_value && !axutil_strcmp(attribute_value, attr_val)) { return node; } } /* Doesn't match? Get the children and search */ temp_node = axiom_node_get_first_element(node, env); while (temp_node) { axiom_node_t *res_node = NULL; res_node = oxs_axiom_get_first_node_by_name_and_attr_val( env, temp_node, e_name, e_ns, attr_name, attr_val, attr_ns); if (res_node) { return res_node; } temp_node = axiom_node_get_next_sibling(temp_node, env); } return NULL; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axis2_svc_grp_builder_populate_svc_grp( axis2_svc_grp_builder_t * svc_grp_builder, const axutil_env_t * env, axis2_svc_grp_t * svc_grp) { axiom_children_qname_iterator_t *itr = NULL; axiom_children_qname_iterator_t *module_ref_itr = NULL; axiom_children_qname_iterator_t *svc_itr = NULL; axutil_qname_t *qparamst = NULL; axutil_qname_t *qmodulest = NULL; axutil_qname_t *qsvc_element = NULL; axiom_element_t *svc_grp_element = NULL; axis2_status_t status = AXIS2_FAILURE; axis2_conf_t *parent = NULL; /* Processing service level paramters */ svc_grp_element = axiom_node_get_data_element(svc_grp_builder->svc_grp, env); qparamst = axutil_qname_create(env, AXIS2_PARAMETERST, NULL, NULL); itr = axiom_element_get_children_with_qname(svc_grp_element, env, qparamst, svc_grp_builder->svc_grp); if(qparamst) { axutil_qname_free(qparamst, env); qparamst = NULL; } parent = axis2_svc_grp_get_parent(svc_grp, env); status = axis2_desc_builder_process_params(svc_grp_builder->desc_builder, env, itr, axis2_svc_grp_get_param_container(svc_grp, env), axis2_conf_get_param_container(parent, env)); /* Processing service modules required to be engaged globally */ qmodulest = axutil_qname_create(env, AXIS2_MODULEST, NULL, NULL); module_ref_itr = axiom_element_get_children_with_qname(svc_grp_element, env, qmodulest, svc_grp_builder-> svc_grp); if(qmodulest) { axutil_qname_free(qmodulest, env); qmodulest = NULL; } axis2_svc_grp_builder_process_module_refs(svc_grp_builder, env, module_ref_itr, svc_grp); qsvc_element = axutil_qname_create(env, AXIS2_SVC_ELEMENT, NULL, NULL); svc_itr = axiom_element_get_children_with_qname(svc_grp_element, env, qsvc_element, svc_grp_builder->svc_grp); if(qsvc_element) { axutil_qname_free(qsvc_element, env); qsvc_element = NULL; } while(axiom_children_qname_iterator_has_next(svc_itr, env)) { axiom_node_t *svc_node = NULL; axiom_element_t *svc_element = NULL; axiom_attribute_t *svc_name_att = NULL; axis2_char_t *svc_name = NULL; axutil_qname_t *qattname = NULL; svc_node = (axiom_node_t *)axiom_children_qname_iterator_next(svc_itr, env); svc_element = axiom_node_get_data_element(svc_node, env); qattname = axutil_qname_create(env, AXIS2_ATTNAME, NULL, NULL); svc_name_att = axiom_element_get_attribute(svc_element, env, qattname); if(qattname) { axutil_qname_free(qattname, env); qattname = NULL; } svc_name = axiom_attribute_get_value(svc_name_att, env); if(!svc_name) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_NAME_ERROR, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service name attribute has no value"); return AXIS2_FAILURE; } else { axis2_svc_t *axis_svc = NULL; axis2_arch_file_data_t *file_data = NULL; axutil_array_list_t *deployable_svcs = NULL; axis2_svc_builder_t *svc_builder = NULL; file_data = axis2_dep_engine_get_current_file_item(axis2_desc_builder_get_dep_engine( svc_grp_builder->desc_builder, env), env); axis_svc = axis2_arch_file_data_get_svc(file_data, env, svc_name); if(!axis_svc) { axutil_qname_t *qsvc_name = NULL; qsvc_name = axutil_qname_create(env, svc_name, NULL, NULL); axis_svc = axis2_svc_create_with_qname(env, qsvc_name); axutil_qname_free(qsvc_name, env); axis2_arch_file_data_add_svc(file_data, env, axis_svc); } /* Adding service to the deployable services list */ deployable_svcs = axis2_arch_file_data_get_deployable_svcs(file_data, env); axutil_array_list_add(deployable_svcs, env, axis_svc); axis2_svc_set_parent(axis_svc, env, svc_grp); svc_builder = axis2_svc_builder_create_with_dep_engine_and_svc(env, axis2_desc_builder_get_dep_engine(svc_grp_builder-> desc_builder, env), axis_svc); status = axis2_svc_builder_populate_svc(svc_builder, env, svc_node); axis2_svc_builder_free(svc_builder, env); } } return status; }
axis2_status_t wsclient_get_attachment (const axutil_env_t *env, axiom_node_t *node, axis2_char_t *base_dir, int is_mtom_enabled) { axiom_node_t *child_node = NULL; axiom_element_t *element; if (!node || !env) return AXIS2_FAILURE; if (axiom_node_get_node_type (node, env) == AXIOM_ELEMENT) { axis2_char_t *local_name; axiom_namespace_t *ns; axis2_char_t *ns_uri; element = (axiom_element_t *) axiom_node_get_data_element (node, env); local_name = axiom_element_get_localname (element, env); if (local_name) { if (!strcmp (local_name, "Include")) { ns = axiom_element_get_namespace(element, env, node); if (ns && (ns_uri = axiom_namespace_get_uri (ns, env)) && (!strcmp (ns_uri, "http://www.w3.org/2004/08/xop/include"))) { axiom_node_t *text_node; axiom_text_t *text; axiom_data_handler_t *data_handler; axis2_char_t *write_file = NULL; axis2_char_t *pwd; axis2_char_t *relative; axutil_qname_t *attribute_qname; axiom_attribute_t *href = NULL; axis2_char_t *cid_value; #if defined(WIN32) char path[256]; GetCurrentDirectory(256, path); pwd = path; #else pwd = AXIS2_GETENV ("PWD"); #endif relative = wsclient_get_relative_path (env, pwd, base_dir); attribute_qname = axutil_qname_create (env, "href", NULL, NULL); if (attribute_qname) href = axiom_element_get_attribute (element, env, attribute_qname); else return AXIS2_FAILURE; if (href) { cid_value = axiom_attribute_get_value (href, env); cid_value = cid_value + 4; } else return AXIS2_FAILURE; axiom_attribute_set_value (href, env, relative); text_node = axiom_node_get_first_child (node, env); if (text_node && (axiom_node_get_node_type (text_node, env) == AXIOM_TEXT)) { text = (axiom_text_t *) axiom_node_get_data_element (text_node, env); data_handler = axiom_text_get_data_handler(text, env); if (data_handler && text) { if (base_dir) { int len = 0; len = strlen (base_dir); if (base_dir [len - 1] != '/') strcat (base_dir, "/"); if (cid_value) write_file = strcat (base_dir, cid_value); else return AXIS2_FAILURE; } if (write_file) axiom_data_handler_set_file_name(data_handler, env, write_file); axiom_data_handler_write_to(data_handler, env); } } } } } child_node = axiom_node_get_first_element (node, env); while (child_node) { wsclient_get_attachment (env, child_node, base_dir, is_mtom_enabled); child_node = axiom_node_get_next_sibling (child_node, env); } } else return AXIS2_FAILURE; return AXIS2_SUCCESS; }