axis2_status_t AXIS2_CALL adb_ServerException_deserialize_obj( adb_ServerException_t* _ServerException, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _ServerException, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for ServerException : " "NULL element can not be passed to deserialize"); return AXIS2_FAILURE; } first_node = axiom_node_get_first_child(parent, env); /* * building Exception element */ current_node = first_node; is_early_node_valid = AXIS2_FALSE; while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } element_qname = axutil_qname_create(env, "Exception", "http://org.apache.axis2/xsd", NULL); if ( (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } text_value = NULL; /* just to avoid warning */ if(axiom_node_get_first_child(current_node, env)) { axiom_node_t *current_property_node = axiom_node_get_first_child(current_node, env); axiom_node_detach(current_property_node, env); status = adb_ServerException_set_Exception(_ServerException, env, current_property_node); } else { status = adb_ServerException_set_Exception(_ServerException, env, NULL); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for Exception "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL rampart_replay_detector_with_flat_file( rampart_replay_detector_t *rrd, const axutil_env_t *env, axis2_msg_ctx_t* msg_ctx, rampart_context_t *rampart_context) { axutil_linked_list_t *ll = NULL; const axis2_char_t *msg_id = NULL; const axis2_char_t *ts = NULL; const axis2_char_t *addr_msg_id = NULL; int max_rcds = RAMPART_RD_DEF_MAX_RCDS; axis2_status_t status = AXIS2_FAILURE; axutil_hash_t *sec_process_result = NULL; /*Get timestamp from security processed results */ sec_process_result = rampart_get_all_security_processed_results(env, msg_ctx); ts = axutil_hash_get(sec_process_result, RAMPART_SPR_TS_CREATED, AXIS2_HASH_KEY_STRING); /* get message id from addressing headers */ addr_msg_id = axis2_msg_ctx_get_wsa_message_id(msg_ctx, env); if(!ts && addr_msg_id) { msg_id = addr_msg_id; } else if(ts && !addr_msg_id) { msg_id = ts; } else if(ts && addr_msg_id) { msg_id = axutil_strcat(env, addr_msg_id, ts, NULL); } else { msg_id = NULL; } if(!msg_id) { /* using default msg id */ msg_id = "RAMPART-DEFAULT-TS"; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart]No msg_id specified, using default = %s", msg_id); } ll = axutil_linked_list_create(env); if(!ll) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Linked list creation failed."); return AXIS2_FAILURE; } status = rampart_replay_detector_read_file(env, ll); if(status != AXIS2_SUCCESS) { /* we have to clear linked list. We don't need to write the contents. So pass false to * denote whether to write the content */ rampart_replay_detector_write_file(env, ll, AXIS2_FALSE); return AXIS2_FAILURE; } else { /* Get the number of records to be kept */ if(rampart_context_get_rd_val(rampart_context, env)) { max_rcds = axutil_atoi(rampart_context_get_rd_val(rampart_context, env)); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart]Using the specified max_rcds %d\n", max_rcds ); } else { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart]Using the default max_rcds %d\n", max_rcds ); } /* If the table already have the same key it's a replay */ if(rampart_replay_detector_check_in_linked_list(ll, env, (void*)msg_id)) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]For ID=%s, a replay detected", msg_id); rampart_replay_detector_write_file(env, ll, AXIS2_FALSE); return AXIS2_FAILURE; } /* if number of records saved are more than allowed, we have to remove them */ while(axutil_linked_list_size(ll, env) >= max_rcds) { axis2_char_t *tmp_msg_id = NULL; tmp_msg_id = (axis2_char_t*)axutil_linked_list_remove_first(ll, env); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart]Deleting record %s\n", tmp_msg_id ); AXIS2_FREE(env->allocator, tmp_msg_id); tmp_msg_id = NULL; } /* Add current record */ status = axutil_linked_list_add(ll, env, (void*)axutil_strdup(env,msg_id)); if(status == AXIS2_SUCCESS) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart]Adding record %s\n", msg_id ); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,"[rampart]Cannot add record %s\n", msg_id); rampart_replay_detector_write_file(env, ll, AXIS2_FALSE); return AXIS2_FAILURE; } status = rampart_replay_detector_write_file(env, ll, AXIS2_TRUE); axutil_linked_list_free(ll, env); if(status == AXIS2_SUCCESS) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart]Writing records to file succeed." ); return AXIS2_SUCCESS; } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,"[rampart]Writing records to file failed"); return AXIS2_FAILURE; } } }
axis2_status_t AXIS2_CALL adb_listControlOperations_deserialize_obj( adb_listControlOperations_t* _listControlOperations, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _listControlOperations, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for listControlOperations : " "NULL element can not be passed to deserialize"); return AXIS2_FAILURE; } current_element = (axiom_element_t *)axiom_node_get_data_element(parent, env); qname = axiom_element_get_qname(current_element, env, parent); if (axutil_qname_equals(qname, env, _listControlOperations-> qname)) { first_node = axiom_node_get_first_child(parent, env); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for listControlOperations : " "Expected %s but returned %s", axutil_qname_to_string(_listControlOperations-> qname, env), axutil_qname_to_string(qname, env)); return AXIS2_FAILURE; } /* * building serviceName element */ current_node = first_node; is_early_node_valid = AXIS2_FALSE; while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } element_qname = axutil_qname_create(env, "serviceName", "http://org.apache.axis2/xsd", NULL); if ( (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } text_value = axiom_element_get_text(current_element, env, current_node); if(text_value != NULL) { status = adb_listControlOperations_set_serviceName(_listControlOperations, env, text_value); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for serviceName "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
AXIS2_EXTERN axis2_svc_t *AXIS2_CALL axis2_svc_create( const axutil_env_t * env) { axis2_svc_t *svc = NULL; svc = (axis2_svc_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_t)); if(!svc) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory"); return NULL; } svc->parent = NULL; svc->axis_svc_name = NULL; svc->filename = NULL; svc->svc_desc = NULL; svc->wsdl_path = NULL; svc->folder_path = NULL; svc->last_update = 0; svc->param_container = NULL; svc->flow_container = NULL; svc->op_alias_map = NULL; svc->op_action_map = NULL; svc->op_rest_map = NULL; svc->module_list = NULL; svc->ns_map = NULL; svc->ns_count = 0; svc->schema_list = NULL; svc->schema_mapping_table = NULL; svc->schema_loc_adjusted = AXIS2_FALSE; svc->custom_schema_name_prefix = NULL; svc->custom_schema_name_suffix = NULL; svc->schema_target_ns = NULL; svc->schema_target_ns_prefix = NULL; svc->target_ns = NULL; svc->target_ns_prefix = NULL; svc->sc_calc_count = 0; svc->impl_class = NULL; svc->qname = NULL; svc->style = NULL; svc->base = NULL; svc->param_container = axutil_param_container_create(env); if(!svc->param_container) { axis2_svc_free(svc, env); AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service param container creation failed"); return NULL; } svc->flow_container = axis2_flow_container_create(env); if(!svc->flow_container) { axis2_svc_free(svc, env); AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service flow container creation failed"); return NULL; } svc->op_alias_map = axutil_hash_make(env); if(!svc->op_alias_map) { axis2_svc_free(svc, env); AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service operation alias map creation failed"); return NULL; } svc->op_action_map = axutil_hash_make(env); if(!svc->op_action_map) { axis2_svc_free(svc, env); AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service operation action map creation failed"); return NULL; } svc->op_rest_map = axutil_hash_make(env); if(!svc->op_rest_map) { axis2_svc_free(svc, env); AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service operation rest map creation failed"); return NULL; } /** Create module list of default size */ svc->module_list = axutil_array_list_create(env, 0); if(!svc->module_list) { axis2_svc_free(svc, env); AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service module list creation failed"); return NULL; } svc->schema_list = axutil_array_list_create(env, AXIS2_ARRAY_LIST_DEFAULT_CAPACITY); if(!svc->schema_list) { axis2_svc_free(svc, env); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service schema list creation failed"); return NULL; } svc->engaged_module_list = axutil_array_list_create(env, AXIS2_ARRAY_LIST_DEFAULT_CAPACITY); if(!svc->engaged_module_list) { axis2_svc_free(svc, env); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service engaged modules list creation failed"); return NULL; } svc->schema_loc_adjusted = AXIS2_FALSE; if(svc->schema_target_ns_prefix) { AXIS2_FREE(env->allocator, svc->schema_target_ns_prefix); svc->schema_target_ns_prefix = NULL; } svc->schema_target_ns_prefix = axutil_strdup(env, "ns"); if(svc->target_ns) { AXIS2_FREE(env->allocator, svc->target_ns); svc->target_ns = NULL; } svc->target_ns = axutil_strdup(env, "http://ws.apache.org/axis2"); if(svc->target_ns_prefix) { AXIS2_FREE(env->allocator, svc->target_ns_prefix); svc->target_ns_prefix = NULL; } svc->target_ns_prefix = axutil_strdup(env, "tns"); svc->sc_calc_count = 0; svc->base = axis2_desc_create(env); if(!svc->base) { axis2_svc_free(svc, env); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service base creation failed"); return NULL; } svc->mutex = axutil_thread_mutex_create(env->allocator, AXIS2_THREAD_MUTEX_DEFAULT); if(!svc->mutex) { axis2_svc_free(svc, env); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service mutex creation failed"); return NULL; } return svc; }
axis2_status_t AXIS2_CALL adb_changePassword_deserialize_obj( adb_changePassword_t* _changePassword, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _changePassword, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for changePassword : "******"NULL element can not be passed to deserialize"); return AXIS2_FAILURE; } current_element = (axiom_element_t *)axiom_node_get_data_element(parent, env); qname = axiom_element_get_qname(current_element, env, parent); if (axutil_qname_equals(qname, env, _changePassword-> qname)) { first_node = axiom_node_get_first_child(parent, env); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for changePassword : "******"Expected %s but returned %s", axutil_qname_to_string(_changePassword-> qname, env), axutil_qname_to_string(qname, env)); return AXIS2_FAILURE; } /* * building userName element */ current_node = first_node; is_early_node_valid = AXIS2_FALSE; while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } element_qname = axutil_qname_create(env, "userName", "http://service.mgt.user.carbon.wso2.org", NULL); if ( (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } text_value = axiom_element_get_text(current_element, env, current_node); if(text_value != NULL) { status = adb_changePassword_set_userName(_changePassword, env, text_value); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for userName "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } /* * building newPassword element */ /* * because elements are ordered this works fine */ if(current_node != NULL && is_early_node_valid) { current_node = axiom_node_get_next_sibling(current_node, env); while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } } is_early_node_valid = AXIS2_FALSE; element_qname = axutil_qname_create(env, "newPassword", "http://service.mgt.user.carbon.wso2.org", NULL); if ( (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } text_value = axiom_element_get_text(current_element, env, current_node); if(text_value != NULL) { status = adb_changePassword_set_newPassword(_changePassword, env, text_value); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for newPassword "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
axis2_status_t AXIS2_CALL adb_DSAKeyValueTypeSequence_type1_deserialize_obj( adb_DSAKeyValueTypeSequence_type1_t* _DSAKeyValueTypeSequence_type1, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; void *element = NULL; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _DSAKeyValueTypeSequence_type1, AXIS2_FAILURE); first_node = parent; /* * building Seed element */ current_node = first_node; is_early_node_valid = AXIS2_FALSE; while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } element_qname = axutil_qname_create(env, "Seed", "http://www.w3.org/2000/09/xmldsig#", NULL); if (adb_CryptoBinary_is_particle() || (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } element = (void*)axis2_extension_mapper_create_from_node(env, ¤t_node, "adb_CryptoBinary"); status = adb_CryptoBinary_deserialize((adb_CryptoBinary_t*)element, env, ¤t_node, &is_early_node_valid, AXIS2_FALSE); if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in building adb object for element Seed"); } else { status = adb_DSAKeyValueTypeSequence_type1_set_Seed(_DSAKeyValueTypeSequence_type1, env, (adb_CryptoBinary_t*)element); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for Seed "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } else if(!dont_care_minoccurs) { if(element_qname) { axutil_qname_free(element_qname, env); } /* this is not a nillable element*/ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "non nillable or minOuccrs != 0 element Seed missing"); return AXIS2_FAILURE; } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } /* * building PgenCounter element */ /* * because elements are ordered this works fine */ if(current_node != NULL && is_early_node_valid) { current_node = axiom_node_get_next_sibling(current_node, env); while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } } is_early_node_valid = AXIS2_FALSE; element_qname = axutil_qname_create(env, "PgenCounter", "http://www.w3.org/2000/09/xmldsig#", NULL); if (adb_CryptoBinary_is_particle() || (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } element = (void*)axis2_extension_mapper_create_from_node(env, ¤t_node, "adb_CryptoBinary"); status = adb_CryptoBinary_deserialize((adb_CryptoBinary_t*)element, env, ¤t_node, &is_early_node_valid, AXIS2_FALSE); if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in building adb object for element PgenCounter"); } else { status = adb_DSAKeyValueTypeSequence_type1_set_PgenCounter(_DSAKeyValueTypeSequence_type1, env, (adb_CryptoBinary_t*)element); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for PgenCounter "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } else if(!dont_care_minoccurs) { if(element_qname) { axutil_qname_free(element_qname, env); } /* this is not a nillable element*/ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "non nillable or minOuccrs != 0 element PgenCounter missing"); return AXIS2_FAILURE; } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } *dp_parent = current_node; *dp_is_early_node_valid = is_early_node_valid; return status; }
axiom_node_t* AXIS2_CALL prf_queryPackageListResponseType_serialize_obj( prf_queryPackageListResponseType_t* _queryPackageListResponseType, const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index) { axis2_char_t *string_to_stream; axiom_node_t* current_node = NULL; int tag_closed = 0; axis2_char_t* xsi_prefix = NULL; axiom_namespace_t* xsi_ns = NULL; axiom_attribute_t* xsi_type_attri = NULL; axis2_char_t* type_attrib = NULL; axiom_namespace_t *ns1 = NULL; axis2_char_t *qname_uri = NULL; axis2_char_t *qname_prefix = NULL; axis2_char_t *p_prefix = NULL; axis2_bool_t ns_already_defined; axis2_char_t text_value_1[PRF_DEFAULT_DIGIT_LIMIT]; axis2_char_t *start_input_str = NULL; axis2_char_t *end_input_str = NULL; unsigned int start_input_str_len = 0; unsigned int end_input_str_len = 0; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = NULL; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _queryPackageListResponseType, NULL); current_node = parent; data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, env); if (!data_source) return NULL; stream = axiom_data_source_get_stream(data_source, env); /* assume parent is of type data source */ if (!stream) return NULL; if(!parent_tag_closed) { if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); if(element_ns) { axiom_namespace_free(element_ns, env); } } } type_attrib = axutil_strcat(env, " ", xsi_prefix, ":type=\"queryPackageListResponseType\"", NULL); axutil_stream_write(stream, env, type_attrib, axutil_strlen(type_attrib)); AXIS2_FREE(env->allocator, type_attrib); string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } else { /* if the parent tag closed we would be able to declare the type directly on the parent element */ if(!(xsi_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING))) { /* it is better to stick with the standard prefix */ xsi_prefix = (axis2_char_t*)axutil_strdup(env, "xsi"); axutil_hash_set(namespaces, "http://www.w3.org/2001/XMLSchema-instance", AXIS2_HASH_KEY_STRING, xsi_prefix); if(parent_element) { axiom_namespace_t *element_ns = NULL; element_ns = axiom_namespace_create(env, "http://www.w3.org/2001/XMLSchema-instance", xsi_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, element_ns); if(element_ns) { axiom_namespace_free(element_ns, env); } } } } xsi_ns = axiom_namespace_create (env, "http://www.pratsam.org/ns/profile/", xsi_prefix); xsi_type_attri = axiom_attribute_create (env, "type", "queryPackageListResponseType", xsi_ns); axiom_element_add_attribute (parent_element, env, xsi_type_attri, parent); if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.pratsam.org/ns/profile/", AXIS2_HASH_KEY_STRING))) { p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * PRF_DEFAULT_NAMESPACE_PREFIX_LIMIT); sprintf(p_prefix, "n%d", (*next_ns_index)++); axutil_hash_set(namespaces, "http://www.pratsam.org/ns/profile/", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://www.pratsam.org/ns/profile/", p_prefix)); } if (!_queryPackageListResponseType->is_valid_packageListResult) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property packageListResult"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("packageListResult"))); /* axutil_strlen("<:>") + 1 = 4 */ end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (5 + axutil_strlen(p_prefix) + axutil_strlen("packageListResult"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing packageListResult element */ sprintf(start_input_str, "<%s%spackageListResult", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%spackageListResult>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); if(!prf_packageListType_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } prf_packageListType_serialize(_queryPackageListResponseType->property_packageListResult, env, current_node, parent_element, prf_packageListType_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!prf_packageListType_is_particle()) { axutil_stream_write(stream, env, end_input_str, end_input_str_len); } AXIS2_FREE(env->allocator,start_input_str); AXIS2_FREE(env->allocator,end_input_str); } return parent; }
/** * Create a new create_seq_msg * @param env * @param application_rm_msg * @param internal_seq_id * @param acks_to * @param seq_prop_mgr * @return sandesha2_msg_ctx_t */ sandesha2_msg_ctx_t *AXIS2_CALL sandesha2_msg_creator_create_create_seq_msg( const axutil_env_t *env, sandesha2_msg_ctx_t *application_rm_msg, axis2_char_t *internal_seq_id, axis2_char_t *acks_to, sandesha2_seq_property_mgr_t *seq_prop_mgr) { axis2_msg_ctx_t *application_msg_ctx = NULL; axis2_msg_ctx_t *create_seq_msg_ctx = NULL; axis2_conf_ctx_t *conf_ctx = NULL; axis2_op_t *app_msg_op_desc = NULL; axis2_op_ctx_t *op_ctx = NULL; axis2_char_t *create_seq_msg_id = NULL; axis2_char_t *rm_version = NULL; axis2_char_t *rm_ns_value = NULL; axis2_char_t *addressing_ns_value = NULL; axis2_char_t *anonymous_uri = NULL; axis2_char_t *temp_value = NULL; axis2_char_t *temp_action = NULL; axutil_string_t *temp_soap_action = NULL; axis2_endpoint_ref_t *to_epr = NULL; axis2_endpoint_ref_t *temp_to = NULL; axis2_endpoint_ref_t *acks_to_epr = NULL; axis2_endpoint_ref_t *temp_reply_to = NULL; sandesha2_create_seq_t *create_seq_part = NULL; sandesha2_seq_property_bean_t *reply_to_bean = NULL; sandesha2_seq_property_bean_t *to_bean = NULL; sandesha2_msg_ctx_t *create_seq_rm_msg = NULL; sandesha2_address_t *temp_address = NULL; sandesha2_acks_to_t *temp_acks_to = NULL; axutil_property_t *property = NULL; const axis2_char_t *reply_to_address = NULL; application_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(application_rm_msg, env); if(!application_msg_ctx) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_APPLICATION_MSG_NULL, AXIS2_FAILURE); return NULL; } conf_ctx = axis2_msg_ctx_get_conf_ctx(application_msg_ctx, env); if(!conf_ctx) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CONF_CTX_NULL, AXIS2_FAILURE); return NULL; } /* Creating by copying common contents. */ create_seq_msg_ctx = sandesha2_utils_create_new_related_msg_ctx(env, application_rm_msg); sandesha2_msg_creator_init_creation(env, application_msg_ctx, create_seq_msg_ctx); create_seq_msg_id = axutil_uuid_gen(env); axis2_msg_ctx_set_message_id(create_seq_msg_ctx, env, create_seq_msg_id); AXIS2_FREE(env->allocator, create_seq_msg_id); app_msg_op_desc = axis2_msg_ctx_get_op(application_msg_ctx, env); property = axis2_msg_ctx_get_property(application_msg_ctx, env, AXIS2_TARGET_EPR); if(property) { temp_to = axutil_property_get_value(property, env); to_epr = axis2_endpoint_ref_create(env, axis2_endpoint_ref_get_address(temp_to, env)); } if (!to_epr) { temp_to = sandesha2_msg_ctx_get_to(application_rm_msg, env); if (temp_to) { to_epr = axis2_endpoint_ref_create(env, axis2_endpoint_ref_get_address(temp_to, env)); } } if (to_epr) { axis2_msg_ctx_set_to(create_seq_msg_ctx, env, to_epr); to_epr = NULL; } temp_reply_to = sandesha2_msg_ctx_get_reply_to(application_rm_msg, env); if(temp_reply_to) { axis2_endpoint_ref_t *reply_to_epr = NULL; reply_to_address = axis2_endpoint_ref_get_address(temp_reply_to, env); reply_to_epr = axis2_endpoint_ref_create(env, reply_to_address); if(reply_to_epr) { axis2_msg_ctx_set_reply_to(create_seq_msg_ctx, env, reply_to_epr); } } create_seq_rm_msg = sandesha2_msg_ctx_create(env, create_seq_msg_ctx); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "create_seq_internal_seq_id:%s", internal_seq_id); rm_version = sandesha2_utils_get_rm_version(env, application_msg_ctx); if(!rm_version) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_RM_VERSION_OF_GIVEN_MSG, AXIS2_FAILURE); return NULL; } rm_ns_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, rm_version); addressing_ns_value = sandesha2_utils_get_seq_property(env, internal_seq_id, SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, seq_prop_mgr); create_seq_part = sandesha2_create_seq_create(env, addressing_ns_value, rm_ns_value); if(!create_seq_part) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] creating create sequence message failed"); return NULL; } /* Adding sequence offer if present */ op_ctx = axis2_msg_ctx_get_op_ctx(application_msg_ctx, env); if(op_ctx) { axis2_op_t *operation = NULL; int mep = -1; axis2_char_t *offered_seq_id = NULL; /*axutil_property_t *property = NULL; axis2_ctx_t *ctx = NULL; ctx = axis2_msg_ctx_get_base(application_msg_ctx, env); property = axis2_ctx_get_property(ctx, env, SANDESHA2_CLIENT_OFFERED_SEQ_ID); if(property) { offered_seq_id = axutil_property_get_value(property, env); }*/ operation = axis2_op_ctx_get_op(op_ctx, env); mep = axis2_op_get_axis_specific_mep_const(operation, env); if(mep == AXIS2_MEP_CONSTANT_OUT_IN) { offered_seq_id = axutil_uuid_gen(env); } /*if(offered_seq_id && 0 != axutil_strcmp("", offered_seq_id))*/ if(offered_seq_id) { sandesha2_seq_offer_t *offer_part = NULL; sandesha2_identifier_t *identifier = NULL; sandesha2_endpoint_t *endpoint = NULL; offer_part = sandesha2_seq_offer_create(env, rm_ns_value, addressing_ns_value); identifier = sandesha2_identifier_create(env, rm_ns_value); sandesha2_identifier_set_identifier(identifier, env, offered_seq_id); sandesha2_seq_offer_set_identifier(offer_part, env, identifier); if(!axutil_strcmp(SANDESHA2_SPEC_VERSION_1_1, rm_version)) { axis2_endpoint_ref_t *reply_to_epr = NULL; sandesha2_address_t *address = NULL; reply_to_epr = axis2_endpoint_ref_create(env, reply_to_address); address = sandesha2_address_create(env, addressing_ns_value, reply_to_epr); endpoint = sandesha2_endpoint_create(env, address, rm_ns_value, addressing_ns_value); sandesha2_seq_offer_set_endpoint(offer_part, env, endpoint); } sandesha2_create_seq_set_seq_offer(create_seq_part, env, offer_part); } } reply_to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_seq_id, SANDESHA2_SEQ_PROP_REPLY_TO_EPR); to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_seq_id, SANDESHA2_SEQ_PROP_TO_EPR); if (to_bean) { temp_value = sandesha2_seq_property_bean_get_value(to_bean, env); if (temp_value) { to_epr = axis2_endpoint_ref_create(env, temp_value); } sandesha2_seq_property_bean_free(to_bean, env); } anonymous_uri = sandesha2_spec_specific_consts_get_anon_uri(env, addressing_ns_value); if(reply_to_bean) { axis2_endpoint_ref_t *reply_to_epr = NULL; temp_value = sandesha2_seq_property_bean_get_value(reply_to_bean, env); if(temp_value) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "dam_reply_to:%s", temp_value); reply_to_epr = axis2_endpoint_ref_create(env, temp_value); acks_to = axutil_strdup(env, temp_value); } if(reply_to_epr) { sandesha2_msg_ctx_set_reply_to(create_seq_rm_msg, env, reply_to_epr); } sandesha2_seq_property_bean_free(reply_to_bean, env); } if(!acks_to || !axutil_strcmp("", acks_to)) { acks_to = axutil_strdup(env, anonymous_uri); } acks_to_epr = axis2_endpoint_ref_create(env, acks_to); temp_to = sandesha2_msg_ctx_get_to(create_seq_rm_msg, env); if(!temp_to && to_epr) { sandesha2_msg_ctx_set_to(create_seq_rm_msg, env, to_epr); } else { axis2_endpoint_ref_free(to_epr, env); } temp_address = sandesha2_address_create(env, addressing_ns_value, acks_to_epr); temp_acks_to = sandesha2_acks_to_create(env, temp_address, rm_ns_value, addressing_ns_value); if(addressing_ns_value) { AXIS2_FREE(env->allocator, addressing_ns_value); } sandesha2_create_seq_set_acks_to(create_seq_part, env, temp_acks_to); sandesha2_msg_ctx_set_create_seq(create_seq_rm_msg, env, create_seq_part); sandesha2_msg_ctx_add_soap_envelope(create_seq_rm_msg, env); temp_action = sandesha2_spec_specific_consts_get_create_seq_action(env, rm_version); sandesha2_msg_ctx_set_wsa_action(create_seq_rm_msg, env, temp_action); temp_soap_action = axutil_string_create(env, temp_action); if(temp_soap_action) { sandesha2_msg_ctx_set_soap_action(create_seq_rm_msg, env, temp_soap_action); axutil_string_free(temp_soap_action, env); } /*sandesha2_msg_creator_finalize_creation(env, application_msg_ctx, create_seq_msg_ctx);*/ return create_seq_rm_msg; }
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; /* Set up the environment */ env = axutil_env_create_all("echo_blocking.log", AXIS2_LOG_LEVEL_TRACE); /* Set end point reference of echo service */ address = "http://localhost:9090/axis2/services/echo"; if (argc > 1) address = argv[1]; if (axutil_strcmp(address, "-h") == 0) { printf("Usage : %s [endpoint_url]\n", argv[0]); printf("use -h for help\n"); return 0; } printf("Using endpoint : %s\n", address); /* 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); /* Set up deploy folder. It is from the deploy folder, the configuration is picked up * using the axis2.xml file. * In this sample client_home points to the Axis2/C default deploy folder. The client_home can * be different from this folder on your system. For example, you may have a different folder * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the * modules that the client uses */ 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_om_payload_for_echo_svc(env); /* Send request */ ret_node = axis2_svc_client_send_receive(svc_client, env, payload); 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); AXIS2_FREE(env->allocator, om_str); } printf("\necho client invoke SUCCESSFUL!\n"); } 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("echo 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; }
axiom_node_t* AXIS2_CALL adb_serviceProvider_type0_serialize_obj( adb_serviceProvider_type0_t* _serviceProvider_type0, const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index) { axiom_attribute_t *text_attri = NULL; axis2_char_t *string_to_stream; axiom_node_t* current_node = NULL; int tag_closed = 0; axis2_char_t* xsi_prefix = NULL; axiom_namespace_t* xsi_ns = NULL; axiom_attribute_t* xsi_type_attri = NULL; axis2_char_t* type_attrib = NULL; axiom_namespace_t *ns1 = NULL; axis2_char_t *qname_uri = NULL; axis2_char_t *qname_prefix = NULL; axis2_char_t *p_prefix = NULL; axis2_bool_t ns_already_defined; axis2_char_t text_value_1[ADB_DEFAULT_DIGIT_LIMIT]; axis2_char_t *text_value_2; axis2_char_t *text_value_2_temp; axis2_char_t *text_value = NULL; axis2_char_t *start_input_str = NULL; axis2_char_t *end_input_str = NULL; unsigned int start_input_str_len = 0; unsigned int end_input_str_len = 0; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = NULL; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _serviceProvider_type0, NULL); current_node = parent; data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, env); if (!data_source) return NULL; stream = axiom_data_source_get_stream(data_source, env); /* assume parent is of type data source */ if (!stream) return NULL; if(!parent_tag_closed) { if(_serviceProvider_type0->is_valid_id) { p_prefix = NULL; text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * (5 + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT + axutil_strlen(_serviceProvider_type0->property_id) + axutil_strlen("id"))); sprintf(text_value, " %s%s%s=\"%s\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"", "id", _serviceProvider_type0->property_id); axutil_stream_write(stream, env, text_value, axutil_strlen(text_value)); AXIS2_FREE(env-> allocator, text_value); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-optional attribute id"); return NULL; } string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.daisy.org/ns/daisy-online/", AXIS2_HASH_KEY_STRING))) { p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT); sprintf(p_prefix, "n%d", (*next_ns_index)++); axutil_hash_set(namespaces, "http://www.daisy.org/ns/daisy-online/", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://www.daisy.org/ns/daisy-online/", p_prefix)); } if (!_serviceProvider_type0->is_valid_label) { /* no need to complain for minoccurs=0 element */ } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("label"))); /* axutil_strlen("<:>") + 1 = 4 */ end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (5 + axutil_strlen(p_prefix) + axutil_strlen("label"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing label element */ sprintf(start_input_str, "<%s%slabel", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%slabel>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); if(!adb_label_type0_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_label_type0_serialize(_serviceProvider_type0->property_label, env, current_node, parent_element, adb_label_type0_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_label_type0_is_particle()) { axutil_stream_write(stream, env, end_input_str, end_input_str_len); } AXIS2_FREE(env->allocator,start_input_str); AXIS2_FREE(env->allocator,end_input_str); } if(parent_tag_closed) { if(_serviceProvider_type0->is_valid_id) { p_prefix = NULL; ns1 = NULL; text_value = _serviceProvider_type0->property_id; text_attri = axiom_attribute_create (env, "id", text_value, ns1); axiom_element_add_attribute (parent_element, env, text_attri, parent); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-optional attribute id"); return NULL; } } return parent; }
/** * Create a new create_seq_response message. * @param env axis2 environment struct * @param create_seq_msg * @param out_msg * @param new_seq_id * @param seq_prop_mgr * @return sandesha2_msg_ctx_t */ sandesha2_msg_ctx_t * sandesha2_msg_creator_create_create_seq_res_msg( const axutil_env_t *env, sandesha2_msg_ctx_t *create_seq_msg, axis2_msg_ctx_t *out_msg, axis2_char_t *new_seq_id, sandesha2_seq_property_mgr_t *seq_prop_mgr) { axis2_conf_ctx_t *conf_ctx = NULL; axis2_msg_ctx_t *temp_msg_ctx = NULL; axis2_char_t *rm_version = NULL; axis2_char_t *rm_ns_value = NULL; axis2_char_t *addressing_ns_value = NULL; axis2_char_t *new_msg_id = NULL; axis2_char_t *temp_action = NULL; axutil_string_t *soap_action = NULL; axiom_soap_envelope_t *envelope = NULL; axiom_soap_envelope_t *temp_envelope = NULL; axiom_soap_body_t *temp_soap_body = NULL; axiom_node_t *temp_om_node = NULL; sandesha2_create_seq_res_t *create_seq_res = NULL; sandesha2_identifier_t *identifier = NULL; sandesha2_seq_offer_t *offer = NULL; sandesha2_msg_ctx_t *create_seq_res_rm_msg_ctx = NULL; sandesha2_create_seq_t *cs = NULL; int soap_version = -1; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_msg_creator_create_create_seq_res_msg"); temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); conf_ctx = axis2_msg_ctx_get_conf_ctx(temp_msg_ctx, env); cs = sandesha2_msg_ctx_get_create_seq(create_seq_msg, env); rm_version = sandesha2_utils_get_rm_version(env, temp_msg_ctx); if(!rm_version) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find rm version of given message"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_RM_VERSION_OF_GIVEN_MSG, AXIS2_FAILURE); return NULL; } rm_ns_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, rm_version); addressing_ns_value = sandesha2_utils_get_seq_property(env, new_seq_id, SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, seq_prop_mgr); if(!addressing_ns_value) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find addressing namespace value"); return NULL; } create_seq_res = sandesha2_create_seq_res_create(env, rm_ns_value, addressing_ns_value); identifier = sandesha2_identifier_create(env, rm_ns_value); sandesha2_identifier_set_identifier(identifier, env, new_seq_id); sandesha2_create_seq_res_set_identifier(create_seq_res, env, identifier); offer = sandesha2_create_seq_get_seq_offer(cs, env); if(offer) { axis2_char_t *out_seq_id = NULL; sandesha2_identifier_t *temp_identifier = NULL; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Offer present"); temp_identifier = sandesha2_seq_offer_get_identifier(offer, env); out_seq_id = sandesha2_identifier_get_identifier(temp_identifier, env); if(out_seq_id && axutil_strcmp("", out_seq_id)) { sandesha2_accept_t *accept = NULL; axis2_endpoint_ref_t *acks_to_epr = NULL; sandesha2_acks_to_t *acks_to = NULL; sandesha2_address_t *address = NULL; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] out_seq_id present"); accept = sandesha2_accept_create(env, rm_ns_value, addressing_ns_value); if(accept) { axis2_endpoint_ref_t *temp_to_epr = NULL; acks_to_epr = sandesha2_msg_ctx_get_to(create_seq_msg, env); if(acks_to_epr) { temp_to_epr = sandesha2_util_endpoint_ref_clone(env, acks_to_epr); } address = sandesha2_address_create(env, addressing_ns_value, temp_to_epr); acks_to = sandesha2_acks_to_create(env, address, rm_ns_value, addressing_ns_value); sandesha2_accept_set_acks_to(accept, env, acks_to); sandesha2_create_seq_res_set_accept(create_seq_res, env, accept); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Could not create accept element"); return NULL; } } } temp_envelope = sandesha2_msg_ctx_get_soap_envelope(create_seq_msg, env); soap_version = sandesha2_utils_get_soap_version(env, temp_envelope); envelope = axiom_soap_envelope_create_default_soap_envelope(env, soap_version); temp_soap_body = axiom_soap_envelope_get_body(envelope, env); temp_om_node = axiom_soap_body_get_base_node(temp_soap_body, env); sandesha2_create_seq_res_to_om_node(create_seq_res, env, temp_om_node); temp_action = sandesha2_spec_specific_consts_get_create_seq_res_action(env, rm_version); axis2_msg_ctx_set_wsa_action(out_msg, env, temp_action); soap_action = axutil_string_create(env, temp_action); /*if(soap_action) { axis2_msg_ctx_set_soap_action(out_msg, env, soap_action); axutil_string_free(soap_action, env); }*/ if(addressing_ns_value) { AXIS2_FREE(env->allocator, addressing_ns_value); } new_msg_id = axutil_uuid_gen(env); if(new_msg_id) { axis2_msg_ctx_set_message_id(out_msg, env, new_msg_id); AXIS2_FREE(env->allocator, new_msg_id); } axis2_msg_ctx_set_soap_envelope(out_msg, env, envelope); temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); sandesha2_msg_creator_init_creation(env, temp_msg_ctx, out_msg); create_seq_res_rm_msg_ctx = sandesha2_msg_init_init_msg(env, out_msg); sandesha2_msg_ctx_set_create_seq_res(create_seq_res_rm_msg_ctx, env, create_seq_res); temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); sandesha2_msg_creator_finalize_creation(env, temp_msg_ctx, out_msg); axis2_msg_ctx_set_server_side(temp_msg_ctx, env, AXIS2_TRUE); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Exit:sandesha2_msg_creator_create_create_seq_res_msg"); return create_seq_res_rm_msg_ctx; }
axis2_status_t AXIS2_CALL adb_serviceProvider_type0_deserialize_obj( adb_serviceProvider_type0_t* _serviceProvider_type0, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; axiom_attribute_t *parent_attri = NULL; axiom_element_t *parent_element = NULL; axis2_char_t *attrib_text = NULL; axutil_hash_t *attribute_hash = NULL; void *element = NULL; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _serviceProvider_type0, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for serviceProvider_type0 : " "NULL element can not be passed to deserialize"); return AXIS2_FAILURE; } first_node = axiom_node_get_first_child(parent, env); parent_element = (axiom_element_t *)axiom_node_get_data_element(parent, env); attribute_hash = axiom_element_get_all_attributes(parent_element, env); /* * building label element */ current_node = first_node; is_early_node_valid = AXIS2_FALSE; while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } element_qname = axutil_qname_create(env, "label", "http://www.daisy.org/ns/daisy-online/", NULL); if (adb_label_type0_is_particle() || (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } element = (void*)axis2_extension_mapper_create_from_node(env, ¤t_node, "adb_label_type0"); status = adb_label_type0_deserialize((adb_label_type0_t*)element, env, ¤t_node, &is_early_node_valid, AXIS2_FALSE); if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in building adb object for element label"); } else { status = adb_serviceProvider_type0_set_label(_serviceProvider_type0, env, (adb_label_type0_t*)element); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for label "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } parent_attri = NULL; attrib_text = NULL; if(attribute_hash) { axutil_hash_index_t *hi; void *val; const void *key; for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, &key, NULL, &val); if(!strcmp((axis2_char_t*)key, "id")) { parent_attri = (axiom_attribute_t*)val; AXIS2_FREE(env->allocator, hi); break; } } } if(parent_attri) { attrib_text = axiom_attribute_get_value(parent_attri, env); } else { /* this is hoping that attribute is stored in "id", this happnes when name is in default namespace */ attrib_text = axiom_element_get_attribute_value_by_name(parent_element, env, "id"); } if(attrib_text != NULL) { adb_serviceProvider_type0_set_id(_serviceProvider_type0, env, attrib_text); } else if(!dont_care_minoccurs) { if(element_qname) { axutil_qname_free(element_qname, env); } /* this is not a nillable element*/ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "required attribute id missing"); return AXIS2_FAILURE; } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
axis2_status_t AXIS2_CALL adb_ProductComplete_deserialize( adb_ProductComplete_t* _ProductComplete, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; void *element = NULL; axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _ProductComplete, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for ProductComplete : " "NULL elemenet can not be passed to deserialize"); return AXIS2_FAILURE; } current_element = (axiom_element_t *)axiom_node_get_data_element(parent, env); qname = axiom_element_get_qname(current_element, env, parent); if (axutil_qname_equals(qname, env, _ProductComplete-> qname)) { first_node = axiom_node_get_first_child(parent, env); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for ProductComplete : " "Expected %s but returned %s", axutil_qname_to_string(_ProductComplete-> qname, env), axutil_qname_to_string(qname, env)); return AXIS2_FAILURE; } /* * building productInfo element */ current_node = first_node; is_early_node_valid = AXIS2_FALSE; while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } element_qname = axutil_qname_create(env, "productInfo", "http://webser.com", NULL); if (adb_ProductCompleteType_is_particle() || (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } element = (void*)adb_ProductCompleteType_create(env); status = adb_ProductCompleteType_deserialize((adb_ProductCompleteType_t*)element, env, ¤t_node, &is_early_node_valid, AXIS2_FALSE); if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in building adb object for element productInfo"); } else { status = adb_ProductComplete_set_productInfo(_ProductComplete, env, (adb_ProductCompleteType_t*)element); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for productInfo "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
axis2_status_t axis2_amqp_process_request( const axutil_env_t* env, axis2_amqp_request_processor_resource_pack_t* request_resource_pack) { axiom_xml_reader_t* xml_reader = NULL; axiom_stax_builder_t* stax_builder = NULL; axiom_soap_builder_t* soap_builder = NULL; axis2_transport_out_desc_t* out_desc = NULL; axis2_transport_in_desc_t* in_desc = NULL; axis2_msg_ctx_t* msg_ctx = NULL; axiom_soap_envelope_t* soap_envelope = NULL; axis2_engine_t* engine = NULL; const axis2_char_t* soap_ns_uri = NULL; axis2_bool_t is_soap_11 = AXIS2_FALSE; axis2_char_t *soap_body_str = NULL; int soap_body_len = 0; axis2_bool_t is_mtom = AXIS2_FALSE; axis2_status_t status = AXIS2_FAILURE; axutil_hash_t *binary_data_map = NULL; axiom_soap_body_t *soap_body = NULL; axutil_property_t* reply_to_property = NULL; /* Create msg_ctx */ if(!request_resource_pack->conf_ctx) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Conf Context not Available"); return AXIS2_FAILURE; } out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf( request_resource_pack->conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_AMQP); if(!out_desc) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport Out Descriptor not Found"); return AXIS2_FAILURE; } in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(request_resource_pack->conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_AMQP); if(!in_desc) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport In Descriptor not Found"); return AXIS2_FAILURE; } /* Create msg_ctx */ msg_ctx = axis2_msg_ctx_create(env, request_resource_pack->conf_ctx, in_desc, out_desc); axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE); /* Handle MTOM */ if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED)) { axis2_char_t* mime_boundary = axis2_amqp_util_get_value_from_content_type(env, request_resource_pack->content_type, AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY); if(mime_boundary) { axiom_mime_parser_t *mime_parser = NULL; int soap_body_len = 0; axutil_param_t *buffer_size_param = NULL; axutil_param_t *max_buffers_param = NULL; axutil_param_t *attachment_dir_param = NULL; axis2_char_t *value_size = NULL; axis2_char_t *value_num = NULL; axis2_char_t *value_dir = NULL; int size = 0; int num = 0; mime_parser = axiom_mime_parser_create(env); buffer_size_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_BUFFER_SIZE); if(buffer_size_param) { value_size = (axis2_char_t*)axutil_param_get_value(buffer_size_param, env); if(value_size) { size = atoi(value_size); axiom_mime_parser_set_buffer_size(mime_parser, env, size); } } max_buffers_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_MAX_BUFFERS); if(max_buffers_param) { value_num = (axis2_char_t*)axutil_param_get_value(max_buffers_param, env); if(value_num) { num = atoi(value_num); axiom_mime_parser_set_max_buffers(mime_parser, env, num); } } /* If this paramter is there mime_parser will cached the attachment * using to the directory for large attachments. */ attachment_dir_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_ATTACHMENT_DIR); if(attachment_dir_param) { value_dir = (axis2_char_t*)axutil_param_get_value(attachment_dir_param, env); if(value_dir) { axiom_mime_parser_set_attachment_dir(mime_parser, env, value_dir); } } if(mime_parser) { axis2_callback_info_t *callback_ctx = NULL; axutil_stream_t *stream = NULL; callback_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_callback_info_t)); stream = axutil_stream_create_basic(env); if(stream) { axutil_stream_write(stream, env, request_resource_pack->request_content, request_resource_pack->content_length); callback_ctx->env = env; callback_ctx->in_stream = stream; callback_ctx->content_length = request_resource_pack->content_length; callback_ctx->unread_len = request_resource_pack->content_length; callback_ctx->chunked_stream = NULL; } /*binary_data_map = axiom_mime_parser_parse(mime_parser, env, axis2_amqp_util_on_data_request, (void*)callback_ctx, mime_boundary);*/ if(!binary_data_map) { return AXIS2_FAILURE; } soap_body_str = axiom_mime_parser_get_soap_body_str(mime_parser, env); soap_body_len = axiom_mime_parser_get_soap_body_len(mime_parser, env); axutil_stream_free(stream, env); AXIS2_FREE(env->allocator, callback_ctx); axiom_mime_parser_free(mime_parser, env); } AXIS2_FREE(env->allocator, mime_boundary); } is_mtom = AXIS2_TRUE; } else { soap_body_str = request_resource_pack->request_content; soap_body_len = request_resource_pack->content_length; } soap_body_len = axutil_strlen(soap_body_str); xml_reader = axiom_xml_reader_create_for_memory(env, soap_body_str, soap_body_len, NULL, AXIS2_XML_PARSER_TYPE_BUFFER); if(!xml_reader) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Reader"); return AXIS2_FAILURE; } stax_builder = axiom_stax_builder_create(env, xml_reader); if(!stax_builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create StAX Builder"); return AXIS2_FAILURE; } soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; if(request_resource_pack->content_type) { if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML)) { is_soap_11 = AXIS2_TRUE; soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; } /*if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_APPL_SOAP)) { is_soap_11 = AXIS2_FALSE; soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; } else if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML)) { is_soap_11 = AXIS2_TRUE; soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; }*/ } soap_builder = axiom_soap_builder_create(env, stax_builder, soap_ns_uri); if(!soap_builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create SOAP Builder"); return AXIS2_FAILURE; } if(binary_data_map) { axiom_soap_builder_set_mime_body_parts(soap_builder, env, binary_data_map); } soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env); axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope); soap_body = axiom_soap_envelope_get_body(soap_envelope, env); if(!soap_body) { return AXIS2_FAILURE; } /* SOAPAction */ if(request_resource_pack->soap_action) { axis2_msg_ctx_set_soap_action(msg_ctx, env, axutil_string_create(env, request_resource_pack->soap_action)); } /* SOAP version */ axis2_msg_ctx_set_is_soap_11(msg_ctx, env, is_soap_11); /* Set ReplyTo in the msg_ctx as a property. This is used by the server when * 1. WS-A is not in use * 2. ReplyTo is an anonymous EPR - Sandesha2/Dual-channel */ reply_to_property = axutil_property_create_with_args(env, AXIS2_SCOPE_REQUEST, 0, 0, (void*)request_resource_pack->reply_to); axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO, reply_to_property); engine = axis2_engine_create(env, request_resource_pack->conf_ctx); if(AXIS2_TRUE == axiom_soap_body_has_fault(soap_body, env)) { status = axis2_engine_receive_fault(engine, env, msg_ctx); } else { status = axis2_engine_receive(engine, env, msg_ctx); } if(engine) { axis2_engine_free(engine, env); } if(soap_body_str && is_mtom) { AXIS2_FREE(env->allocator, soap_body_str); } return status; }
axis2_status_t AXIS2_CALL adb_changeRolePermissionsResponse_deserialize_obj( adb_changeRolePermissionsResponse_t* _changeRolePermissionsResponse, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _changeRolePermissionsResponse, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for changeRolePermissionsResponse : " "NULL element can not be passed to deserialize"); return AXIS2_FAILURE; } current_element = (axiom_element_t *)axiom_node_get_data_element(parent, env); qname = axiom_element_get_qname(current_element, env, parent); if (axutil_qname_equals(qname, env, _changeRolePermissionsResponse-> qname)) { first_node = axiom_node_get_first_child(parent, env); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for changeRolePermissionsResponse : " "Expected %s but returned %s", axutil_qname_to_string(_changeRolePermissionsResponse-> qname, env), axutil_qname_to_string(qname, env)); return AXIS2_FAILURE; } /* * building return element */ current_node = first_node; is_early_node_valid = AXIS2_FALSE; while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } element_qname = axutil_qname_create(env, "return", "http://services.resource.ui.mgt.registry.carbon.wso2.org", NULL); if ( (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } text_value = axiom_element_get_text(current_element, env, current_node); if(text_value != NULL) { if (!axutil_strcasecmp(text_value , "true")) { status = adb_changeRolePermissionsResponse_set_return(_changeRolePermissionsResponse, env, AXIS2_TRUE); } else { status = adb_changeRolePermissionsResponse_set_return(_changeRolePermissionsResponse, env, AXIS2_FALSE); } } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "NULL value is set to a non nillable element return"); status = AXIS2_FAILURE; } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for return "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
axis2_status_t AXIS2_CALL adb_TransportData_deserialize_obj( adb_TransportData_t* _TransportData, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; void *element = NULL; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _TransportData, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for TransportData : " "NULL element can not be passed to deserialize"); return AXIS2_FAILURE; } first_node = axiom_node_get_first_child(parent, env); /* * building details element */ current_node = first_node; is_early_node_valid = AXIS2_FALSE; while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } element_qname = axutil_qname_create(env, "details", "http://mgt.transport.carbon.wso2.org/xsd", NULL); if (adb_TransportDetails_is_particle() || (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } element = (void*)axis2_extension_mapper_create_from_node(env, ¤t_node, "adb_TransportDetails"); status = adb_TransportDetails_deserialize((adb_TransportDetails_t*)element, env, ¤t_node, &is_early_node_valid, AXIS2_FALSE); if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in building adb object for element details"); } else { status = adb_TransportData_set_details(_TransportData, env, (adb_TransportDetails_t*)element); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for details "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } /* * building summary element */ /* * because elements are ordered this works fine */ if(current_node != NULL && is_early_node_valid) { current_node = axiom_node_get_next_sibling(current_node, env); while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } } is_early_node_valid = AXIS2_FALSE; element_qname = axutil_qname_create(env, "summary", "http://mgt.transport.carbon.wso2.org/xsd", NULL); if (adb_TransportSummary_is_particle() || (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } element = (void*)axis2_extension_mapper_create_from_node(env, ¤t_node, "adb_TransportSummary"); status = adb_TransportSummary_deserialize((adb_TransportSummary_t*)element, env, ¤t_node, &is_early_node_valid, AXIS2_FALSE); if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in building adb object for element summary"); } else { status = adb_TransportData_set_summary(_TransportData, env, (adb_TransportSummary_t*)element); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for summary "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
/** executes as new entry arises */ void *AXIS2_CALL tcpmon_entry_new_entry_funct( axutil_thread_t * thd, void *data) { tcpmon_entry_request_data_t *req_data = (tcpmon_entry_request_data_t *) data; const axutil_env_t *env = NULL; int client_socket = -1; int host_socket = -1; tcpmon_session_t *session; TCPMON_SESSION_TRANS_ERROR_FUNCT on_trans_fault_funct; TCPMON_SESSION_NEW_ENTRY_FUNCT on_new_entry; axutil_stream_t *client_stream = NULL; axutil_stream_t *host_stream = NULL; int buffer_size = 0; axis2_char_t *headers = NULL; axis2_char_t *content = NULL; axis2_char_t *buffer = NULL; time_t now; struct tm *localTime = NULL; int arrived_secs = 0; int sent_secs = 0; int time_diff_i = 0; int target_port = 0; axis2_char_t *target_host = NULL; int test_bit = 0; int format_bit = 0; tcpmon_entry_t *entry = NULL; tcpmon_entry_impl_t *entry_impl = NULL; env = req_data->env; client_socket = req_data->socket; session = req_data->session; on_trans_fault_funct = tcpmon_session_get_on_trans_fault(session, env); on_new_entry = tcpmon_session_get_on_new_entry(session, env); entry = tcpmon_entry_create(env); entry_impl = AXIS2_INTF_TO_IMPL(entry); target_port = TCPMON_SESSION_GET_TARGET_PORT(session, env); target_host = TCPMON_SESSION_GET_TARGET_HOST(session, env); if (target_port == -1 || target_host == NULL) { axutil_network_handler_close_socket(env, client_socket); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Missing target port and host" "input missing"); if (on_trans_fault_funct) { (on_trans_fault_funct) (env, "Missing target port and host"); } if (thd) { AXIS2_FREE(env->allocator, thd); } if (data) { AXIS2_FREE(env->allocator, (tcpmon_entry_request_data_t *)data); } return NULL; } client_stream = axutil_stream_create_socket(env, client_socket); if (!client_stream) { axutil_network_handler_close_socket(env, client_socket); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in creating client stream" "handling response"); /** call the callback */ if (on_trans_fault_funct) { (on_trans_fault_funct) (env, "error in creating the client stream"); } if (thd) { AXIS2_FREE(env->allocator, thd); } if (data) { AXIS2_FREE(env->allocator, (tcpmon_entry_request_data_t *)data); } return NULL; } buffer = tcpmon_util_read_current_stream(env, client_stream, &buffer_size, &headers, &content); headers =(char *) tcpmon_util_str_replace(env, headers,"localhost", target_host); test_bit = TCPMON_SESSION_GET_TEST_BIT(session, env); if (test_bit) { tcpmon_util_write_to_file("reqest", buffer); } format_bit = TCPMON_SESSION_GET_FORMAT_BIT(session, env); TCPMON_ENTRY_SET_FORMAT_BIT(entry, env, format_bit); now = time(NULL); localTime = localtime(&now); sprintf(entry_impl->sent_time, "%d:%d:%d", localTime->tm_hour, localTime->tm_min, localTime->tm_sec); sent_secs = localTime->tm_hour * 60 * 60 + localTime->tm_min * 60 + localTime->tm_sec; /*free ( localTime); */ entry_impl->sent_headers = headers; entry_impl->sent_data = content; entry_impl->sent_data_length = buffer_size; if (on_new_entry) { (on_new_entry) (env, entry, 0); } host_socket = (int)axutil_network_handler_open_socket(env, target_host, target_port); if (-1 == host_socket) { axutil_stream_write(client_stream, env, NULL, 0); axutil_stream_free(client_stream, env); axutil_network_handler_close_socket(env, client_socket); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in creating host_socket" "creating socket"); /** call the callback */ if (on_trans_fault_funct) { (on_trans_fault_funct) (env, "error in creating the host socket"); } if (thd) { AXIS2_FREE(env->allocator, thd); } if (data) { AXIS2_FREE(env->allocator, (tcpmon_entry_request_data_t *)data); } return NULL; } host_stream = axutil_stream_create_socket(env, host_socket); if (!host_stream) { axutil_stream_write(client_stream, env, NULL, 0); axutil_stream_free(client_stream, env); axutil_network_handler_close_socket(env, client_socket); axutil_network_handler_close_socket(env, host_socket); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in creating host stream" "handling response"); /** call the callback */ if (on_trans_fault_funct) { (on_trans_fault_funct) (env, "error in creating the host stream"); } if (thd) { AXIS2_FREE(env->allocator, thd); } if (data) { AXIS2_FREE(env->allocator, (tcpmon_entry_request_data_t *)data); } return NULL; } axutil_stream_write(host_stream, env, buffer, buffer_size); AXIS2_FREE(env->allocator, buffer); buffer = tcpmon_util_read_current_stream(env, host_stream, &buffer_size, &headers, &content); test_bit = TCPMON_SESSION_GET_TEST_BIT(session, env); if (test_bit) { tcpmon_util_write_to_file("response", buffer); } now = time(NULL); localTime = localtime(&now); sprintf(entry_impl->arrived_time, "%d:%d:%d", localTime->tm_hour, localTime->tm_min, localTime->tm_sec); arrived_secs = localTime->tm_hour * 60 * 60 + localTime->tm_min * 60 + localTime->tm_sec; /*free ( localTime); */ time_diff_i = arrived_secs - sent_secs; if (time_diff_i < 0) { time_diff_i += 24 * 60 * 60; } sprintf(entry_impl->time_diff, "%d sec(s)", time_diff_i); entry_impl->arrived_headers = headers; entry_impl->arrived_data = content; entry_impl->arrived_data_length = buffer_size; if (buffer == NULL || buffer_size == 0) { entry_impl->is_success = 0; } else { entry_impl->is_success = 1; } if (on_new_entry) { (on_new_entry) (env, entry, 1); } axutil_stream_write(client_stream, env, buffer, buffer_size); AXIS2_FREE(env->allocator, buffer); axutil_stream_free(client_stream, env); axutil_stream_free(host_stream, env); axutil_network_handler_close_socket(env, client_socket); axutil_network_handler_close_socket(env, host_socket); if (entry_impl) { tcpmon_entry_free(&(entry_impl->entry), env); } if (thd) { AXIS2_FREE(env->allocator, thd); } if (data) { AXIS2_FREE(env->allocator, (tcpmon_entry_request_data_t *)data); } return NULL; }
axis2_status_t AXIS2_CALL adb_unsubscribeResponse_deserialize_obj( adb_unsubscribeResponse_t* _unsubscribeResponse, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _unsubscribeResponse, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for unsubscribeResponse : " "NULL element can not be passed to deserialize"); return AXIS2_FAILURE; } current_element = (axiom_element_t *)axiom_node_get_data_element(parent, env); qname = axiom_element_get_qname(current_element, env, parent); if (axutil_qname_equals(qname, env, _unsubscribeResponse-> qname)) { first_node = axiom_node_get_first_child(parent, env); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for unsubscribeResponse : " "Expected %s but returned %s", axutil_qname_to_string(_unsubscribeResponse-> qname, env), axutil_qname_to_string(qname, env)); return AXIS2_FAILURE; } /* * building message element */ current_node = first_node; is_early_node_valid = AXIS2_FALSE; while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } element_qname = axutil_qname_create(env, "message", NULL, NULL); if ( (current_node && current_element && (axutil_qname_equals(element_qname, env, qname) || !axutil_strcmp("message", axiom_element_get_localname(current_element, env))))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname) || !axutil_strcmp("message", axiom_element_get_localname(current_element, env)))) { is_early_node_valid = AXIS2_TRUE; } text_value = axiom_element_get_text(current_element, env, current_node); if(text_value != NULL) { status = adb_unsubscribeResponse_set_message(_unsubscribeResponse, env, text_value); } else { /* * axis2_qname_t *qname = NULL; * axiom_attribute_t *the_attri = NULL; * * qname = axutil_qname_create(env, "nil", "http://www.w3.org/2001/XMLSchema-instance", "xsi"); * the_attri = axiom_element_get_attribute(current_element, env, qname); */ /* currently thereis a bug in the axiom_element_get_attribute, so we have to go to this bad method */ axiom_attribute_t *the_attri = NULL; axis2_char_t *attrib_text = NULL; axutil_hash_t *attribute_hash = NULL; attribute_hash = axiom_element_get_all_attributes(current_element, env); attrib_text = NULL; if(attribute_hash) { axutil_hash_index_t *hi; void *val; const void *key; for (hi = axutil_hash_first(attribute_hash, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, &key, NULL, &val); if(strstr((axis2_char_t*)key, "nil|http://www.w3.org/2001/XMLSchema-instance")) { the_attri = (axiom_attribute_t*)val; break; } } } if(the_attri) { attrib_text = axiom_attribute_get_value(the_attri, env); } else { /* this is hoping that attribute is stored in "http://www.w3.org/2001/XMLSchema-instance", this happnes when name is in default namespace */ attrib_text = axiom_element_get_attribute_value_by_name(current_element, env, "nil"); } if(attrib_text && 0 == axutil_strcmp(attrib_text, "1")) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "NULL value is set to a non nillable element message"); status = AXIS2_FAILURE; } else { /* after all, we found this is a empty string */ status = adb_unsubscribeResponse_set_message(_unsubscribeResponse, env, ""); } } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for message "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } else if(!dont_care_minoccurs) { if(element_qname) { axutil_qname_free(element_qname, env); } /* this is not a nillable element*/ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "non nillable or minOuccrs != 0 element message missing"); return AXIS2_FAILURE; } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
axis2_status_t AXIS2_CALL prf_queryPackageListResponseType_deserialize_obj( prf_queryPackageListResponseType_t* _queryPackageListResponseType, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; void *element = NULL; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _queryPackageListResponseType, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for queryPackageListResponseType : " "NULL element can not be passed to deserialize"); return AXIS2_FAILURE; } first_node = axiom_node_get_first_child(parent, env); /* * building packageListResult element */ current_node = first_node; is_early_node_valid = AXIS2_FALSE; while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } element_qname = axutil_qname_create(env, "packageListResult", "http://www.pratsam.org/ns/profile/", NULL); if (prf_packageListType_is_particle() || (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } element = (void*)axis2_prf_extension_mapper_create_from_node(env, ¤t_node, "prf_packageListType"); status = prf_packageListType_deserialize((prf_packageListType_t*)element, env, ¤t_node, &is_early_node_valid, AXIS2_FALSE); if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in building adb object for element packageListResult"); } else { status = prf_queryPackageListResponseType_set_packageListResult(_queryPackageListResponseType, env, (prf_packageListType_t*)element); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for packageListResult "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } else if(!dont_care_minoccurs) { if(element_qname) { axutil_qname_free(element_qname, env); } /* this is not a nillable element*/ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "non nillable or minOuccrs != 0 element packageListResult missing"); return AXIS2_FAILURE; } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
axiom_node_t* AXIS2_CALL adb_unsubscribeResponse_serialize_obj( adb_unsubscribeResponse_t* _unsubscribeResponse, const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index) { axiom_node_t* current_node = NULL; int tag_closed = 0; axiom_namespace_t *ns1 = NULL; axis2_char_t *qname_uri = NULL; axis2_char_t *qname_prefix = NULL; axis2_char_t *p_prefix = NULL; axis2_bool_t ns_already_defined; axis2_char_t *text_value_1; axis2_char_t *text_value_1_temp; axis2_char_t *start_input_str = NULL; axis2_char_t *end_input_str = NULL; unsigned int start_input_str_len = 0; unsigned int end_input_str_len = 0; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = NULL; int next_ns_index_value = 0; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _unsubscribeResponse, NULL); namespaces = axutil_hash_make(env); next_ns_index = &next_ns_index_value; ns1 = axiom_namespace_create (env, "http://mopevm.ru/axis2/services/types", "n"); axutil_hash_set(namespaces, "http://mopevm.ru/axis2/services/types", AXIS2_HASH_KEY_STRING, axutil_strdup(env, "n")); parent_element = axiom_element_create (env, NULL, "unsubscribeResponse", ns1 , &parent); axiom_element_set_namespace(parent_element, env, ns1, parent); data_source = axiom_data_source_create(env, parent, ¤t_node); stream = axiom_data_source_get_stream(data_source, env); p_prefix = NULL; if (!_unsubscribeResponse->is_valid_message) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property message"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("message"))); /* axutil_strlen("<:>") + 1 = 4 */ end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (5 + axutil_strlen(p_prefix) + axutil_strlen("message"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing message element */ sprintf(start_input_str, "<%s%smessage>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%smessage>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); text_value_1 = _unsubscribeResponse->property_message; axutil_stream_write(stream, env, start_input_str, start_input_str_len); text_value_1_temp = axutil_xml_quote_string(env, text_value_1, AXIS2_TRUE); if (text_value_1_temp) { axutil_stream_write(stream, env, text_value_1_temp, axutil_strlen(text_value_1_temp)); AXIS2_FREE(env->allocator, text_value_1_temp); } else { axutil_stream_write(stream, env, text_value_1, axutil_strlen(text_value_1)); } axutil_stream_write(stream, env, end_input_str, end_input_str_len); AXIS2_FREE(env->allocator,start_input_str); AXIS2_FREE(env->allocator,end_input_str); } if(namespaces) { axutil_hash_index_t *hi; void *val; for (hi = axutil_hash_first(namespaces, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, NULL, NULL, &val); AXIS2_FREE(env->allocator, val); } axutil_hash_free(namespaces, env); } return parent; }
/** * Here we extract all operations defined in module.xml and built execution * chains for them by calling axis2_phase_resolver_build_execution_chains_for_module_op() * function. Within that function handlers of the modules defined for that * operation are added to module operation chains appropriately. */ AXIS2_EXTERN axis2_status_t AXIS2_CALL axis2_svc_add_module_ops( axis2_svc_t * svc, const axutil_env_t * env, axis2_module_desc_t * module_desc, axis2_conf_t * conf) { axutil_hash_t *map = NULL; axutil_hash_index_t *hash_idx = NULL; axis2_phase_resolver_t *phase_resolver = NULL; axis2_op_t *op_desc = NULL; axis2_status_t status = AXIS2_FAILURE; const axis2_char_t *svcname = NULL; axis2_char_t *modname = NULL; axis2_char_t *opname = NULL; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_svc_add_module_ops"); AXIS2_PARAM_CHECK(env->error, module_desc, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, conf, AXIS2_FAILURE); svcname = axis2_svc_get_name(svc, env); modname = axutil_qname_get_localpart(axis2_module_desc_get_qname(module_desc, env), env); map = axis2_module_desc_get_all_ops(module_desc, env); phase_resolver = axis2_phase_resolver_create_with_config_and_svc(env, conf, svc); if(!phase_resolver) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating phase resolver failed for service %s", svcname); return AXIS2_FAILURE; } for(hash_idx = axutil_hash_first(map, env); hash_idx; hash_idx = axutil_hash_next(env, hash_idx)) { void *v = NULL; axutil_hash_this(hash_idx, NULL, NULL, &v); op_desc = (axis2_op_t *)v; opname = axutil_qname_get_localpart(axis2_op_get_qname(op_desc, env), env); status = axis2_phase_resolver_build_execution_chains_for_module_op(phase_resolver, env, op_desc); if(AXIS2_SUCCESS != status) { axis2_phase_resolver_free(phase_resolver, env); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Builidng module operation %s failed for module %s", opname, modname); return status; } status = axis2_svc_add_op(svc, env, op_desc); if(AXIS2_SUCCESS != status) { axis2_phase_resolver_free(phase_resolver, env); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Adding operation %s to service %s failed", opname, svcname); return status; } } axis2_phase_resolver_free(phase_resolver, env); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_svc_add_module_ops"); return AXIS2_SUCCESS; }
AXIS2_EXTERN axis2_http_accept_record_t *AXIS2_CALL axis2_http_accept_record_create( const axutil_env_t * env, const axis2_char_t * str) { axis2_char_t *tmp_accept_record = NULL; axis2_char_t *tmp = NULL; axis2_http_accept_record_t *accept_record = NULL; float quality = 1.0; int level = -1; axis2_char_t *name = NULL; AXIS2_PARAM_CHECK(env->error, str, NULL); tmp_accept_record = (axis2_char_t *) axutil_strdup(env, str); if (!tmp_accept_record) { AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "unable to strdup string %s", str); return NULL; } accept_record = (axis2_http_accept_record_t *) AXIS2_MALLOC (env->allocator, sizeof(axis2_http_accept_record_t)); if (!accept_record) { AXIS2_HANDLE_ERROR (env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); return NULL; } memset ((void *)accept_record, 0, sizeof (axis2_http_accept_record_t)); accept_record->record = axutil_strtrim(env, tmp_accept_record, AXIS2_SPACE_COMMA); tmp = strchr(tmp_accept_record, AXIS2_Q); if (tmp) { *tmp = AXIS2_ESC_NULL; tmp++; tmp = axutil_strtrim(env, tmp, AXIS2_EQ_N_SEMICOLON); if (tmp) { sscanf(tmp, "%f", &quality); AXIS2_FREE(env->allocator, tmp); } } tmp = strstr(tmp_accept_record, AXIS2_LEVEL); if (tmp) { *tmp = AXIS2_ESC_NULL; tmp++; tmp = axutil_strtrim(env, tmp, AXIS2_EQ_N_SEMICOLON); if (tmp) { sscanf(tmp, "%d", &level); AXIS2_FREE(env->allocator, tmp); } } tmp = axutil_strtrim(env, tmp_accept_record, AXIS2_SPACE_SEMICOLON); if (tmp) { name = tmp; } if (!name || quality > 1.0 || quality < 0.0) { axis2_http_accept_record_free(accept_record, env); return NULL; } accept_record->name = name; accept_record->quality = quality; accept_record->level = level; AXIS2_FREE(env->allocator, tmp_accept_record); return accept_record; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axis2_svc_add_op( axis2_svc_t * svc, const axutil_env_t * env, axis2_op_t * op) { axis2_status_t status = AXIS2_FAILURE; axis2_msg_recv_t *msg_recv = NULL; const axutil_qname_t *qname = NULL; axis2_char_t *key = NULL; const axis2_char_t *svcname = NULL; axutil_array_list_t *mappings_list = NULL; int size = 0; int j = 0; AXIS2_PARAM_CHECK(env->error, op, AXIS2_FAILURE); svcname = axis2_svc_get_name(svc, env); qname = axis2_op_get_qname(op, env); if(qname) key = axutil_qname_get_localpart(qname, env); mappings_list = axis2_op_get_wsamapping_list(op, env); /* Adding action mappings into service */ if(mappings_list) size = axutil_array_list_size(mappings_list, env); for(j = 0; j < size; j++) { axis2_char_t *mapping = NULL; mapping = (axis2_char_t *)axutil_array_list_get(mappings_list, env, j); status = axis2_svc_add_mapping(svc, env, mapping, op); if(AXIS2_SUCCESS != status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Adding operation %s to service %s mapping list failed", svcname, key); return status; } } status = axis2_op_set_parent(op, env, svc); if(AXIS2_SUCCESS != status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Setting service %s as operation %s parent failed", svcname, key); return status; } msg_recv = axis2_op_get_msg_recv(op, env); if(msg_recv == NULL) { msg_recv = axis2_desc_builder_load_default_msg_recv(env); axis2_op_set_msg_recv(op, env, msg_recv); } if(key) { /* If service defines the operation, then we should not override with module level * operation. Module operations are global. If any setting to be modified, those operations * can be defined in service */ if(!axutil_hash_get(svc->op_alias_map, key, AXIS2_HASH_KEY_STRING)) { axutil_hash_set(svc->op_alias_map, key, AXIS2_HASH_KEY_STRING, op); } } return AXIS2_SUCCESS; }
int axis2_xmpp_client_on_normal_node( axis2_xmpp_session_data_t *session, iks* node) { if(!strcmp("stream:features", iks_name(node))) { session->features = iks_stream_features(node); if(session->use_sasl) { if(session->use_tls && !iks_is_secure(session->parser)) { if(!session->authorized) { /* we might be in the process of establishing TLS. so should return OK */ return IKS_OK; } return IKS_HOOK; } if(session->authorized) { /* Bind a resource if required */ xmpp_process_msg(session, node); } else { if(session->features & IKS_STREAM_SASL_MD5) { iks_start_sasl(session->parser, IKS_SASL_DIGEST_MD5, session->jid->user, session->password); } else if(session->features & IKS_STREAM_SASL_PLAIN) { iks_start_sasl(session->parser, IKS_SASL_PLAIN, session->jid->user, session->password); } #ifdef AXIS2_XMPP_GSSAPI else if (session->features & IKS_STREAM_SASL_GSSAPI) { iks_start_sasl (session->parser, IKS_SASL_GSSAPI, session->jid->user, session->password); } #endif /* AXIS2_XMPP_GSSAPI */ } } else { /* features node */ if(!strcmp("stream:features", iks_name(node))) { if(session->authorized) xmpp_process_msg(session, node); } } } else if(!strcmp("failure", iks_name(node))) { AXIS2_LOG_ERROR(session->env->log, AXIS2_LOG_SI, "[xmpp]Authentication failed."); return IKS_HOOK; } else if(!strcmp("success", iks_name(node))) { AXIS2_LOG_INFO(session->env->log, "[xmpp]Authentication successful."); session->authorized = 1; iks_send_header(session->parser, session->server); } else { ikspak *pak; pak = iks_packet(node); iks_filter_packet(session->filter, pak); } return IKS_OK; }
static axis2_status_t rampart_replay_detector_write_file( const axutil_env_t *env, axutil_linked_list_t* ll, axis2_bool_t write_content) { FILE* file = NULL; axis2_char_t *file_dir = NULL; axis2_char_t *file_name = NULL; file_dir = rampart_replay_detector_file_dir(env); if (write_content) { file_name = axutil_stracat(env, file_dir, REPLAY_FILE); file = fopen (file_name, "w+"); if (!file) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Creating replay file failed" ); AXIS2_FREE(env->allocator, file_name); file_name = axutil_stracat(env, file_dir, INDICATOR_FILE); remove(file_name); AXIS2_FREE(env->allocator, file_name); AXIS2_FREE(env->allocator, file_dir); return AXIS2_FAILURE; } #ifndef WIN32 else { axis2_char_t *command = NULL; command = axutil_stracat(env, "chmod 666 ", file_name); system(command); AXIS2_FREE(env->allocator, command); } #endif AXIS2_FREE(env->allocator, file_name); } while(axutil_linked_list_size(ll, env) > 0) { axis2_char_t *tmp_msg_id = NULL; tmp_msg_id = (axis2_char_t*)axutil_linked_list_remove_first(ll, env); if (file) { fwrite(tmp_msg_id, sizeof(axis2_char_t), axutil_strlen(tmp_msg_id), file); fputc(DELIMIT, file); } AXIS2_FREE(env->allocator, tmp_msg_id); tmp_msg_id = NULL; } if (file) { fclose(file); } file_name = axutil_stracat(env, file_dir, INDICATOR_FILE); remove(file_name); AXIS2_FREE(env->allocator, file_name); AXIS2_FREE(env->allocator, file_dir); return AXIS2_SUCCESS; }
axis2_status_t AXIS2_CALL adb_getServiceAnnouncementsResponse_deserialize_obj( adb_getServiceAnnouncementsResponse_t* _getServiceAnnouncementsResponse, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; void *element = NULL; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _getServiceAnnouncementsResponse, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for getServiceAnnouncementsResponse : " "NULL element can not be passed to deserialize"); return AXIS2_FAILURE; } current_element = (axiom_element_t *)axiom_node_get_data_element(parent, env); qname = axiom_element_get_qname(current_element, env, parent); if (axutil_qname_equals(qname, env, _getServiceAnnouncementsResponse-> qname)) { first_node = axiom_node_get_first_child(parent, env); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for getServiceAnnouncementsResponse : " "Expected %s but returned %s", axutil_qname_to_string(_getServiceAnnouncementsResponse-> qname, env), axutil_qname_to_string(qname, env)); return AXIS2_FAILURE; } /* * building announcements element */ current_node = first_node; is_early_node_valid = AXIS2_FALSE; while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } element_qname = axutil_qname_create(env, "announcements", "http://www.daisy.org/ns/daisy-online/", NULL); if (adb_announcements_type0_is_particle() || (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } element = (void*)axis2_extension_mapper_create_from_node(env, ¤t_node, "adb_announcements_type0"); status = adb_announcements_type0_deserialize((adb_announcements_type0_t*)element, env, ¤t_node, &is_early_node_valid, AXIS2_FALSE); if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in building adb object for element announcements"); } else { status = adb_getServiceAnnouncementsResponse_set_announcements(_getServiceAnnouncementsResponse, env, (adb_announcements_type0_t*)element); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for announcements "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } else if(!dont_care_minoccurs) { if(element_qname) { axutil_qname_free(element_qname, env); } /* this is not a nillable element*/ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "non nillable or minOuccrs != 0 element announcements missing"); return AXIS2_FAILURE; } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
static axis2_status_t rampart_replay_detector_read_file( const axutil_env_t *env, axutil_linked_list_t* ll) { FILE* temp_file = NULL; FILE* file = NULL; axis2_char_t buffer[sizeof(axis2_char_t) * (BUFFER_LEN + 1)]; int ch_read = 0; char* key = NULL; axis2_char_t *file_dir = NULL; axis2_char_t *file_name = NULL; char dilim[2]; dilim[0] = DELIMIT; dilim[1] = 0; /* * check whether some other threads are using the file. In that case, the indicator file will * not be empty. If no other threads are using it, then the file will not available */ file_dir = rampart_replay_detector_file_dir(env); file_name = axutil_stracat(env, file_dir, INDICATOR_FILE); temp_file = fopen(file_name, "r"); while (temp_file) { fclose (temp_file); #ifdef WIN32 Sleep (5000); #else sleep (5); #endif temp_file = fopen(file_name, "r"); } temp_file = fopen(file_name, "w+"); AXIS2_FREE(env->allocator, file_name); if (!temp_file) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Creating indicator file failed" ); AXIS2_FREE(env->allocator, file_dir); return AXIS2_FAILURE; } fclose (temp_file); /* * now we can safely read the actual replay content file */ file_name = axutil_stracat(env, file_dir, REPLAY_FILE); file = fopen (file_name, "r"); AXIS2_FREE(env->allocator, file_dir); AXIS2_FREE(env->allocator, file_name); if (file) { axis2_char_t* whole_buffer = NULL; do { ch_read = fread (buffer, sizeof(axis2_char_t), BUFFER_LEN, file); buffer[ch_read] = 0; if (!ch_read) break; if (whole_buffer) { axis2_char_t* temp_str = whole_buffer; whole_buffer = axutil_stracat(env, temp_str, buffer); AXIS2_FREE(env->allocator, temp_str); } else { whole_buffer = axutil_strdup(env, buffer); } }while (!feof(file)); fclose(file); if (whole_buffer) { key = strtok(whole_buffer, dilim); while (key) { axutil_linked_list_add(ll, env, (void*)axutil_strdup(env,key)); key = strtok(NULL, dilim); } AXIS2_FREE(env->allocator, whole_buffer); } } return AXIS2_SUCCESS; }
axiom_node_t* AXIS2_CALL adb_getServiceAnnouncementsResponse_serialize_obj( adb_getServiceAnnouncementsResponse_t* _getServiceAnnouncementsResponse, const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index) { axiom_node_t* current_node = NULL; int tag_closed = 0; axis2_char_t* xsi_prefix = NULL; axiom_namespace_t* xsi_ns = NULL; axiom_attribute_t* xsi_type_attri = NULL; axiom_namespace_t *ns1 = NULL; axis2_char_t *qname_uri = NULL; axis2_char_t *qname_prefix = NULL; axis2_char_t *p_prefix = NULL; axis2_bool_t ns_already_defined; axis2_char_t text_value_1[ADB_DEFAULT_DIGIT_LIMIT]; axis2_char_t *start_input_str = NULL; axis2_char_t *end_input_str = NULL; unsigned int start_input_str_len = 0; unsigned int end_input_str_len = 0; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = NULL; int next_ns_index_value = 0; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _getServiceAnnouncementsResponse, NULL); namespaces = axutil_hash_make(env); next_ns_index = &next_ns_index_value; ns1 = axiom_namespace_create (env, "http://www.daisy.org/ns/daisy-online/", "n"); axutil_hash_set(namespaces, "http://www.daisy.org/ns/daisy-online/", AXIS2_HASH_KEY_STRING, axutil_strdup(env, "n")); parent_element = axiom_element_create (env, NULL, "getServiceAnnouncementsResponse", ns1 , &parent); axiom_element_set_namespace(parent_element, env, ns1, parent); data_source = axiom_data_source_create(env, parent, ¤t_node); stream = axiom_data_source_get_stream(data_source, env); if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.daisy.org/ns/daisy-online/", AXIS2_HASH_KEY_STRING))) { p_prefix = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof (axis2_char_t) * ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT); sprintf(p_prefix, "n%d", (*next_ns_index)++); axutil_hash_set(namespaces, "http://www.daisy.org/ns/daisy-online/", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://www.daisy.org/ns/daisy-online/", p_prefix)); } if (!_getServiceAnnouncementsResponse->is_valid_announcements) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property announcements"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("announcements"))); /* axutil_strlen("<:>") + 1 = 4 */ end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (5 + axutil_strlen(p_prefix) + axutil_strlen("announcements"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing announcements element */ sprintf(start_input_str, "<%s%sannouncements", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sannouncements>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); if(!adb_announcements_type0_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_announcements_type0_serialize(_getServiceAnnouncementsResponse->property_announcements, env, current_node, parent_element, adb_announcements_type0_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_announcements_type0_is_particle()) { axutil_stream_write(stream, env, end_input_str, end_input_str_len); } AXIS2_FREE(env->allocator,start_input_str); AXIS2_FREE(env->allocator,end_input_str); } if(namespaces) { axutil_hash_index_t *hi; void *val; for (hi = axutil_hash_first(namespaces, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, NULL, NULL, &val); AXIS2_FREE(env->allocator, val); } axutil_hash_free(namespaces, env); } return parent; }
axis2_status_t AXIS2_CALL adb_Metric_deserialize( adb_Metric_t* _Metric, const axutil_env_t *env, axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid, axis2_bool_t dont_care_minoccurs) { axiom_node_t *parent = *dp_parent; axis2_status_t status = AXIS2_SUCCESS; const axis2_char_t* text_value = NULL; axutil_qname_t *qname = NULL; axutil_qname_t *element_qname = NULL; axiom_node_t *first_node = NULL; axis2_bool_t is_early_node_valid = AXIS2_TRUE; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, _Metric, AXIS2_FAILURE); while(parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) { parent = axiom_node_get_next_sibling(parent, env); } if (NULL == parent) { /* This should be checked before everything */ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed in building adb object for Metric : " "NULL elemenet can not be passed to deserialize"); return AXIS2_FAILURE; } first_node = axiom_node_get_first_child(parent, env); /* * building unit element */ current_node = first_node; is_early_node_valid = AXIS2_FALSE; while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } element_qname = axutil_qname_create(env, "unit", "http://util.services.statistics.carbon.wso2.org/xsd", NULL); if ( (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } text_value = axiom_element_get_text(current_element, env, current_node); if(text_value != NULL) { status = adb_Metric_set_unit(_Metric, env, text_value); } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for unit "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } /* * building value element */ /* * because elements are ordered this works fine */ if(current_node != NULL && is_early_node_valid) { current_node = axiom_node_get_next_sibling(current_node, env); while(current_node && axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT) { current_node = axiom_node_get_next_sibling(current_node, env); } if(current_node != NULL) { current_element = (axiom_element_t *)axiom_node_get_data_element(current_node, env); qname = axiom_element_get_qname(current_element, env, current_node); } } is_early_node_valid = AXIS2_FALSE; element_qname = axutil_qname_create(env, "value", "http://util.services.statistics.carbon.wso2.org/xsd", NULL); if ( (current_node && current_element && (axutil_qname_equals(element_qname, env, qname)))) { if( current_node && current_element && (axutil_qname_equals(element_qname, env, qname))) { is_early_node_valid = AXIS2_TRUE; } text_value = axiom_element_get_text(current_element, env, current_node); if(text_value != NULL) { status = adb_Metric_set_value(_Metric, env, atof(text_value)); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "NULL value is set to a non nillable element value"); status = AXIS2_FAILURE; } if(AXIS2_FAILURE == status) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for value "); if(element_qname) { axutil_qname_free(element_qname, env); } return AXIS2_FAILURE; } } if(element_qname) { axutil_qname_free(element_qname, env); element_qname = NULL; } return status; }
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_endpoint_ref_t *reply_to = 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; axis2_callback_t *callback = NULL; int count = 0; /* Set up the environment */ env = axutil_env_create_all("echo_non_blocking_dual.log", AXIS2_LOG_LEVEL_TRACE); /* Set end point reference of echo service */ address = "http://localhost:9090/axis2/services/echo"; if (argc > 1) address = argv[1]; if (axutil_strcmp(address, "-h") == 0) { printf("Usage : %s [endpoint_url]\n", argv[0]); printf("use -h for help\n"); return 0; } printf("Using endpoint : %s\n", address); /* 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_use_separate_listener(options, env, AXIS2_TRUE); /* Seperate listner needs addressing, hence addressing stuff in options */ axis2_options_set_action(options, env, "http://ws.apache.org/axis2/c/samples/echoString"); reply_to = axis2_endpoint_ref_create(env, "http://localhost:6060/axis2/services/__ANONYMOUS_SERVICE__/__OPERATION_OUT_IN__"); axis2_options_set_reply_to(options, env, reply_to); /* Set up deploy folder. It is from the deploy folder, the configuration is picked up * using the axis2.xml file. * In this sample client_home points to the Axis2/C default deploy folder. The client_home can * be different from this folder on your system. For example, you may have a different folder * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the * modules that the client uses */ client_home = AXIS2_GETENV("AXIS2C_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 AXIS2C_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); axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING); /*axis2_svc_client_engage_module(svc_client, env, "sandesha2"); */ /* Build the SOAP request message payload using OM API. */ payload = build_om_payload_for_echo_svc(env); /* Create the callback object with default on_complete and on_error callback functions */ callback = axis2_callback_create(env); /* Set our on_complete fucntion pointer to the callback object */ axis2_callback_set_on_complete(callback, echo_callback_on_complete); /* Set our on_error function pointer to the callback object */ axis2_callback_set_on_error(callback, echo_callback_on_error); /* Send request */ axis2_svc_client_send_receive_non_blocking(svc_client, env, payload, callback); /** Wait till callback is complete. Simply keep the parent thread running until our on_complete or on_error is invoked */ while (count < MAX_COUNT) { if (isComplete) { /* We are done with the callback */ break; } /* AXIS2_SLEEP(1); */ count++; } if (!(count < MAX_COUNT)) { printf("\necho client invoke FAILED. Counter timed out.\n"); } if (svc_client) { AXIS2_SLEEP(1); axis2_svc_client_free(svc_client, env); svc_client = NULL; } if (env) { axutil_env_free((axutil_env_t *) env); env = NULL; } return 0; }