AXIS2_EXTERN axis2_char_t *AXIS2_CALL oxs_util_get_newline_removed_string(const axutil_env_t *env, axis2_char_t *input) { /*axis2_char_t *output = NULL; int i = 0; output = AXIS2_MALLOC(env->allocator, axutil_strlen(input) +1); while(*input!='\0') { if(*input!='\n') { output[i] = *input; i++; } input++; } output[i]='\0'; return output;*/ axis2_char_t *output = NULL; int index = 0; int len = axutil_strlen(input); output = AXIS2_MALLOC(env->allocator, len +1); while(len > 0) { size_t i = 0; /* scan buffer until the next newline character and skip it */ axis2_char_t *pos = (axis2_char_t*)strchr(input, '\n'); if(pos) { i = pos - input; } else { i = len; } /* write everything until the special character */ if(i > 0) { memcpy(output + index, input, i); input += i; index += i; len -= i; } /* skip the new line */ if(len > 0) { ++input; --len; } } output[index]='\0'; return output; }
static axis2_status_t AXIS2_CALL sandesha2_terminate_seq_msg_processor_process_in_msg ( sandesha2_msg_processor_t *msg_processor, const axutil_env_t *env, sandesha2_msg_ctx_t *rm_msg_ctx) { axis2_msg_ctx_t *terminate_msg_ctx = NULL; sandesha2_terminate_seq_t *term_seq = NULL; axis2_char_t *rmd_sequence_id = NULL; axis2_conf_ctx_t *conf_ctx = NULL; sandesha2_storage_mgr_t *storage_mgr = NULL; sandesha2_seq_property_mgr_t *seq_prop_mgr = NULL; sandesha2_create_seq_mgr_t *create_seq_mgr = NULL; sandesha2_sender_mgr_t *sender_mgr = NULL; sandesha2_next_msg_mgr_t *next_msg_mgr = NULL; sandesha2_msg_ctx_t *fault_ctx = NULL; axis2_char_t *spec_version = NULL; axis2_char_t *dbname = NULL; sandesha2_seq_ack_t *seq_ack = NULL; axis2_op_ctx_t *op_ctx = NULL; /*sandesha2_seq_property_bean_t *term_rcvd_bean = NULL;*/ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Entry:sandesha2_terminate_seq_msg_processor_process_in_msg"); AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE); terminate_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env); if(axis2_msg_ctx_get_server_side(terminate_msg_ctx, env)) { axis2_msg_ctx_t **msg_ctx_map = NULL; op_ctx = axis2_msg_ctx_get_op_ctx(terminate_msg_ctx, env); msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env); msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN] = terminate_msg_ctx; } term_seq = sandesha2_msg_ctx_get_terminate_seq(rm_msg_ctx, env); if(!term_seq) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Terminate Sequence part is not available"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING, AXIS2_FAILURE); return AXIS2_FAILURE; } rmd_sequence_id = sandesha2_identifier_get_identifier(sandesha2_terminate_seq_get_identifier( term_seq, env), env); if(!rmd_sequence_id || 0 == axutil_strlen(rmd_sequence_id)) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Invalid sequence id"); return AXIS2_FAILURE; } conf_ctx = axis2_msg_ctx_get_conf_ctx(terminate_msg_ctx, env); dbname = sandesha2_util_get_dbname(env, conf_ctx); storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname); if(!storage_mgr) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Could not create storage manager."); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_COULD_NOT_CREATE_STORAGE_MANAGER, AXIS2_FAILURE); return AXIS2_FAILURE; } seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname); create_seq_mgr = sandesha2_permanent_create_seq_mgr_create(env, dbname); sender_mgr = sandesha2_permanent_sender_mgr_create(env, dbname); next_msg_mgr = sandesha2_permanent_next_msg_mgr_create(env, dbname); fault_ctx = sandesha2_fault_mgr_check_for_unknown_seq(env, rm_msg_ctx, rmd_sequence_id, seq_prop_mgr, create_seq_mgr, next_msg_mgr); if(fault_ctx) { axis2_engine_t *engine = NULL; engine = axis2_engine_create(env, conf_ctx); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Send fault occurred"); axis2_engine_send_fault(engine, env, sandesha2_msg_ctx_get_msg_ctx(fault_ctx, env)); sandesha2_msg_ctx_free(fault_ctx, env); if(engine) { axis2_engine_free(engine, env); } axis2_msg_ctx_set_paused(terminate_msg_ctx, env, AXIS2_TRUE); if(seq_prop_mgr) { sandesha2_seq_property_mgr_free(seq_prop_mgr, env); } if(create_seq_mgr) { sandesha2_create_seq_mgr_free(create_seq_mgr, env); } if(sender_mgr) { sandesha2_sender_mgr_free(sender_mgr, env); } if(next_msg_mgr) { sandesha2_next_msg_mgr_free(next_msg_mgr, env); } if(storage_mgr) { sandesha2_storage_mgr_free(storage_mgr, env); } return AXIS2_SUCCESS; } /*term_rcvd_bean = sandesha2_seq_property_bean_create(env); sandesha2_seq_property_bean_set_seq_id(term_rcvd_bean, env, rmd_sequence_id); sandesha2_seq_property_bean_set_name(term_rcvd_bean, env, SANDESHA2_SEQ_PROP_TERMINATE_RECEIVED); sandesha2_seq_property_bean_set_value(term_rcvd_bean, env, AXIS2_VALUE_TRUE); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, term_rcvd_bean);*/ spec_version = sandesha2_msg_ctx_get_rm_spec_ver(rm_msg_ctx, env); if(sandesha2_spec_specific_consts_is_term_seq_res_reqd(env, spec_version)) { sandesha2_terminate_seq_msg_processor_add_terminate_seq_res(env, rm_msg_ctx, rmd_sequence_id, seq_prop_mgr); } seq_ack = sandesha2_msg_ctx_get_seq_ack(rm_msg_ctx, env); /* If we have received a sequence acknowldegment with the incoming terminate message then we may * decide to send the terminate sequence message. */ if(seq_ack) { axis2_char_t *internal_sequence_id = NULL; axis2_char_t *rms_sequence_id = NULL; axis2_char_t *last_out_msg_no_str = NULL; long highest_out_msg_no = 0; sandesha2_seq_property_bean_t *terminated_bean = NULL; /* If there is a sequence acknowledgement element present in the sequence we will check * whether the sequence is completed. If so send a terminate sequence message. */ rms_sequence_id = sandesha2_identifier_get_identifier(sandesha2_seq_ack_get_identifier( seq_ack, env), env); internal_sequence_id = sandesha2_utils_get_seq_property(env, rms_sequence_id, SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_INTERNAL_SEQUENCE_ID, seq_prop_mgr); terminated_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_sequence_id, SANDESHA2_SEQ_PROP_TERMINATE_ADDED); if(terminated_bean) { axis2_char_t *value = sandesha2_seq_property_bean_get_value(terminated_bean, env); if(value && !axutil_strcmp(AXIS2_VALUE_TRUE, value)) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Terminate sequence message was added previously"); } sandesha2_seq_property_bean_free(terminated_bean, env); } else { /* Retrieve the message number of the RM 1.0 last message */ last_out_msg_no_str = sandesha2_utils_get_seq_property(env, internal_sequence_id, SANDESHA2_SEQ_PROP_LAST_OUT_MESSAGE_NO, seq_prop_mgr); if(last_out_msg_no_str) { highest_out_msg_no = atol(last_out_msg_no_str); if(last_out_msg_no_str) { AXIS2_FREE(env->allocator, last_out_msg_no_str); } } else { highest_out_msg_no = sandesha2_app_msg_processor_get_prev_msg_no(env, internal_sequence_id, seq_prop_mgr); } if(highest_out_msg_no > 0) { axis2_bool_t completed = AXIS2_FALSE; axutil_array_list_t *ack_range_list = NULL; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] highest_out_msg_no:%ld", highest_out_msg_no); ack_range_list = sandesha2_seq_ack_get_ack_range_list(seq_ack, env); completed = sandesha2_ack_mgr_verify_seq_completion(env, ack_range_list, highest_out_msg_no); if(completed) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Sequence %s is completed. So adding terminate msg", rms_sequence_id); sandesha2_terminate_mgr_send_terminate_seq_msg(env, rm_msg_ctx, rms_sequence_id, internal_sequence_id, storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr); } } if(internal_sequence_id) { AXIS2_FREE(env->allocator, internal_sequence_id); } } } else { sandesha2_terminate_seq_msg_processor_setup_highest_msg_nums(env, conf_ctx, storage_mgr, rmd_sequence_id, rm_msg_ctx, seq_prop_mgr, create_seq_mgr, sender_mgr); } /*sandesha2_terminate_mgr_clean_recv_side_after_terminate_msg(env, conf_ctx, rmd_sequence_id, storage_mgr, seq_prop_mgr, next_msg_mgr);*/ /*transmit_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id, SANDESHA2_SEQ_PROP_SEQ_TERMINATED, AXIS2_VALUE_TRUE); sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, transmit_bean); sandesha2_seq_mgr_update_last_activated_time(env, rmd_sequence_id, storage_mgr); */ /* We have no intention to pass this message beyond Sandesha2/C handler. So pause the message * context */ sandesha2_msg_ctx_set_paused(rm_msg_ctx, env, AXIS2_TRUE); if(seq_prop_mgr) { sandesha2_seq_property_mgr_free(seq_prop_mgr, env); } if(create_seq_mgr) { sandesha2_create_seq_mgr_free(create_seq_mgr, env); } if(sender_mgr) { sandesha2_sender_mgr_free(sender_mgr, env); } if(next_msg_mgr) { sandesha2_next_msg_mgr_free(next_msg_mgr, env); } if(storage_mgr) { sandesha2_storage_mgr_free(storage_mgr, env); } AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Exit:sandesha2_terminate_seq_msg_processor_process_in_msg"); return AXIS2_SUCCESS; }
axiom_node_t* AXIS2_CALL adb_disableSecurityOnService_serialize_obj( adb_disableSecurityOnService_t* _disableSecurityOnService, 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, _disableSecurityOnService, NULL); namespaces = axutil_hash_make(env); next_ns_index = &next_ns_index_value; ns1 = axiom_namespace_create (env, "http://service.config.security.carbon.wso2.org", "n"); axutil_hash_set(namespaces, "http://service.config.security.carbon.wso2.org", AXIS2_HASH_KEY_STRING, axutil_strdup(env, "n")); parent_element = axiom_element_create (env, NULL, "disableSecurityOnService", 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://service.config.security.carbon.wso2.org", 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://service.config.security.carbon.wso2.org", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://service.config.security.carbon.wso2.org", p_prefix)); } if (!_disableSecurityOnService->is_valid_serviceName) { /* 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("serviceName"))); /* 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("serviceName"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing serviceName element */ sprintf(start_input_str, "<%s%sserviceName>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sserviceName>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); text_value_1 = _disableSecurityOnService->property_serviceName; 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; }
AXIS2_EXTERN axis2_bool_t AXIS2_CALL axis2_tcp_worker_process_request( axis2_tcp_worker_t * tcp_worker, const axutil_env_t * env, axis2_simple_tcp_svr_conn_t * svr_conn, axis2_char_t * simple_request) { axis2_conf_ctx_t *conf_ctx = 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_xml_reader_t *reader = NULL; axiom_stax_builder_t *builder = NULL; axiom_soap_builder_t *soap_builder = NULL; axiom_soap_envelope_t *soap_envelope = NULL; axis2_engine_t *engine = NULL; axis2_status_t status = AXIS2_FALSE; axutil_stream_t *svr_stream = NULL; axis2_char_t *buffer = NULL; int len = 0; int write = -1; axutil_stream_t *out_stream = NULL; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "start:axis2_tcp_worker_process_request"); out_stream = axutil_stream_create_basic(env); reader = axiom_xml_reader_create_for_memory(env, simple_request, axutil_strlen(simple_request), NULL, AXIS2_XML_PARSER_TYPE_BUFFER); if(!reader) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create XML reader"); return AXIS2_FAILURE; } builder = axiom_stax_builder_create(env, reader); if(!builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create Stax builder"); return AXIS2_FAILURE; } soap_builder= axiom_soap_builder_create(env, builder, NULL); if(!soap_builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create SOAP builder"); return AXIS2_FAILURE; } conf_ctx = tcp_worker->conf_ctx; if(!conf_ctx) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "conf ctx not available"); return AXIS2_FAILURE; } out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf(conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_TCP); if(!out_desc) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport out not set"); return AXIS2_FAILURE; } in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_TCP); msg_ctx = axis2_msg_ctx_create(env, conf_ctx, in_desc, out_desc); axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE); axis2_msg_ctx_set_transport_out_stream(msg_ctx, env, out_stream); soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env); axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope); engine = axis2_engine_create(env, conf_ctx); status = axis2_engine_receive(engine, env, msg_ctx); svr_stream = axis2_simple_tcp_svr_conn_get_stream(svr_conn, env); buffer = out_stream->buffer; len = out_stream->len; buffer[len] = 0; if(svr_stream && buffer) { write = axutil_stream_write(svr_stream, env, buffer, len + 1); if(write < 0) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "stream write failed"); return AXIS2_FAILURE; } AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "stream wrote:%s", buffer); } AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "end:axis2_tcp_worker_process_request"); return AXIS2_SUCCESS; }
axiom_node_t* AXIS2_CALL adb_contentItem_type0_serialize_obj( adb_contentItem_type0_t* _contentItem_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_3; axis2_char_t *text_value_3_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, _contentItem_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(_contentItem_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(_contentItem_type0->property_id) + axutil_strlen("id"))); sprintf(text_value, " %s%s%s=\"%s\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"", "id", _contentItem_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; } if(_contentItem_type0->is_valid_lastModifiedDate) { p_prefix = NULL; text_value = axutil_date_time_serialize_date_time(_contentItem_type0->property_lastModifiedDate, env); string_to_stream = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * (5 + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT + axutil_strlen(text_value) + axutil_strlen("lastModifiedDate"))); sprintf(string_to_stream, " %s%s%s=\"%s\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"", "lastModifiedDate", text_value); axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); AXIS2_FREE(env-> allocator, string_to_stream); } 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 (!_contentItem_type0->is_valid_label) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property label"); return NULL; } 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(_contentItem_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(_contentItem_type0->is_valid_id) { p_prefix = NULL; ns1 = NULL; text_value = _contentItem_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; } } if(parent_tag_closed) { if(_contentItem_type0->is_valid_lastModifiedDate) { p_prefix = NULL; ns1 = NULL; text_value = axutil_date_time_serialize_date_time(_contentItem_type0->property_lastModifiedDate, env); text_attri = axiom_attribute_create (env, "lastModifiedDate", text_value, ns1); axiom_element_add_attribute (parent_element, env, text_attri, parent); } } return parent; }
axis2_status_t axis2_addr_out_handler_add_to_header( const axutil_env_t * env, axis2_endpoint_ref_t * epr, axiom_node_t ** parent_node_p, const axis2_char_t * addr_ns) { axiom_node_t *parent_node = NULL; const axutil_qname_t *interface_qname = NULL; axiom_node_t *interface_node = NULL; axiom_element_t *interface_ele = NULL; const axis2_char_t *element_localname = NULL; axis2_svc_name_t *service_name = NULL; axiom_namespace_t *addr_ns_obj = NULL; AXIS2_PARAM_CHECK(env->error, epr, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, parent_node_p, AXIS2_FAILURE); parent_node = *(parent_node_p); interface_qname = axis2_endpoint_ref_get_interface_qname(epr, env); if(interface_qname) { axis2_char_t *text = NULL; axis2_char_t *qname_prefix = NULL; axis2_char_t *qname_localpart = NULL; addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX); if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION)) { element_localname = EPR_PORT_TYPE; } else { element_localname = AXIS2_WSA_INTERFACE_NAME; } interface_ele = axiom_element_create(env, parent_node, element_localname, addr_ns_obj, &interface_node); qname_prefix = axutil_qname_get_prefix(interface_qname, env); qname_localpart = axutil_qname_get_localpart(interface_qname, env); text = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (axutil_strlen(qname_prefix) + axutil_strlen(qname_localpart) + 2)); sprintf(text, "%s:%s", qname_prefix, qname_localpart); axiom_element_set_text(interface_ele, env, text, interface_node); AXIS2_FREE(env->allocator, text); if(interface_ele) { axiom_namespace_t *dec_ns = NULL; dec_ns = axiom_element_find_declared_namespace(interface_ele, env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX); if(!dec_ns) { axiom_namespace_free(addr_ns_obj, env); addr_ns_obj = NULL; } } } service_name = axis2_endpoint_ref_get_svc_name(epr, env); return AXIS2_SUCCESS; }
AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL axiom_mime_part_create_part_list( const axutil_env_t *env, axis2_char_t *soap_body, axutil_array_list_t *binary_node_list, axis2_char_t *boundary, axis2_char_t *content_id, axis2_char_t *char_set_encoding, const axis2_char_t *soap_content_type) { axis2_status_t status = AXIS2_FAILURE; axis2_char_t *header_value = NULL; axis2_char_t *temp_header_value = NULL; axis2_char_t *content_id_string = NULL; axis2_char_t *temp_content_id_string = NULL; axiom_mime_body_part_t *root_mime_body_part = NULL; axis2_char_t *soap_body_buffer = NULL; axutil_array_list_t *part_list = NULL; axiom_mime_part_t *soap_part = NULL; part_list = axutil_array_list_create(env, 0); if(!part_list) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create part list array"); return NULL; } /* This mime_body part just keeps the mime_headers of the * SOAP part. Since it is not created from an axiom_text * this will not contain an attachment*/ root_mime_body_part = axiom_mime_body_part_create(env); if(!root_mime_body_part) { return NULL; } /* In order to understand the following code which creates * mime_headers go through the code with a sample mtom message */ /* Adding Content-Type Header */ header_value = axutil_strdup(env, AXIOM_MIME_TYPE_XOP_XML ";" AXIOM_MIME_HEADER_FIELD_CHARSET "="); temp_header_value = axutil_stracat(env, header_value, char_set_encoding); AXIS2_FREE(env->allocator, header_value); header_value = temp_header_value; temp_header_value = axutil_stracat(env, header_value, ";" AXIOM_MIME_HEADER_FIELD_TYPE "=\""); AXIS2_FREE(env->allocator, header_value); header_value = temp_header_value; temp_header_value = axutil_stracat(env, header_value, soap_content_type); AXIS2_FREE(env->allocator, header_value); header_value = temp_header_value; temp_header_value = axutil_stracat(env, header_value, "\";"); AXIS2_FREE(env->allocator, header_value); header_value = temp_header_value; AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env, AXIOM_MIME_HEADER_CONTENT_TYPE, header_value); /* Adding Content Transfer Encoding header */ AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env, AXIOM_MIME_HEADER_CONTENT_TRANSFER_ENCODING, axutil_strdup(env, AXIOM_MIME_CONTENT_TRANSFER_ENCODING_BINARY)); /* Adding Content ID header */ content_id_string = (axis2_char_t *)"<"; content_id_string = axutil_stracat(env, content_id_string, content_id); temp_content_id_string = axutil_stracat(env, content_id_string, ">"); AXIS2_FREE(env->allocator, content_id_string); content_id_string = temp_content_id_string; AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env, AXIOM_MIME_HEADER_CONTENT_ID, content_id_string); /* Now first insert the headers needed for SOAP */ /* After calling this method we have mime_headers of the SOAP envelope * as a mime_part in the array_list */ status = axiom_mime_part_write_body_part_to_list(env, part_list, root_mime_body_part, boundary); if(status == AXIS2_FAILURE) { return NULL; } /* Now add the SOAP body */ AXIOM_MIME_BODY_PART_FREE(root_mime_body_part, env); root_mime_body_part = NULL; soap_part = axiom_mime_part_create(env); if(!soap_part) { return NULL; } /* The atachment's mime_boundary will start after a new line charator */ soap_body_buffer = axutil_stracat(env, soap_body, AXIS2_CRLF); soap_part->part = (axis2_byte_t *)soap_body_buffer; soap_part->part_size = (int)axutil_strlen(soap_body_buffer); soap_part->type = AXIOM_MIME_PART_BUFFER; axutil_array_list_add(part_list, env, soap_part); /* Now we need to add each binary attachment to the array_list */ if(binary_node_list) { int j = 0; for(j = 0; j < axutil_array_list_size(binary_node_list, env); j++) { /* Getting each attachment text node from the node list */ axiom_text_t *text = (axiom_text_t *)axutil_array_list_get(binary_node_list, env, j); if(text) { axiom_mime_body_part_t *mime_body_part = NULL; mime_body_part = axiom_mime_body_part_create_from_om_text(env, text); /* Let's fill the mime_part arraylist with attachment data*/ if(!mime_body_part) { return NULL; } /* This call will create mime_headers for the attachment and put * them to the array_list. Then put the attachment file_name to the * list */ status = axiom_mime_part_write_body_part_to_list(env, part_list, mime_body_part, boundary); if(status == AXIS2_FAILURE) { return NULL; } AXIOM_MIME_BODY_PART_FREE(mime_body_part, env); mime_body_part = NULL; } } } /* Now we have the SOAP message, all the attachments and headers are added to the list. * So let's add the final mime_boundary with -- at the end */ status = axiom_mime_part_finish_adding_parts(env, part_list, boundary); if(status == AXIS2_FAILURE) { return NULL; } return part_list; }
axiom_node_t* AXIS2_CALL adb_listGloballyEngagedModulesResponse_serialize_obj( adb_listGloballyEngagedModulesResponse_t* _listGloballyEngagedModulesResponse, 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; int i = 0; int count = 0; void *element = NULL; 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, _listGloballyEngagedModulesResponse, NULL); namespaces = axutil_hash_make(env); next_ns_index = &next_ns_index_value; ns1 = axiom_namespace_create (env, "http://service.mgt.module.carbon.wso2.org", "n"); axutil_hash_set(namespaces, "http://service.mgt.module.carbon.wso2.org", AXIS2_HASH_KEY_STRING, axutil_strdup(env, "n")); parent_element = axiom_element_create (env, NULL, "listGloballyEngagedModulesResponse", 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://service.mgt.module.carbon.wso2.org", 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://service.mgt.module.carbon.wso2.org", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://service.mgt.module.carbon.wso2.org", p_prefix)); } if (!_listGloballyEngagedModulesResponse->is_valid_return) { /* 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("return"))); /* 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("return"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * Parsing return array */ if (_listGloballyEngagedModulesResponse->property_return != NULL) { sprintf(start_input_str, "<%s%sreturn", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sreturn>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); count = axutil_array_list_size(_listGloballyEngagedModulesResponse->property_return, env); for(i = 0; i < count; i ++) { element = axutil_array_list_get(_listGloballyEngagedModulesResponse->property_return, env, i); if(NULL == element) { continue; } /* * parsing return element */ if(!adb_ModuleMetaData_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_ModuleMetaData_serialize((adb_ModuleMetaData_t*)element, env, current_node, parent_element, adb_ModuleMetaData_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_ModuleMetaData_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 axis2_libcurl_send( axis2_libcurl_t *data, axiom_output_t * om_output, const axutil_env_t * env, axis2_msg_ctx_t * msg_ctx, axiom_soap_envelope_t * out, const axis2_char_t * str_url, const axis2_char_t * soap_action) { struct curl_slist *headers = NULL; axiom_soap_body_t *soap_body; axis2_bool_t is_soap = AXIS2_TRUE; axis2_bool_t send_via_get = AXIS2_FALSE; axis2_bool_t send_via_head = AXIS2_FALSE; axis2_bool_t send_via_put = AXIS2_FALSE; axis2_bool_t send_via_delete = AXIS2_FALSE; axis2_bool_t doing_mtom = AXIS2_FALSE; axiom_node_t *body_node = NULL; axiom_node_t *data_out = NULL; axutil_property_t *method = NULL; axis2_char_t *method_value = NULL; axiom_xml_writer_t *xml_writer = NULL; axis2_char_t *buffer = NULL; unsigned int buffer_size = 0; int content_length = -1; axis2_char_t *content_type = NULL; axis2_char_t *content_len = AXIS2_HTTP_HEADER_CONTENT_LENGTH_; const axis2_char_t *char_set_enc = NULL; axis2_char_t *content = AXIS2_HTTP_HEADER_CONTENT_TYPE_; axis2_char_t *soap_action_header = AXIS2_HTTP_HEADER_SOAP_ACTION_; axutil_stream_t *in_stream; axutil_property_t *trans_in_property; axutil_string_t *char_set_enc_str; axis2_byte_t *output_stream = NULL; int output_stream_size = 0; CURL *handler; axis2_conf_ctx_t *conf_ctx = NULL; axis2_conf_t *conf = NULL; axis2_transport_out_desc_t *trans_desc = NULL; axutil_param_t *write_xml_declaration_param = NULL; axutil_hash_t *transport_attrs = NULL; axis2_bool_t write_xml_declaration = AXIS2_FALSE; axutil_property_t *property; int *response_length = NULL; axis2_http_status_line_t *status_line = NULL; axis2_char_t *status_line_str = NULL; axis2_char_t *tmp_strcat = NULL; int status_code = 0; AXIS2_PARAM_CHECK(env->error, data, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, data->handler, AXIS2_FAILURE); handler = data->handler; curl_easy_reset(handler); curl_easy_setopt(handler, CURLOPT_ERRORBUFFER, data->errorbuffer); headers = curl_slist_append(headers, AXIS2_HTTP_HEADER_USER_AGENT_AXIS2C); headers = curl_slist_append(headers, AXIS2_HTTP_HEADER_ACCEPT_); headers = curl_slist_append(headers, AXIS2_HTTP_HEADER_EXPECT_); if(AXIS2_FAILURE == axis2_libcurl_set_options(handler, env, msg_ctx)) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[axis2libcurl]Setting options in Libcurl failed"); return AXIS2_FAILURE; } if (AXIS2_TRUE == axis2_msg_ctx_get_doing_rest(msg_ctx, env)) { is_soap = AXIS2_FALSE; } else { is_soap = AXIS2_TRUE; } if (!is_soap) { soap_body = axiom_soap_envelope_get_body(out, env); if (!soap_body) { AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL, AXIS2_FAILURE); return AXIS2_FAILURE; } body_node = axiom_soap_body_get_base_node(soap_body, env); if (!body_node) { AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL, AXIS2_FAILURE); return AXIS2_FAILURE; } data_out = axiom_node_get_first_element(body_node, env); method = (axutil_property_t *) axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_HTTP_METHOD); if (method) { method_value = (axis2_char_t *) axutil_property_get_value(method, env); } /* The default is POST */ if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_GET)) { send_via_get = AXIS2_TRUE; } else if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_HEAD)) { send_via_head = AXIS2_TRUE; } else if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_PUT)) { send_via_put = AXIS2_TRUE; } else if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_DELETE)) { send_via_delete = AXIS2_TRUE; } } conf_ctx = axis2_msg_ctx_get_conf_ctx (msg_ctx, env); if (conf_ctx) { conf = axis2_conf_ctx_get_conf (conf_ctx, env); } if (conf) { trans_desc = axis2_conf_get_transport_out (conf, env, AXIS2_TRANSPORT_ENUM_HTTP); } if (trans_desc) { write_xml_declaration_param = axutil_param_container_get_param (axis2_transport_out_desc_param_container (trans_desc, env), env, AXIS2_XML_DECLARATION); } if (write_xml_declaration_param) { transport_attrs = axutil_param_get_attributes (write_xml_declaration_param, env); if (transport_attrs) { axutil_generic_obj_t *obj = NULL; axiom_attribute_t *write_xml_declaration_attr = NULL; axis2_char_t *write_xml_declaration_attr_value = NULL; obj = axutil_hash_get (transport_attrs, AXIS2_ADD_XML_DECLARATION, AXIS2_HASH_KEY_STRING); if (obj) { write_xml_declaration_attr = (axiom_attribute_t *) axutil_generic_obj_get_value (obj, env); } if (write_xml_declaration_attr) { write_xml_declaration_attr_value = axiom_attribute_get_value (write_xml_declaration_attr, env); } if (write_xml_declaration_attr_value && 0 == axutil_strcasecmp (write_xml_declaration_attr_value, AXIS2_VALUE_TRUE)) { write_xml_declaration = AXIS2_TRUE; } } } if (write_xml_declaration) { axiom_output_write_xml_version_encoding (om_output, env); } if (!send_via_get && !send_via_head && !send_via_delete) { xml_writer = axiom_output_get_xml_writer(om_output, env); char_set_enc_str = axis2_msg_ctx_get_charset_encoding(msg_ctx, env); if (!char_set_enc_str) { char_set_enc = AXIS2_DEFAULT_CHAR_SET_ENCODING; } else { char_set_enc = axutil_string_get_buffer(char_set_enc_str, env); } if (!send_via_put && is_soap) { doing_mtom = axis2_msg_ctx_get_doing_mtom(msg_ctx, env); axiom_output_set_do_optimize(om_output, env, doing_mtom); axiom_soap_envelope_serialize(out, env, om_output, AXIS2_FALSE); if (AXIS2_TRUE == axis2_msg_ctx_get_is_soap_11(msg_ctx, env)) { if (AXIS2_ESC_DOUBLE_QUOTE != *soap_action) { axis2_char_t *tmp_soap_action = NULL; tmp_soap_action = AXIS2_MALLOC(env->allocator, (axutil_strlen(soap_action) + 5) * sizeof(axis2_char_t)); sprintf(tmp_soap_action, "\"%s\"", soap_action); tmp_strcat = axutil_stracat(env, soap_action_header,tmp_soap_action); headers = curl_slist_append(headers, tmp_strcat); AXIS2_FREE(env->allocator, tmp_strcat); AXIS2_FREE(env->allocator, tmp_soap_action); } else { tmp_strcat = axutil_stracat(env, soap_action_header, soap_action); headers = curl_slist_append(headers, tmp_strcat ); AXIS2_FREE(env->allocator, tmp_strcat); } } if (doing_mtom) { /*axiom_output_flush(om_output, env, &output_stream, &output_stream_size);*/ axiom_output_flush(om_output, env); content_type = (axis2_char_t *) axiom_output_get_content_type(om_output, env); if (AXIS2_TRUE != axis2_msg_ctx_get_is_soap_11(msg_ctx, env)) { if (axutil_strcmp(soap_action, "")) { /* handle SOAP action for SOAP 1.2 case */ axis2_char_t *temp_content_type = NULL; temp_content_type = axutil_stracat (env, content_type, AXIS2_CONTENT_TYPE_ACTION); content_type = temp_content_type; temp_content_type = axutil_stracat (env, content_type, soap_action); AXIS2_FREE (env->allocator, content_type); content_type = temp_content_type; temp_content_type = axutil_stracat (env, content_type, AXIS2_ESC_DOUBLE_QUOTE_STR); AXIS2_FREE (env->allocator, content_type); content_type = temp_content_type; } } } else if (AXIS2_TRUE == axis2_msg_ctx_get_is_soap_11(msg_ctx, env)) { axis2_char_t *temp_content_type = NULL; content_type = (axis2_char_t *) AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML; content_type = axutil_stracat(env, content_type, AXIS2_CONTENT_TYPE_CHARSET); temp_content_type = axutil_stracat(env, content_type, char_set_enc); AXIS2_FREE(env->allocator, content_type); content_type = temp_content_type; } else { axis2_char_t *temp_content_type = NULL; content_type = (axis2_char_t *) AXIS2_HTTP_HEADER_ACCEPT_APPL_SOAP; content_type = axutil_stracat(env, content_type, AXIS2_CONTENT_TYPE_CHARSET); temp_content_type = axutil_stracat(env, content_type, char_set_enc); AXIS2_FREE(env->allocator, content_type); content_type = temp_content_type; if (axutil_strcmp(soap_action, "")) { temp_content_type = axutil_stracat(env, content_type, AXIS2_CONTENT_TYPE_ACTION); AXIS2_FREE(env->allocator, content_type); content_type = temp_content_type; temp_content_type = axutil_stracat(env, content_type, soap_action); AXIS2_FREE(env->allocator, content_type); content_type = temp_content_type; } temp_content_type = axutil_stracat(env, content_type, AXIS2_SEMI_COLON_STR); AXIS2_FREE(env->allocator, content_type); content_type = temp_content_type; } } else if (is_soap) { AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "Attempt to send SOAP" "message using HTTP PUT failed"); return AXIS2_FAILURE; } else { axutil_property_t *content_type_property = NULL; axutil_hash_t *content_type_hash = NULL; axis2_char_t *content_type_value = NULL; axiom_node_serialize(data_out, env, om_output); content_type_property = (axutil_property_t *) axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_USER_DEFINED_HTTP_HEADER_CONTENT_TYPE); if (content_type_property) { content_type_hash = (axutil_hash_t *) axutil_property_get_value(content_type_property, env); if (content_type_hash) { content_type_value = (char *) axutil_hash_get(content_type_hash, AXIS2_HTTP_HEADER_CONTENT_TYPE, AXIS2_HASH_KEY_STRING); } } if (content_type_value) { content_type = content_type_value; } else { content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML; } } buffer = axiom_xml_writer_get_xml(xml_writer, env); if (!doing_mtom) { buffer_size = axiom_xml_writer_get_xml_size(xml_writer, env); } else buffer_size = output_stream_size; { /* * Curl calculates the content-length automatically. * This commented section is not only unnecessary, * it interferes with authentication. * * NTLM, for example, will send an empty request * first (no body) to get the auth challenge * before resending with actual content. */ /*char tmp_buf[10]; sprintf(tmp_buf, "%d", buffer_size); tmp_strcat = axutil_stracat(env, content_len, tmp_buf); headers = curl_slist_append(headers, tmp_strcat); AXIS2_FREE(env->allocator, tmp_strcat); tmp_strcat = NULL;*/ tmp_strcat = axutil_stracat(env, content, content_type); headers = curl_slist_append(headers, tmp_strcat); AXIS2_FREE(env->allocator, tmp_strcat); tmp_strcat = NULL; } if (!doing_mtom) { curl_easy_setopt(handler, CURLOPT_POSTFIELDSIZE, buffer_size); curl_easy_setopt(handler, CURLOPT_POSTFIELDS, buffer); } else { curl_easy_setopt(handler, CURLOPT_POSTFIELDSIZE, output_stream_size); curl_easy_setopt(handler, CURLOPT_POSTFIELDS, output_stream); } if (send_via_put) { curl_easy_setopt(handler, CURLOPT_CUSTOMREQUEST, AXIS2_HTTP_PUT); } curl_easy_setopt(handler, CURLOPT_URL, str_url); } else { axis2_char_t *request_param; axis2_char_t *url_encode; request_param = (axis2_char_t *) axis2_http_sender_get_param_string(NULL, env, msg_ctx); url_encode = axutil_strcat(env, str_url, AXIS2_Q_MARK_STR, request_param, NULL); if (send_via_get) { curl_easy_setopt(handler, CURLOPT_HTTPGET, 1); } else if (send_via_head) { curl_easy_setopt(handler, CURLOPT_NOBODY, 1); } else if (send_via_delete) { curl_easy_setopt(handler, CURLOPT_CUSTOMREQUEST, AXIS2_HTTP_DELETE); } curl_easy_setopt(handler, CURLOPT_URL, url_encode); } { axis2_bool_t manage_session; manage_session = axis2_msg_ctx_get_manage_session(msg_ctx, env); if (manage_session == AXIS2_TRUE) { if (data->cookies == AXIS2_FALSE) { /* Ensure cookies enabled to manage session */ /* Pass empty cookie string to enable cookies */ curl_easy_setopt(handler, CURLOPT_COOKIEFILE, " "); data->cookies = AXIS2_TRUE; } } else if (data->cookies == AXIS2_TRUE) { /* Pass special string ALL to reset cookies if any have been enabled. */ /* If cookies have ever been enabled, we reset every time as long as manage_session is false, as there is no clear curl option to turn off the cookie engine once enabled. */ curl_easy_setopt(handler, CURLOPT_COOKIELIST, AXIS2_ALL); } } curl_easy_setopt(handler, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(handler, CURLOPT_WRITEFUNCTION, axis2_libcurl_write_memory_callback); curl_easy_setopt(handler, CURLOPT_WRITEDATA, data); curl_easy_setopt (handler, CURLOPT_HEADERFUNCTION, axis2_libcurl_header_callback); curl_easy_setopt (handler, CURLOPT_WRITEHEADER, data); /* Free response data from previous request */ if( data->size ) { if (data->memory) { AXIS2_FREE(data->env->allocator, data->memory); } data->size = 0; } if (curl_easy_perform(handler)) { AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "%s", &data->errorbuffer); AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_HTTP_CLIENT_TRANSPORT_ERROR, AXIS2_FAILURE); return AXIS2_FAILURE; } in_stream = axutil_stream_create_libcurl(env, data->memory, data->size); trans_in_property = axutil_property_create(env); axutil_property_set_scope(trans_in_property, env, AXIS2_SCOPE_REQUEST); axutil_property_set_free_func(trans_in_property, env, libcurl_stream_free); axutil_property_set_value(trans_in_property, env, in_stream); axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_TRANSPORT_IN, trans_in_property); if (axutil_array_list_size(data->alist, env) > 0) { status_line_str = axutil_array_list_get(data->alist, env, 0); if (status_line_str) { status_line = axis2_http_status_line_create(env, status_line_str); } } if (status_line) { status_code = axis2_http_status_line_get_status_code(status_line, env); } axis2_msg_ctx_set_status_code (msg_ctx, env, status_code); AXIS2_FREE(data->env->allocator, content_type); content_type = axis2_libcurl_get_content_type(data, env); if (content_type) { if (strstr (content_type, AXIS2_HTTP_HEADER_ACCEPT_MULTIPART_RELATED) && strstr (content_type, AXIS2_HTTP_HEADER_ACCEPT_XOP_XML)) { axis2_ctx_t *axis_ctx = axis2_op_ctx_get_base (axis2_msg_ctx_get_op_ctx (msg_ctx, env), env); property = axutil_property_create (env); axutil_property_set_scope (property, env, AXIS2_SCOPE_REQUEST); axutil_property_set_value (property, env, axutil_strdup (env, content_type)); axis2_ctx_set_property (axis_ctx, env, MTOM_RECIVED_CONTENT_TYPE, property); } } content_length = axis2_libcurl_get_content_length(data, env); if (content_length >= 0) { response_length = AXIS2_MALLOC (env->allocator, sizeof (int)); memcpy (response_length, &content_length, sizeof (int)); property = axutil_property_create (env); axutil_property_set_scope (property, env, AXIS2_SCOPE_REQUEST); axutil_property_set_value (property, env, response_length); axis2_msg_ctx_set_property (msg_ctx, env, AXIS2_HTTP_HEADER_CONTENT_LENGTH, property); } curl_slist_free_all (headers); /* release the read http headers. */ /* (commenting out the call below is a clever way to force a premature EOF condition in subsequent messages, as they will be read using the content-length of the first message.) */ axis2_libcurl_free_headers(data, env); AXIS2_FREE(data->env->allocator, content_type); axis2_http_status_line_free( status_line, env); return AXIS2_SUCCESS; }
axiom_node_t* AXIS2_CALL adb_IssuerType_serialize_obj( adb_IssuerType_t* _IssuerType, 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_data_source_t *data_source = NULL; axutil_stream_t *stream = NULL; axis2_char_t *text_value; axiom_namespace_t *ns1 = NULL; axis2_char_t *p_prefix = 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(_IssuerType->is_valid_uid) { p_prefix = NULL; adb_IdString_declare_parent_namespaces(_IssuerType->property_uid, env, parent_element, namespaces, next_ns_index); text_value = adb_IdString_serialize_to_string(_IssuerType->property_uid, env, namespaces); string_to_stream = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * (5 + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT + axutil_strlen(text_value) + axutil_strlen("uid"))); sprintf(string_to_stream, " %s%s%s=\"%s\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"", "uid", text_value); axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); AXIS2_FREE(env-> allocator, string_to_stream); AXIS2_FREE(env-> allocator, text_value); } string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } if(!parent_tag_closed && !tag_closed) { text_value = ">"; axutil_stream_write(stream, env, text_value, axutil_strlen(text_value)); } text_value = adb_IssuerType_serialize_to_string(_IssuerType, env, namespaces); if(text_value) { axutil_stream_write(stream, env, text_value, axutil_strlen(text_value)); AXIS2_FREE(env->allocator, text_value); } if(parent_tag_closed) { if(_IssuerType->is_valid_uid) { p_prefix = NULL; ns1 = NULL; adb_IdString_declare_parent_namespaces(_IssuerType->property_uid, env, parent_element, namespaces, next_ns_index); text_value = adb_IdString_serialize_to_string(_IssuerType->property_uid, env, namespaces); if(text_value) { text_attri = axiom_attribute_create (env, "uid", text_value, ns1); axiom_element_add_attribute (parent_element, env, text_attri, parent); AXIS2_FREE(env-> allocator, text_value); } } } return parent; }
axiom_node_t* AXIS2_CALL axis2_getPortfolioResponse_serialize( axis2_getPortfolioResponse_t* getPortfolioResponse, const axutil_env_t *env, axiom_node_t* parent, int has_parent) { axiom_namespace_t *ns1 = NULL; /*axis2_char_t text_value_1[64];*/ axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = 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; AXIS2_ENV_CHECK(env, NULL); ns1 = axiom_namespace_create (env, "http://www.wso2.org/types", "ns1"); if( parent == NULL) { current_element = axiom_element_create (env, parent, "getPortfolioResponse", ns1 , ¤t_node); axiom_element_set_namespace( current_element, env, ns1, current_node); parent = current_node; } if(has_parent) { data_source = axiom_node_get_data_element(parent, 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; current_node = parent; } else { data_source = axiom_data_source_create(env, parent, ¤t_node); stream = axiom_data_source_get_stream(data_source, env); } /** * parsing portFolio element */ start_input_str = "<ns1:portFolio xmlns:ns1=\"http://www.wso2.org/types\">"; start_input_str_len = axutil_strlen(start_input_str); end_input_str = "</ns1:portFolio>"; end_input_str_len = axutil_strlen(end_input_str); axutil_stream_write(stream, env, start_input_str, start_input_str_len); axis2_PortFolio_serialize( getPortfolioResponse->attrib_portFolio, env, current_node, AXIS2_TRUE); axutil_stream_write(stream, env, end_input_str, end_input_str_len); return parent; }
axiom_node_t* AXIS2_CALL adb_createReservation_serialize( adb_createReservation_t* _createReservation, 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; 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 text_value_2[64]; axis2_char_t text_value_3[64]; 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, _createReservation, 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) { string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } p_prefix = NULL; if (!_createReservation->is_valid_sessionId) { /* 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("sessionId"))); /* 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("sessionId"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing sessionId element */ sprintf(start_input_str, "<%s%ssessionId>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%ssessionId>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); text_value_1 = _createReservation->property_sessionId; 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); } p_prefix = NULL; if (!_createReservation->is_valid_bandwidthRequest) { /* 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("bandwidthRequest"))); /* 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("bandwidthRequest"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing bandwidthRequest element */ sprintf(start_input_str, "<%s%sbandwidthRequest", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sbandwidthRequest>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); if(!adb_bandwidthRequest_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_bandwidthRequest_serialize(_createReservation->property_bandwidthRequest, env, current_node, parent_element, adb_bandwidthRequest_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_bandwidthRequest_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); } p_prefix = NULL; if (!_createReservation->is_valid_bidirectional) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property bidirectional"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("bidirectional"))); /* 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("bidirectional"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing bidirectional element */ sprintf(start_input_str, "<%s%sbidirectional>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sbidirectional>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); strcpy(text_value_3, (_createReservation->property_bidirectional)?"true":"false"); axutil_stream_write(stream, env, start_input_str, start_input_str_len); axutil_stream_write(stream, env, text_value_3, axutil_strlen(text_value_3)); 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; }
axiom_node_t* AXIS2_CALL adb_supportedContentProtectionFormats_type0_serialize_obj( adb_supportedContentProtectionFormats_type0_t* _supportedContentProtectionFormats_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) { 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; int i = 0; int count = 0; void *element = NULL; 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; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _supportedContentProtectionFormats_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) { 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 (!_supportedContentProtectionFormats_type0->is_valid_protectionFormat) { /* 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("protectionFormat"))); /* 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("protectionFormat"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * Parsing protectionFormat array */ if (_supportedContentProtectionFormats_type0->property_protectionFormat != NULL) { sprintf(start_input_str, "<%s%sprotectionFormat", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sprotectionFormat>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); count = axutil_array_list_size(_supportedContentProtectionFormats_type0->property_protectionFormat, env); for(i = 0; i < count; i ++) { element = axutil_array_list_get(_supportedContentProtectionFormats_type0->property_protectionFormat, env, i); if(NULL == element) { continue; } /* * parsing protectionFormat element */ if(!adb_protectionFormat_type1_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_protectionFormat_type1_serialize((adb_protectionFormat_type1_t*)element, env, current_node, parent_element, adb_protectionFormat_type1_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_protectionFormat_type1_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; }
//----------------------------------------------------------------------------- void sp_update_lineage( const axutil_env_t * env, const sp_props *props, axiom_node_t *return_node, axiom_node_t *request_node, time_t request_time) { axiom_node_t *eom_node = rp_find_named_child(env, return_node, "EOMetadata", 1); if (NULL == eom_node) { rp_log_error(env, "*Warning S2P(%s:%d): %s node not found.\n", __FILE__, __LINE__, "EOMetadata"); return; } time_t lineage_time = 0; axiom_node_t *curr_lineage = sp_latest_named(env, eom_node, "lineage", &lineage_time); // TODO: should improve handling of insignificant whitespace. // grab some whitespace for future use axiom_node_t *lin_whsp_node = sp_get_last_text_node(curr_lineage, env); axiom_node_t *eom_whsp_node = sp_get_last_text_node(eom_node, env); const axis2_char_t *lin_whsp_str = sp_get_text_text(lin_whsp_node, env); const axis2_char_t *eom_whsp_str = sp_get_text_text(eom_whsp_node, env); int whspace_indent = SP_DEFAULT_WHSPACE; if (NULL != lin_whsp_str && NULL != eom_whsp_str) { whspace_indent = axutil_strlen(lin_whsp_str) - axutil_strlen(eom_whsp_str); if (whspace_indent < 0 || whspace_indent >12) { rp_log_error(env, "*Warning S2P: funny whitespace indent (%d) calculated.\n", whspace_indent); whspace_indent = SP_DEFAULT_WHSPACE; } } axis2_char_t curr_whspace[SP_MAX_LOCAL_STR_LEN]; strncpy(curr_whspace, lin_whsp_str, SP_MAX_LOCAL_STR_LEN-1); curr_whspace[SP_MAX_LOCAL_STR_LEN-1] = '\0'; // The most recent Lineage data is deleted only if it has been added // in the time period since we started processing this request. if (NULL != curr_lineage && lineage_time >= request_time) { // OK to delete lineage axiom_node_detach (curr_lineage, env); axiom_node_free_tree (curr_lineage, env); curr_lineage = NULL; lin_whsp_node = NULL; lin_whsp_str = NULL; } else { sp_add_whspace(env, eom_node, curr_whspace); } // Add a new lineage. here is an example: // <wcseo:lineage> // <wcseo:referenceGetCoverage> // <ows:ServiceReference xlink:href="http://www.someWCS.org"> // <ows:RequestMessage> // <wcs:GetCoverage service="WCS" version="2.0.0"> // <wcs:format>application/gml+xml</wcs:format> // <wcs:CoverageId>someEOCoverage1</wcs:CoverageId> // </wcs:GetCoverage> // </ows:RequestMessage> // </ows:ServiceReference> // </wcseo:referenceGetCoverage> // <gml:timePosition>2011-08-24T14:18:52Z</gml:timePosition> // </wcseo:lineage> // <wcseo:lineage> axiom_node_t *lineage_node = rp_add_child_el(env, eom_node, "lineage", NULL); sp_inc_whspace(curr_whspace, whspace_indent); sp_add_whspace(env, lineage_node, curr_whspace); // comment axiom_node_t *comment = axiom_node_create(env); axiom_comment_create ( env, lineage_node, "POST GetCoverage request added by SOAP-TO-POST proxy.", &comment); //<wcseo:referenceGetCoverage> axiom_node_t *ref_g1_node = rp_add_child_el(env, lineage_node, "referenceGetCoverage", curr_whspace); // <ows:ServiceReference xlink:href="http://www.someWCS.org"> sp_inc_whspace(curr_whspace, whspace_indent); sp_add_whspace(env, ref_g1_node, curr_whspace); axiom_namespace_t *ows_ns = sp_find_or_create_ns(env, return_node, SP_OWS_NAMESPACE_STR, "ows"); axiom_node_t *service_ref_node = axiom_node_create(env); axiom_element_t *service_ref_el = axiom_element_create( env, ref_g1_node, "ServiceReference", ows_ns, &service_ref_node); axiom_namespace_t *xlink_ns = sp_find_or_create_ns( env, return_node, SP_XLINK_NAMESPACE_STR, "xlink"); axiom_attribute_t *attr = axiom_attribute_create (env, "type", "simple", xlink_ns); axiom_element_add_attribute (service_ref_el, env, attr, service_ref_node); attr = axiom_attribute_create (env, "href", rp_getSoapOpsURL(env, props), xlink_ns); axiom_element_add_attribute (service_ref_el, env, attr, service_ref_node); //<ows:RequestMessage> axiom_node_t *req_msg_node = rp_add_child_el(env, service_ref_node, "RequestMessage", curr_whspace); sp_inc_whspace(curr_whspace, whspace_indent); // Detach the request GetCoverage element from its parent // and attach it here. axiom_node_t *gc_node = rp_find_named_node(env, request_node, "GetCoverage", 1); if (gc_node) { // TODO - pretty-up the the indentation to match current. sp_add_whspace(env, req_msg_node, curr_whspace); axiom_node_detach (gc_node, env); axiom_node_add_child (req_msg_node, env, gc_node); } // Adjust the indentation of closing tags sp_inc_whspace(curr_whspace, -whspace_indent); sp_add_whspace(env, req_msg_node, curr_whspace); sp_inc_whspace(curr_whspace, -whspace_indent); sp_add_whspace(env, service_ref_node, curr_whspace); sp_inc_whspace(curr_whspace, -whspace_indent); sp_add_whspace(env, ref_g1_node, curr_whspace); sp_inc_whspace(curr_whspace, -whspace_indent); //<gml:timePosition>2011-08-24T14:18:52Z</gml:timePosition> sp_add_whspace(env, lineage_node, curr_whspace); axiom_namespace_t *gml_ns = sp_find_or_create_ns( env, return_node, SP_GML_NAMESPACE_STR, "gml"); axiom_node_t *time_pos_node = axiom_node_create(env); axiom_element_t *time_pos_el = axiom_element_create( env, lineage_node, "timePosition", gml_ns, &time_pos_node); char tmbuf[22]; sp_time_str(tmbuf, time(NULL)); axiom_element_set_text(time_pos_el, env, tmbuf, time_pos_node); // Adjust the indentation of remaining closing tags sp_inc_whspace(curr_whspace, -whspace_indent); sp_add_whspace(env, lineage_node, curr_whspace); // Adjust whitespace before the element // that follows our new lineage element, whatever it may be. sp_add_whspace(env, eom_node, eom_whsp_str); // Delete the whitespace before any our insertions. axiom_node_detach (eom_whsp_node, env); axiom_node_free_tree (eom_whsp_node, env); }
axiom_node_t* AXIS2_CALL adb_ReferenceListChoiceE3_serialize_obj( adb_ReferenceListChoiceE3_t* _ReferenceListChoiceE3, 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[ADB_DEFAULT_DIGIT_LIMIT]; axis2_char_t text_value_2[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; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _ReferenceListChoiceE3, 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) { string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } if(0 == axutil_strcmp(_ReferenceListChoiceE3->current_choice, "http://www.w3.org/2001/04/xmlenc#:DataReference")) { if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/04/xmlenc#", 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.w3.org/2001/04/xmlenc#", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://www.w3.org/2001/04/xmlenc#", p_prefix)); } if (!_ReferenceListChoiceE3->is_valid_DataReference) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property DataReference"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("DataReference"))); /* 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("DataReference"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing DataReference element */ sprintf(start_input_str, "<%s%sDataReference", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sDataReference>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); if(!adb_ReferenceTypeE2_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_ReferenceTypeE2_serialize(_ReferenceListChoiceE3->property_DataReference, env, current_node, parent_element, adb_ReferenceTypeE2_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_ReferenceTypeE2_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(0 == axutil_strcmp(_ReferenceListChoiceE3->current_choice, "http://www.w3.org/2001/04/xmlenc#:KeyReference")) { if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://www.w3.org/2001/04/xmlenc#", 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.w3.org/2001/04/xmlenc#", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://www.w3.org/2001/04/xmlenc#", p_prefix)); } if (!_ReferenceListChoiceE3->is_valid_KeyReference) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property KeyReference"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("KeyReference"))); /* 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("KeyReference"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing KeyReference element */ sprintf(start_input_str, "<%s%sKeyReference", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sKeyReference>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); if(!adb_ReferenceTypeE2_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_ReferenceTypeE2_serialize(_ReferenceListChoiceE3->property_KeyReference, env, current_node, parent_element, adb_ReferenceTypeE2_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_ReferenceTypeE2_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; }
axiom_node_t* AXIS2_CALL adb_lastmark_type0_serialize_obj( adb_lastmark_type0_t* _lastmark_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) { 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 *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, _lastmark_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(!(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=\"lastmark_type0\"", 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.daisy.org/z3986/2005/bookmark/", xsi_prefix); xsi_type_attri = axiom_attribute_create (env, "type", "lastmark_type0", 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.daisy.org/z3986/2005/bookmark/", 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/z3986/2005/bookmark/", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://www.daisy.org/z3986/2005/bookmark/", p_prefix)); } if (!_lastmark_type0->is_valid_bookmarkContent) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property bookmarkContent"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("bookmarkContent"))); /* 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("bookmarkContent"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing bookmarkContent element */ sprintf(start_input_str, "<%s%sbookmarkContent", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sbookmarkContent>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); if(!adb_bookmarkContent_is_particle()) { axutil_stream_write(stream, env, start_input_str, start_input_str_len); } adb_bookmarkContent_serialize(_lastmark_type0->property_bookmarkContent, env, current_node, parent_element, adb_bookmarkContent_is_particle() || AXIS2_FALSE, namespaces, next_ns_index); if(!adb_bookmarkContent_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; }
axiom_node_t* AXIS2_CALL adb_TagCount_serialize_obj( adb_TagCount_t* _TagCount, 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; axis2_char_t* type_attrib = 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; axis2_char_t *text_value_1_temp; axis2_char_t text_value_2[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; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _TagCount, 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); } } type_attrib = axutil_strcat(env, " ", xsi_prefix, ":type=\"TagCount\"", 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); } } } xsi_ns = axiom_namespace_create (env, "http://common.registry.carbon.wso2.org/xsd", xsi_prefix); xsi_type_attri = axiom_attribute_create (env, "type", "TagCount", xsi_ns); axiom_element_add_attribute (parent_element, env, xsi_type_attri, parent); if(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://common.registry.carbon.wso2.org/xsd", 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://common.registry.carbon.wso2.org/xsd", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://common.registry.carbon.wso2.org/xsd", p_prefix)); } if (!_TagCount->is_valid_key) { /* 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("key"))); /* 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("key"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing key element */ sprintf(start_input_str, "<%s%skey>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%skey>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); text_value_1 = _TagCount->property_key; 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(!(p_prefix = (axis2_char_t*)axutil_hash_get(namespaces, "http://common.registry.carbon.wso2.org/xsd", 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://common.registry.carbon.wso2.org/xsd", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://common.registry.carbon.wso2.org/xsd", p_prefix)); } if (!_TagCount->is_valid_value) { /* 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("value"))); /* 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("value"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing value element */ sprintf(start_input_str, "<%s%svalue>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%svalue>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); sprintf (text_value_2, AXIS2_PRINTF_INT64_FORMAT_SPECIFIER, (int64_t) _TagCount->property_value); axutil_stream_write(stream, env, start_input_str, start_input_str_len); axutil_stream_write(stream, env, text_value_2, axutil_strlen(text_value_2)); 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; }
static axis2_status_t AXIS2_CALL sandesha2_close_seq_res_msg_processor_process_in_msg ( sandesha2_msg_processor_t *msg_processor, const axutil_env_t *env, sandesha2_msg_ctx_t *rm_msg_ctx) { axis2_msg_ctx_t *msg_ctx = NULL; sandesha2_close_seq_res_t *close_seq_res = NULL; axis2_char_t *outgoing_sequence_id = NULL; axis2_char_t *outgoing_internal_sequence_id = NULL; axis2_conf_ctx_t *conf_ctx = NULL; sandesha2_storage_mgr_t *storage_mgr = NULL; sandesha2_seq_property_mgr_t *seq_prop_mgr = NULL; sandesha2_create_seq_mgr_t *create_seq_mgr = NULL; sandesha2_sender_mgr_t *sender_mgr = NULL; axis2_char_t *dbname = NULL; AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_close_seq_res_msg_processor_process_in_msg"); msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env); close_seq_res = sandesha2_msg_ctx_get_close_seq_res(rm_msg_ctx, env); if(!close_seq_res) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Close Sequence part is not available"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING, AXIS2_FAILURE); return AXIS2_FAILURE; } outgoing_sequence_id = sandesha2_identifier_get_identifier( sandesha2_close_seq_res_get_identifier(close_seq_res, env), env); if(!outgoing_sequence_id || 0 == axutil_strlen(outgoing_sequence_id)) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Invalid sequence id"); return AXIS2_FAILURE; } conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); dbname = sandesha2_util_get_dbname(env, conf_ctx); storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname); if(!storage_mgr) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Could not create storage manager."); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_COULD_NOT_CREATE_STORAGE_MANAGER, AXIS2_FAILURE); return AXIS2_FAILURE; } seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname); create_seq_mgr = sandesha2_permanent_create_seq_mgr_create(env, dbname); sender_mgr =sandesha2_permanent_sender_mgr_create(env, dbname); /*sandesha2_msg_ctx_set_paused(rm_msg_ctx, env, AXIS2_TRUE);*/ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Close sequence message for sequence %s is sent and response received. "\ "So adding terminate msg", outgoing_sequence_id); outgoing_internal_sequence_id = sandesha2_utils_get_seq_property(env, outgoing_sequence_id, SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_INTERNAL_SEQUENCE_ID, seq_prop_mgr); sandesha2_terminate_mgr_send_terminate_seq_msg(env, rm_msg_ctx, outgoing_sequence_id, outgoing_internal_sequence_id, storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr); if(seq_prop_mgr) { sandesha2_seq_property_mgr_free(seq_prop_mgr, env); } if(create_seq_mgr) { sandesha2_create_seq_mgr_free(create_seq_mgr, env); } if(sender_mgr) { sandesha2_sender_mgr_free(sender_mgr, env); } if(storage_mgr) { sandesha2_storage_mgr_free(storage_mgr, env); } AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Exit:sandesha2_close_seq_res_msg_processor_process_in_msg"); return AXIS2_SUCCESS; }
static axis2_status_t axiom_mime_part_finish_adding_parts( const axutil_env_t *env, axutil_array_list_t *list, axis2_char_t *boundary) { axis2_byte_t *byte_buffer = NULL; axis2_byte_t *byte_stream = NULL; int size = 0; axiom_mime_part_t *final_part = NULL; size = axutil_strlen(boundary); byte_buffer = (axis2_byte_t *)boundary; /* There is -- before and after so the length of the * actual part is mime_boundary_len + 4 */ byte_stream = AXIS2_MALLOC(env->allocator, (size + 4) * sizeof(axis2_byte_t)); if(!byte_stream) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create byte stream"); return AXIS2_FAILURE; } /* Adding the starting -- */ byte_stream[0] = AXIOM_MIME_BOUNDARY_BYTE; byte_stream[1] = AXIOM_MIME_BOUNDARY_BYTE; if(byte_buffer) { memcpy(byte_stream + 2, byte_buffer, size); } else { AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "Byte buffer not available for writing"); } /* Adding the final -- */ byte_stream[size + 2] = AXIOM_MIME_BOUNDARY_BYTE; byte_stream[size + 3] = AXIOM_MIME_BOUNDARY_BYTE; /* Now we add this as an mime_part to * the list. */ final_part = axiom_mime_part_create(env); if(!final_part) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create final_part"); return AXIS2_FAILURE; } final_part->part = byte_stream; final_part->part_size = size + 4; final_part->type = AXIOM_MIME_PART_BUFFER; axutil_array_list_add(list, env, final_part); return AXIS2_SUCCESS; }
axiom_node_t* AXIS2_CALL adb_creator_serialize_obj( adb_creator_t* _creator, 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; 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, _creator, NULL); namespaces = axutil_hash_make(env); next_ns_index = &next_ns_index_value; ns1 = axiom_namespace_create (env, "http://purl.org/dc/elements/1.1/", "n"); axutil_hash_set(namespaces, "http://purl.org/dc/elements/1.1/", AXIS2_HASH_KEY_STRING, axutil_strdup(env, "n")); parent_element = axiom_element_create (env, NULL, "creator", 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://purl.org/dc/elements/1.1/", 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://purl.org/dc/elements/1.1/", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://purl.org/dc/elements/1.1/", p_prefix)); } if (!_creator->is_valid_creator) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property creator"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("creator"))); /* 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("creator"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing creator element */ sprintf(start_input_str, "<%s%screator>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%screator>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); text_value_1 = NULL; /* just to bypass the warning unused variable */ axiom_node_add_child(parent, env, _creator->property_creator); 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; }
axiom_node_t* AXIS2_CALL adb_SnakeException_serialize( adb_SnakeException_t* _SnakeException, 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; 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; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _SnakeException, 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) { string_to_stream = ">"; axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream)); tag_closed = 1; } p_prefix = NULL; if (!_SnakeException->is_valid_message) { /* 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("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 = _SnakeException->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); } return parent; }
axiom_node_t* AXIS2_CALL adb_metadataChoice_type1_serialize_obj( adb_metadataChoice_type1_t* _metadataChoice_type1, 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; 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; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _metadataChoice_type1, 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=\"metadataChoice_type1\"", 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.daisy.org/ns/daisy-online/", xsi_prefix); xsi_type_attri = axiom_attribute_create (env, "type", "metadataChoice_type1", xsi_ns); axiom_element_add_attribute (parent_element, env, xsi_type_attri, parent); if(0 == axutil_strcmp(_metadataChoice_type1->current_choice, ":extraElement")) { p_prefix = NULL; if (!_metadataChoice_type1->is_valid_extraElement) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property extraElement"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("extraElement"))); /* 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("extraElement"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing extraElement element */ sprintf(start_input_str, "<%s%sextraElement>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sextraElement>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); text_value_1 = axiom_node_to_string(_metadataChoice_type1->property_extraElement, env); axutil_stream_write(stream, env, text_value_1, axutil_strlen(text_value_1)); AXIS2_FREE(env->allocator,start_input_str); AXIS2_FREE(env->allocator,end_input_str); } } return parent; }
axiom_node_t* AXIS2_CALL adb_Signature_serialize_obj( adb_Signature_t* _Signature, 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, _Signature, NULL); namespaces = axutil_hash_make(env); next_ns_index = &next_ns_index_value; ns1 = axiom_namespace_create (env, "http://www.w3.org/2000/09/xmldsig#", "n"); axutil_hash_set(namespaces, "http://www.w3.org/2000/09/xmldsig#", AXIS2_HASH_KEY_STRING, axutil_strdup(env, "n")); parent_element = axiom_element_create (env, NULL, "Signature", 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.w3.org/2000/09/xmldsig#", 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.w3.org/2000/09/xmldsig#", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://www.w3.org/2000/09/xmldsig#", p_prefix)); } if (!_Signature->is_valid_Signature) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property Signature"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("Signature"))); /* 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("Signature"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing Signature element */ sprintf(start_input_str, "<%s%sSignature", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sSignature>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); adb_SignatureType_serialize(_Signature->property_Signature, env, current_node, parent_element, adb_SignatureType_is_particle() || AXIS2_TRUE, namespaces, next_ns_index); 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_EXTERN axis2_op_t *AXIS2_CALL axis2_svc_get_op_with_qname( const axis2_svc_t * svc, const axutil_env_t * env, const axutil_qname_t * op_qname) { axis2_op_t *op = NULL; axis2_char_t *nc_name = NULL; axis2_char_t *nc_tmp = NULL; /* This is just for the sake of comparison, * and must not be used to change the passed value */ axis2_bool_t is_matched = AXIS2_FALSE; AXIS2_PARAM_CHECK(env->error, op_qname, NULL); nc_name = axutil_qname_get_localpart(op_qname, env); nc_tmp = nc_name; op = axutil_hash_get(svc->op_alias_map, nc_tmp, AXIS2_HASH_KEY_STRING); if (op) { return op; } op = axutil_hash_get(svc->op_action_map, nc_tmp, AXIS2_HASH_KEY_STRING); if (op) { return op; } if (*nc_tmp && svc->op_action_map) { axutil_hash_index_t *hi = NULL; const void *key = NULL; for (hi = axutil_hash_first(svc->op_action_map, env); hi; hi = axutil_hash_next(env, hi)) { axutil_hash_this(hi, &key, NULL, NULL); nc_tmp = nc_name; if (key) { axis2_char_t *search = NULL; axis2_bool_t match_start = AXIS2_TRUE; axis2_char_t *search_tmp = NULL; search = (axis2_char_t *)key; if (!axutil_strchr(search, '*')) { if (axutil_strstr(nc_tmp, search)) { axis2_char_t *comp_tmp = NULL; comp_tmp = axutil_strstr(nc_tmp, search); if (strlen(comp_tmp) == strlen (search)) { nc_tmp = (axis2_char_t *)key; is_matched = AXIS2_TRUE; break; } } continue; } if (search[0] == '*') { search++; if (!*search) { nc_tmp = (axis2_char_t *)key; is_matched = AXIS2_TRUE; break; } else if (axutil_strchr(search, '*')) { continue; } match_start = AXIS2_FALSE; } while (search && *search) { int length = 0; axis2_char_t *loc_tmp = NULL; if (search_tmp) { AXIS2_FREE(env->allocator, search_tmp); search_tmp = NULL; } loc_tmp = axutil_strchr(search, '*'); if (loc_tmp && *loc_tmp) { if (!loc_tmp[1]) { is_matched = AXIS2_TRUE; break; } length = (int)(loc_tmp - search); /* We are sure that the difference lies within the int range */ search_tmp = (axis2_char_t *) (AXIS2_MALLOC (env->allocator, sizeof (axis2_char_t) * (length + 1))); strncpy(search_tmp, search, length); search_tmp[length] = '\0'; } else if (axutil_strstr(nc_tmp, search)) { axis2_char_t *comp_tmp = NULL; comp_tmp = axutil_strstr(nc_tmp, search); if (strlen(comp_tmp) == strlen (search)) { nc_tmp = (axis2_char_t *)key; is_matched = AXIS2_TRUE; break; } break; } else { break; } if (search_tmp && axutil_strstr(nc_tmp, search_tmp)) { if (match_start && !(axutil_strncmp(nc_tmp, search, length) == 0)) { break; } else if (!match_start) { match_start = AXIS2_TRUE; } } else { break; } search += axutil_strlen(search_tmp) + 1; nc_tmp = axutil_strstr(nc_tmp, search_tmp) + axutil_strlen(search_tmp); } if (search_tmp) { AXIS2_FREE(env->allocator, search_tmp); search_tmp = NULL; } if (is_matched || !*search) { nc_tmp = (axis2_char_t *)key; is_matched = AXIS2_TRUE; break; } } } } if (!is_matched) { nc_tmp = nc_name; } op = axutil_hash_get(svc->op_alias_map, nc_tmp, AXIS2_HASH_KEY_STRING); if (op) { return op; } return (axis2_op_t *)axutil_hash_get(svc->op_action_map, nc_tmp, AXIS2_HASH_KEY_STRING); }
axis2_status_t sign(axutil_env_t *env, axis2_char_t *filename, openssl_pkey_t *prvkey , oxs_x509_cert_t *cert) { axis2_char_t *signed_result = NULL; axis2_char_t *signed_filename = "result-sign.xml"; axiom_node_t *node = NULL; axiom_node_t *tmpl = NULL; oxs_sign_part_t *sign_part = NULL; oxs_sign_ctx_t *sign_ctx = NULL; oxs_transform_t *tr = NULL; axutil_array_list_t *sign_parts = NULL; axutil_array_list_t *tr_list = NULL; axis2_char_t *id = NULL; axis2_status_t status = AXIS2_FAILURE; FILE *outf; tmpl = load_sample_xml(env , tmpl, filename); if (tmpl) { printf("load_sample_xml SUCCESS\n"); } else { printf("load_sample_xml FAILED"); return -1; } /*Sign specific*/ sign_part = oxs_sign_part_create(env); tr_list = axutil_array_list_create(env, 1); /*We need C14N transform*/ tr = oxs_transforms_factory_produce_transform(env, OXS_HREF_TRANSFORM_XML_EXC_C14N); axutil_array_list_add(tr_list, env, tr); oxs_sign_part_set_transforms(sign_part, env, tr_list); /*We need to sign this node add an ID to it*/ node = axiom_node_get_first_element(tmpl, env); id = /*"Sig-ID-EFG";*/ oxs_util_generate_id(env,(axis2_char_t*)OXS_SIG_ID); oxs_axiom_add_attribute(env, node, OXS_WSU, OXS_WSSE_XMLNS, OXS_ATTR_ID, id); status = oxs_sign_part_set_node(sign_part, env,node); status = oxs_sign_part_set_digest_mtd(sign_part, env, OXS_HREF_SHA1); sign_parts = axutil_array_list_create(env, 1); axutil_array_list_add(sign_parts, env, sign_part); sign_ctx = oxs_sign_ctx_create(env); if(sign_ctx){ axiom_node_t *sig_node = NULL; oxs_sign_ctx_set_private_key(sign_ctx, env, prvkey); oxs_sign_ctx_set_certificate(sign_ctx, env, cert); /*Set sig algo*/ oxs_sign_ctx_set_sign_mtd_algo(sign_ctx, env, OXS_HREF_RSA_SHA1); /*Set C14N method*/ oxs_sign_ctx_set_c14n_mtd(sign_ctx, env, OXS_HREF_XML_EXC_C14N); /*Set sig parts*/ oxs_sign_ctx_set_sign_parts(sign_ctx, env, sign_parts); /*Set the operation*/ oxs_sign_ctx_set_operation(sign_ctx, env, OXS_SIGN_OPERATION_SIGN); /*Sign*/ oxs_xml_sig_sign(env, sign_ctx, tmpl, &sig_node); /*Finally build KeyInfo*/ oxs_xml_key_info_build(env, sig_node, cert, OXS_KIBP_X509DATA_X509CERTIFICATE); }else{ printf("Sign ctx creation failed"); } signed_result = axiom_node_to_string(tmpl, env) ; outf = fopen(signed_filename, "wb"); fwrite(signed_result, 1, axutil_strlen(signed_result), outf); return AXIS2_SUCCESS; }
AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL axis2_svc_get_rest_op_list_with_method_and_location( const axis2_svc_t * svc, const axutil_env_t * env, const axis2_char_t * method, const axis2_char_t * location) { axutil_array_list_t *op_list = NULL; axis2_char_t *key = NULL; axis2_char_t *loc_str = NULL; axis2_char_t *loc_str_tmp = NULL; axis2_char_t *rindex = NULL; int plen; AXIS2_PARAM_CHECK(env->error, method, NULL); AXIS2_PARAM_CHECK(env->error, location, NULL); loc_str_tmp = (axis2_char_t *) location; /* Casted to facilitate loop */ if (loc_str_tmp[1] == '/') { loc_str_tmp++; } /* ignore any '/' at the beginning */ if (strchr(loc_str_tmp, '?')) { axis2_char_t *temp = NULL; temp = strchr(loc_str_tmp, '?'); temp[0] = '\0'; } /* ignore block after '?' */ do { axis2_char_t *temp = NULL; temp = strchr(loc_str_tmp, '{'); if (temp) { loc_str_tmp = temp; } else { loc_str_tmp += strlen(loc_str_tmp); break; } } while (loc_str_tmp[1] && loc_str_tmp[1] == '{'); loc_str = (axis2_char_t *) axutil_strmemdup(location, (loc_str_tmp - location), env); rindex = axutil_rindex(loc_str, '/'); if (rindex && *rindex) { loc_str_tmp = axutil_string_substring_ending_at(loc_str, (int)(rindex - loc_str)); /* We are sure that the difference lies within the int range */ } else { loc_str_tmp = loc_str; } plen = axutil_strlen (method) + axutil_strlen (loc_str_tmp) + 2; key = (axis2_char_t *) (AXIS2_MALLOC (env->allocator, sizeof (axis2_char_t) * plen)); sprintf (key, "%s:%s", method, loc_str_tmp); AXIS2_FREE (env->allocator, loc_str); op_list = (axutil_array_list_t *) axutil_hash_get(svc->op_rest_map, key, AXIS2_HASH_KEY_STRING); AXIS2_FREE (env->allocator, key); return op_list; }
axiom_node_t* AXIS2_CALL adb_getMaxOperationResponseTimeResponse_serialize( adb_getMaxOperationResponseTimeResponse_t* _getMaxOperationResponseTimeResponse, 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[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, _getMaxOperationResponseTimeResponse, NULL); namespaces = axutil_hash_make(env); next_ns_index = &next_ns_index_value; ns1 = axiom_namespace_create (env, "http://org.apache.axis2/xsd", "n"); axutil_hash_set(namespaces, "http://org.apache.axis2/xsd", AXIS2_HASH_KEY_STRING, axutil_strdup(env, "n")); parent_element = axiom_element_create (env, NULL, "getMaxOperationResponseTimeResponse", 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://org.apache.axis2/xsd", 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://org.apache.axis2/xsd", AXIS2_HASH_KEY_STRING, p_prefix); axiom_element_declare_namespace_assume_param_ownership(parent_element, env, axiom_namespace_create (env, "http://org.apache.axis2/xsd", p_prefix)); } if (!_getMaxOperationResponseTimeResponse->is_valid_return) { /* 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("return"))); /* 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("return"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing return element */ sprintf(start_input_str, "<%s%sreturn>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sreturn>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); sprintf (text_value_1, AXIS2_PRINTF_INT64_FORMAT_SPECIFIER, (int64_t) _getMaxOperationResponseTimeResponse->property_return); axutil_stream_write(stream, env, start_input_str, start_input_str_len); 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; }
axiom_node_t* AXIS2_CALL prf_queryPackageListType_serialize_obj( prf_queryPackageListType_t* _queryPackageListType, 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; axis2_char_t *text_value_1_temp; axis2_char_t *text_value_2; axis2_char_t *text_value_2_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; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, _queryPackageListType, 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=\"queryPackageListType\"", 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", "queryPackageListType", 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 (!_queryPackageListType->is_valid_firmwareType) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property firmwareType"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("firmwareType"))); /* 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("firmwareType"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing firmwareType element */ sprintf(start_input_str, "<%s%sfirmwareType>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sfirmwareType>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); text_value_1 = _queryPackageListType->property_firmwareType; 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(!(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 (!_queryPackageListType->is_valid_firmwareVersion) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-nillable property firmwareVersion"); return NULL; } else { start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (4 + axutil_strlen(p_prefix) + axutil_strlen("firmwareVersion"))); /* 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("firmwareVersion"))); /* axutil_strlen("</:>") + 1 = 5 */ /* * parsing firmwareVersion element */ sprintf(start_input_str, "<%s%sfirmwareVersion>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); start_input_str_len = axutil_strlen(start_input_str); sprintf(end_input_str, "</%s%sfirmwareVersion>", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); end_input_str_len = axutil_strlen(end_input_str); text_value_2 = _queryPackageListType->property_firmwareVersion; axutil_stream_write(stream, env, start_input_str, start_input_str_len); text_value_2_temp = axutil_xml_quote_string(env, text_value_2, AXIS2_TRUE); if (text_value_2_temp) { axutil_stream_write(stream, env, text_value_2_temp, axutil_strlen(text_value_2_temp)); AXIS2_FREE(env->allocator, text_value_2_temp); } else { axutil_stream_write(stream, env, text_value_2, axutil_strlen(text_value_2)); } 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; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL oxs_xml_enc_decrypt_data( const axutil_env_t *env, oxs_ctx_t * enc_ctx, axiom_node_t *enc_type_node, oxs_buffer_t *result_buf) { axiom_node_t *enc_mtd_node = NULL; axiom_node_t *cd_node = NULL; axiom_node_t *cv_node = NULL; axis2_char_t *cipher_val = NULL; axis2_char_t *new_cipher_val = NULL; axis2_char_t *sym_algo = NULL; axis2_char_t *type = NULL; axis2_char_t *id = NULL; oxs_buffer_t *input_buf = NULL; axis2_status_t status = AXIS2_FAILURE; /* Get the symmetric encryption algorithm */ enc_mtd_node = oxs_axiom_get_first_child_node_by_name(env, enc_type_node, OXS_NODE_ENCRYPTION_METHOD, OXS_ENC_NS, OXS_XENC); if(!enc_mtd_node) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Cannot find encryption method node"); return AXIS2_FAILURE; } sym_algo = oxs_token_get_encryption_method(env, enc_mtd_node); if(!sym_algo) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Cannot find encryption method"); return AXIS2_FAILURE; } /* Get ID, Type, MimeType attributes from the EncryptedDataNode */ id = oxs_axiom_get_attribute_value_of_node_by_name(env, enc_type_node, OXS_ATTR_ID, NULL); type = oxs_axiom_get_attribute_value_of_node_by_name(env, enc_type_node, OXS_ATTR_TYPE, NULL); /* Populate the context for future use */ oxs_ctx_set_enc_mtd_algorithm(enc_ctx, env, sym_algo); oxs_ctx_set_id(enc_ctx, env, id); oxs_ctx_set_type(enc_ctx, env, type); /* Get the cipher value */ cd_node = oxs_axiom_get_first_child_node_by_name(env, enc_type_node, OXS_NODE_CIPHER_DATA, OXS_ENC_NS, OXS_XENC); if(!cd_node) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Cannot find cipher data node"); return AXIS2_FAILURE; } cv_node = oxs_axiom_get_first_child_node_by_name(env, cd_node, OXS_NODE_CIPHER_VALUE, OXS_ENC_NS, OXS_XENC); if(!cv_node) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Cannot find cipher value node"); return AXIS2_FAILURE; } cipher_val = oxs_token_get_cipher_value(env, cv_node); if(!cipher_val) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart]Cannot find cipher value"); return AXIS2_FAILURE; } /* We need to remove new lines if any */ new_cipher_val = oxs_util_get_newline_removed_string(env, cipher_val); /* Create input buffer with cipher data obtained */ input_buf = oxs_buffer_create(env); oxs_buffer_populate(input_buf, env, (unsigned char*)new_cipher_val, axutil_strlen(new_cipher_val)); /* Decrypt */ oxs_ctx_set_operation(enc_ctx, env, OXS_CTX_OPERATION_DECRYPT); status = oxs_encryption_symmetric_crypt(env, enc_ctx, input_buf, result_buf); /*Free*/ oxs_buffer_free(input_buf, env); input_buf = NULL; AXIS2_FREE(env->allocator, new_cipher_val); new_cipher_val = NULL; return status; }
axiom_node_t* AXIS2_CALL axis2_getQuoteRequest_serialize( axis2_getQuoteRequest_t* getQuoteRequest, const axutil_env_t *env, axiom_node_t* parent, int has_parent) { axiom_namespace_t *ns1 = NULL; axis2_char_t *text_value_1; axiom_node_t *current_node = NULL; axiom_element_t *current_element = NULL; axiom_data_source_t *data_source = NULL; axutil_stream_t *stream = 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; AXIS2_ENV_CHECK(env, NULL); ns1 = axiom_namespace_create (env, "http://www.wso2.org/types", "ns1"); if( parent == NULL) { current_element = axiom_element_create (env, parent, "getQuoteRequest", ns1 , ¤t_node); axiom_element_set_namespace( current_element, env, ns1, current_node); parent = current_node; } if(has_parent) { data_source = axiom_node_get_data_element(parent, 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; current_node = parent; } else { data_source = axiom_data_source_create(env, parent, ¤t_node); stream = axiom_data_source_get_stream(data_source, env); } /** * parsing symbol element */ start_input_str = "<ns1:symbol>"; start_input_str_len = axutil_strlen(start_input_str); end_input_str = "</ns1:symbol>"; end_input_str_len = axutil_strlen(end_input_str); text_value_1 = getQuoteRequest->attrib_symbol; axutil_stream_write(stream, env, start_input_str, start_input_str_len); 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); return parent; }