AXIS2_EXTERN axiom_node_t* AXIS2_CALL load_sample_xml(const axutil_env_t *env, axiom_node_t* tmpl, axis2_char_t* filename ) { axiom_document_t *doc = NULL; axiom_stax_builder_t *builder = NULL; axiom_xml_reader_t *reader = NULL; /*axiom_xml_writer_t *writer = NULL;*/ reader = axiom_xml_reader_create_for_file(env, filename, NULL); if (!reader) printf("\n Reader is NULL"); builder = axiom_stax_builder_create(env, reader); if (!builder) printf("\n builder is NULL"); doc = axiom_document_create(env, NULL, builder); if (!doc) printf("\n doc is NULL"); tmpl = axiom_document_build_all(doc, env); axiom_stax_builder_free_self(builder, env); builder = NULL; /* tmpl = axiom_document_get_root_element(doc, env);*/ if (!tmpl) printf("\n tmpl is NULL"); return tmpl; }
/* {{{ ws_read_payload */ axiom_node_t * wsf_util_read_payload ( axiom_xml_reader_t * reader, const axutil_env_t * env) { axiom_stax_builder_t *builder = NULL; axiom_document_t *document = NULL; axiom_node_t *payload = NULL; builder = axiom_stax_builder_create (env, reader); if (!builder) { return NULL; } document = axiom_stax_builder_get_document (builder, env); if (!document) { return NULL; } payload = axiom_document_get_root_element (document, env); if (!payload) { return NULL; } axiom_document_build_all (document, env); /** free stax builder and associated document only */ axiom_stax_builder_free_self (builder, env); return payload; }
void create_axiom_from_string(const axutil_env_t* env, axis2_char_t* buffer, axiom_node_t** node) { axiom_xml_reader_t* xml_reader = NULL; axiom_document_t* document = NULL; axiom_stax_builder_t* om_builder = NULL; xml_reader = axiom_xml_reader_create_for_memory(env, buffer, strlen(buffer), NULL, AXIS2_XML_PARSER_TYPE_BUFFER); /* encoding ?? */ if (!xml_reader) { AXIS2_LOG_ERROR_MSG(env->log, "[wsf_wsdl_test]Failed to create wsdl_xml_reader\n"); return; } om_builder = axiom_stax_builder_create(env, xml_reader); if (!om_builder) { AXIS2_LOG_ERROR_MSG(env->log, "[wsf_wsdl_test]Failed to create wsdl stax builder\n"); axiom_xml_reader_free(xml_reader, env); return; } document = axiom_stax_builder_get_document(om_builder, env); if (!document) { AXIS2_LOG_ERROR_MSG(env->log, "[wsf_wsdl_test]Failed to get retrieve wsdl document\n"); axiom_stax_builder_free(om_builder, env); return; } *node = axiom_document_build_all(document, env); return; }
static int ngx_squ_xml_parse(squ_State *l) { char *name; ngx_str_t xml; axiom_node_t *node; axutil_env_t *env; axutil_log_t *log; axutil_error_t *error; axiom_element_t *elem; axiom_document_t *doc; ngx_squ_thread_t *thr; axutil_allocator_t *a; axiom_xml_reader_t *reader; axiom_stax_builder_t *builder; thr = ngx_squ_thread(l); ngx_log_debug0(NGX_LOG_DEBUG_CORE, thr->log, 0, "squ xml parse"); xml.data = (u_char *) squL_checklstring(l, -1, &xml.len); squ_createtable(l, 2, 2); a = ngx_squ_axis2c_allocator_create(thr); log = ngx_squ_axis2c_log_create(thr); error = axutil_error_create(a); env = axutil_env_create_with_error_log(a, error, log); reader = axiom_xml_reader_create_for_memory(env, xml.data, xml.len, NULL, AXIS2_XML_PARSER_TYPE_BUFFER); builder = axiom_stax_builder_create(env, reader); doc = axiom_stax_builder_get_document(builder, env); node = axiom_document_get_root_element(doc, env); if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) { return 1; } elem = axiom_node_get_data_element(node, env); name = axiom_element_get_localname(elem, env); squ_newtable(l); ngx_squ_xml_parse_children(l, env, node, elem); squ_setfield(l, -2, name); return 1; }
axiom_node_t * wsf_wsdl_util_deserialize_buffer( const axutil_env_t* env, axis2_char_t* buffer) { axiom_node_t* payload = NULL; axiom_document_t* document = NULL; axiom_xml_reader_t* reader = NULL; axiom_stax_builder_t* builder = NULL; reader = axiom_xml_reader_create_for_memory (env, buffer, axutil_strlen (buffer), WSF_WSDL_ENCODING_UTF_8, AXIS2_XML_PARSER_TYPE_BUFFER); if (reader) { builder = axiom_stax_builder_create (env, reader); } if (builder) { document = axiom_stax_builder_get_document (builder, env); } if (document) { payload = axiom_document_build_all (document, env); } if (builder) { axiom_stax_builder_free_self (builder, env); } if (!payload) { AXIS2_LOG_ERROR_MSG(env->log, "Deserialization failed.."); } return payload; }
axiom_node_t * wsclient_soap_header ( const axutil_env_t *env, char *input_buffer) { axiom_xml_reader_t *reader; axiom_stax_builder_t *builder; axiom_document_t *doc; axiom_node_t *node; char *input; input = input_buffer; if (input) reader = axiom_xml_reader_create_for_memory (env, input, strlen (input), NULL, AXIS2_XML_PARSER_TYPE_BUFFER); else return WSCLIENT_FAILURE; if (reader) { axiom_xml_reader_init (); builder = axiom_stax_builder_create (env, reader); } else return WSCLIENT_FAILURE; if (builder) { doc = axiom_stax_builder_get_document (builder, env); if (doc) axiom_document_build_all (doc, env); else return WSCLIENT_FAILURE; node = axiom_document_get_root_element (doc, env); } else { axiom_xml_reader_free (reader, env); return WSCLIENT_FAILURE; } return node; }
axiom_soap_envelope_t * wsdl_util_create_soap_envelope_from_buffer( const axutil_env_t * env, axis2_char_t* buffer, axis2_char_t * soap_version_uri) { axiom_soap_envelope_t *soap_envelope = NULL; axiom_soap_builder_t *soap_builder = NULL; axiom_xml_reader_t *reader = NULL; axiom_stax_builder_t *builder = NULL; reader = axiom_xml_reader_create_for_memory(env, buffer, axutil_strlen(buffer), WSF_WSDL_ENCODING_UTF_8, AXIS2_XML_PARSER_TYPE_BUFFER); builder = axiom_stax_builder_create(env, reader); soap_builder = axiom_soap_builder_create(env, builder, soap_version_uri); soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env); return soap_envelope; }
axiom_node_t * wsf_wsdl_util_deserialize_file( const axutil_env_t* env, axis2_char_t* file_name) { axiom_node_t* payload = NULL; axiom_document_t* document = NULL; axiom_xml_reader_t* reader = NULL; axiom_stax_builder_t* builder = NULL; reader = axiom_xml_reader_create_for_file (env, file_name, WSF_WSDL_ENCODING_UTF_8); if (reader) { builder = axiom_stax_builder_create (env, reader); } if (builder) { document = axiom_stax_builder_get_document (builder, env); } if (document) { payload = axiom_document_build_all (document, env); } if (builder) { axiom_stax_builder_free_self (builder, env); } if (!payload) { AXIS2_LOG_ERROR_MSG(env->log, "Deserialization failed.."); } return payload; }
WSF_WSDL_EXTERN axis2_bool_t WSF_WSDL_CALL wsdl_util_create_type_map( const axutil_env_t* env, axis2_char_t* type_map_xml_file, axiom_node_t** type_map) { axiom_xml_reader_t* typemap_xml_reader = NULL; axiom_document_t* typemap_document = NULL; axiom_stax_builder_t* typemap_om_builder = NULL; typemap_xml_reader = axiom_xml_reader_create_for_file(env, type_map_xml_file, NULL); /* encoding ?? */ if (!typemap_xml_reader) { AXIS2_LOG_ERROR_MSG(env->log, "Failed to create xml reader for typemap"); return AXIS2_FAILURE; } typemap_om_builder = axiom_stax_builder_create(env, typemap_xml_reader); if (!typemap_om_builder) { AXIS2_LOG_ERROR_MSG(env->log, "Failed to create om builder for typemap"); axiom_xml_reader_free(typemap_xml_reader, env); return AXIS2_FAILURE; } typemap_document = axiom_stax_builder_get_document(typemap_om_builder, env); if (!typemap_document) { AXIS2_LOG_ERROR_MSG(env->log, "Failed to create document for typemap"); axiom_stax_builder_free(typemap_om_builder, env); return AXIS2_FAILURE; } *type_map = axiom_document_build_all(typemap_document, env); axiom_stax_builder_free_self(typemap_om_builder, env); return AXIS2_SUCCESS; }
axiom_node_t * wsf_util_deserialize_buffer ( const axutil_env_t * env, char *buffer) { axiom_xml_reader_t *reader = NULL; axiom_stax_builder_t *builder = NULL; axiom_document_t *document = NULL; axiom_node_t *payload = NULL; reader = axiom_xml_reader_create_for_memory (env, buffer, axutil_strlen (buffer), "utf-8", AXIS2_XML_PARSER_TYPE_BUFFER); if (!reader) { return NULL; } builder = axiom_stax_builder_create (env, reader); if (!builder) { return NULL; } document = axiom_stax_builder_get_document (builder, env); if (!document) { AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "Document is not found"); return NULL; } payload = axiom_document_get_root_element (document, env); if (!payload) { AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "Root element of the document \ is not found"); return NULL; }
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"); 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); out_stream = axutil_stream_create_basic(env); 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; }
AXIS2_EXTERN axiom_soap_envelope_t* AXIS2_CALL axis2_amqp_util_get_soap_envelope( axis2_amqp_response_t* response, const axutil_env_t* env, axis2_msg_ctx_t* msg_ctx) { axiom_xml_reader_t* xml_reader = NULL; axiom_stax_builder_t* stax_builder = NULL; axiom_soap_builder_t* soap_builder = NULL; axiom_soap_envelope_t* soap_envelope = NULL; const axis2_char_t* soap_ns_uri = NULL; axis2_char_t *soap_body_str = NULL; int soap_body_len = 0; axis2_bool_t is_mtom = AXIS2_FALSE; axutil_hash_t *binary_data_map = NULL; axis2_bool_t is_soap_11 = AXIS2_FALSE; if(!response || !response->data || !response->content_type) { return NULL; } is_soap_11 = axis2_msg_ctx_get_is_soap_11(msg_ctx, env); /* Handle MTOM */ if(strstr(response->content_type, AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED)) { axis2_char_t* mime_boundary = axis2_amqp_util_get_value_from_content_type(env, response->content_type, AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY); if(mime_boundary) { axiom_mime_parser_t *mime_parser = NULL; int soap_body_len = 0; axutil_param_t *buffer_size_param = NULL; axutil_param_t *max_buffers_param = NULL; axutil_param_t *attachment_dir_param = NULL; axis2_char_t *value_size = NULL; axis2_char_t *value_num = NULL; axis2_char_t *value_dir = NULL; int size = 0; int num = 0; mime_parser = axiom_mime_parser_create(env); buffer_size_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_BUFFER_SIZE); if(buffer_size_param) { value_size = (axis2_char_t *)axutil_param_get_value(buffer_size_param, env); if(value_size) { size = atoi(value_size); axiom_mime_parser_set_buffer_size(mime_parser, env, size); } } max_buffers_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_MAX_BUFFERS); if(max_buffers_param) { value_num = (axis2_char_t*)axutil_param_get_value(max_buffers_param, env); if(value_num) { num = atoi(value_num); axiom_mime_parser_set_max_buffers(mime_parser, env, num); } } attachment_dir_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_ATTACHMENT_DIR); if(attachment_dir_param) { value_dir = (axis2_char_t*)axutil_param_get_value(attachment_dir_param, env); if(value_dir) { axiom_mime_parser_set_attachment_dir(mime_parser, env, value_dir); } } if(mime_parser) { axis2_callback_info_t* callback_ctx = NULL; axutil_stream_t* stream = NULL; callback_ctx = (axis2_callback_info_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_callback_info_t)); stream = axutil_stream_create_basic(env); if(stream) { axutil_stream_write(stream, env, response->data, response->length); callback_ctx->env = env; callback_ctx->in_stream = stream; callback_ctx->content_length = response->length; callback_ctx->unread_len = response->length; callback_ctx->chunked_stream = NULL; } /*binary_data_map = axiom_mime_parser_parse(mime_parser, env, axis2_amqp_util_on_data_request, (void*)callback_ctx, mime_boundary);*/ if(!binary_data_map) { return AXIS2_FAILURE; } soap_body_len = axiom_mime_parser_get_soap_body_len(mime_parser, env); soap_body_str = axiom_mime_parser_get_soap_body_str(mime_parser, env); axutil_stream_free(stream, env); AXIS2_FREE(env->allocator, callback_ctx); axiom_mime_parser_free(mime_parser, env); } AXIS2_FREE(env->allocator, mime_boundary); } is_mtom = AXIS2_TRUE; } else { soap_body_str = response->data; soap_body_len = axutil_strlen(response->data); } soap_body_len = axutil_strlen(soap_body_str); xml_reader = axiom_xml_reader_create_for_memory(env, soap_body_str, soap_body_len, NULL, AXIS2_XML_PARSER_TYPE_BUFFER); if(!xml_reader) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Reader"); return NULL; } stax_builder = axiom_stax_builder_create(env, xml_reader); if(!stax_builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create StAX Builder"); return NULL; } soap_ns_uri = is_soap_11 ? AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI : AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; soap_builder = axiom_soap_builder_create(env, stax_builder, soap_ns_uri); if(!soap_builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create SOAP Builder"); return NULL; } if(binary_data_map) { axiom_soap_builder_set_mime_body_parts(soap_builder, env, binary_data_map); } soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env); return soap_envelope; }
axis2_status_t axis2_amqp_process_request( const axutil_env_t* env, axis2_amqp_request_processor_resource_pack_t* request_resource_pack) { axiom_xml_reader_t* xml_reader = NULL; axiom_stax_builder_t* stax_builder = NULL; axiom_soap_builder_t* soap_builder = NULL; axis2_transport_out_desc_t* out_desc = NULL; axis2_transport_in_desc_t* in_desc = NULL; axis2_msg_ctx_t* msg_ctx = NULL; axiom_soap_envelope_t* soap_envelope = NULL; axis2_engine_t* engine = NULL; const axis2_char_t* soap_ns_uri = NULL; axis2_bool_t is_soap_11 = AXIS2_FALSE; axis2_char_t *soap_body_str = NULL; int soap_body_len = 0; axis2_bool_t is_mtom = AXIS2_FALSE; axis2_status_t status = AXIS2_FAILURE; axutil_hash_t *binary_data_map = NULL; axiom_soap_body_t *soap_body = NULL; axutil_property_t* reply_to_property = NULL; /* Create msg_ctx */ if(!request_resource_pack->conf_ctx) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Conf Context not Available"); return AXIS2_FAILURE; } out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf( request_resource_pack->conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_AMQP); if(!out_desc) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport Out Descriptor not Found"); return AXIS2_FAILURE; } in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(request_resource_pack->conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_AMQP); if(!in_desc) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport In Descriptor not Found"); return AXIS2_FAILURE; } /* Create msg_ctx */ msg_ctx = axis2_msg_ctx_create(env, request_resource_pack->conf_ctx, in_desc, out_desc); axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE); /* Handle MTOM */ if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED)) { axis2_char_t* mime_boundary = axis2_amqp_util_get_value_from_content_type(env, request_resource_pack->content_type, AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY); if(mime_boundary) { axiom_mime_parser_t *mime_parser = NULL; int soap_body_len = 0; axutil_param_t *buffer_size_param = NULL; axutil_param_t *max_buffers_param = NULL; axutil_param_t *attachment_dir_param = NULL; axis2_char_t *value_size = NULL; axis2_char_t *value_num = NULL; axis2_char_t *value_dir = NULL; int size = 0; int num = 0; mime_parser = axiom_mime_parser_create(env); buffer_size_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_BUFFER_SIZE); if(buffer_size_param) { value_size = (axis2_char_t*)axutil_param_get_value(buffer_size_param, env); if(value_size) { size = atoi(value_size); axiom_mime_parser_set_buffer_size(mime_parser, env, size); } } max_buffers_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_MAX_BUFFERS); if(max_buffers_param) { value_num = (axis2_char_t*)axutil_param_get_value(max_buffers_param, env); if(value_num) { num = atoi(value_num); axiom_mime_parser_set_max_buffers(mime_parser, env, num); } } /* If this paramter is there mime_parser will cached the attachment * using to the directory for large attachments. */ attachment_dir_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_ATTACHMENT_DIR); if(attachment_dir_param) { value_dir = (axis2_char_t*)axutil_param_get_value(attachment_dir_param, env); if(value_dir) { axiom_mime_parser_set_attachment_dir(mime_parser, env, value_dir); } } if(mime_parser) { axis2_callback_info_t *callback_ctx = NULL; axutil_stream_t *stream = NULL; callback_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_callback_info_t)); stream = axutil_stream_create_basic(env); if(stream) { axutil_stream_write(stream, env, request_resource_pack->request_content, request_resource_pack->content_length); callback_ctx->env = env; callback_ctx->in_stream = stream; callback_ctx->content_length = request_resource_pack->content_length; callback_ctx->unread_len = request_resource_pack->content_length; callback_ctx->chunked_stream = NULL; } /*binary_data_map = axiom_mime_parser_parse(mime_parser, env, axis2_amqp_util_on_data_request, (void*)callback_ctx, mime_boundary);*/ if(!binary_data_map) { return AXIS2_FAILURE; } soap_body_str = axiom_mime_parser_get_soap_body_str(mime_parser, env); soap_body_len = axiom_mime_parser_get_soap_body_len(mime_parser, env); axutil_stream_free(stream, env); AXIS2_FREE(env->allocator, callback_ctx); axiom_mime_parser_free(mime_parser, env); } AXIS2_FREE(env->allocator, mime_boundary); } is_mtom = AXIS2_TRUE; } else { soap_body_str = request_resource_pack->request_content; soap_body_len = request_resource_pack->content_length; } soap_body_len = axutil_strlen(soap_body_str); xml_reader = axiom_xml_reader_create_for_memory(env, soap_body_str, soap_body_len, NULL, AXIS2_XML_PARSER_TYPE_BUFFER); if(!xml_reader) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Reader"); return AXIS2_FAILURE; } stax_builder = axiom_stax_builder_create(env, xml_reader); if(!stax_builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create StAX Builder"); return AXIS2_FAILURE; } soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; if(request_resource_pack->content_type) { if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML)) { is_soap_11 = AXIS2_TRUE; soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; } /*if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_APPL_SOAP)) { is_soap_11 = AXIS2_FALSE; soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; } else if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML)) { is_soap_11 = AXIS2_TRUE; soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; }*/ } soap_builder = axiom_soap_builder_create(env, stax_builder, soap_ns_uri); if(!soap_builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create SOAP Builder"); return AXIS2_FAILURE; } if(binary_data_map) { axiom_soap_builder_set_mime_body_parts(soap_builder, env, binary_data_map); } soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env); axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope); soap_body = axiom_soap_envelope_get_body(soap_envelope, env); if(!soap_body) { return AXIS2_FAILURE; } /* SOAPAction */ if(request_resource_pack->soap_action) { axis2_msg_ctx_set_soap_action(msg_ctx, env, axutil_string_create(env, request_resource_pack->soap_action)); } /* SOAP version */ axis2_msg_ctx_set_is_soap_11(msg_ctx, env, is_soap_11); /* Set ReplyTo in the msg_ctx as a property. This is used by the server when * 1. WS-A is not in use * 2. ReplyTo is an anonymous EPR - Sandesha2/Dual-channel */ reply_to_property = axutil_property_create_with_args(env, AXIS2_SCOPE_REQUEST, 0, 0, (void*)request_resource_pack->reply_to); axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO, reply_to_property); engine = axis2_engine_create(env, request_resource_pack->conf_ctx); if(AXIS2_TRUE == axiom_soap_body_has_fault(soap_body, env)) { status = axis2_engine_receive_fault(engine, env, msg_ctx); } else { status = axis2_engine_receive(engine, env, msg_ctx); } if(engine) { axis2_engine_free(engine, env); } if(soap_body_str && is_mtom) { AXIS2_FREE(env->allocator, soap_body_str); } return status; }
/* Process a request. If the request has a response the response structure will be populated */ AXIS2_EXTERN axis2_bool_t AXIS2_CALL axis2_udp_receiver_process_request( const axutil_env_t * env, axis2_conf_ctx_t *conf_ctx, axis2_udp_request_t * request, axis2_udp_response_t * responce) { 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 *out_stream = NULL; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "start:axis2_udp_worker_process_request"); if (!conf_ctx) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "conf ctx not available"); return AXIS2_FAILURE; } reader = axiom_xml_reader_create_for_memory(env, request->buff, request->buf_size, 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, AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI); if (!soap_builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create SOAP builder"); return AXIS2_FAILURE; } out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf(conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_UDP); 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_UDP); msg_ctx = axis2_msg_ctx_create(env, conf_ctx, in_desc, out_desc); axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE); out_stream = axutil_stream_create_basic(env); 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); if (request->svc) { axis2_msg_ctx_set_svc(msg_ctx, env, request->svc); } if (request->op) { axis2_msg_ctx_set_op(msg_ctx, env, request->op); } engine = axis2_engine_create(env, conf_ctx); status = axis2_engine_receive(engine, env, msg_ctx); responce->buff = axutil_stream_get_buffer(out_stream, env); responce->buf_size = axutil_stream_get_len(out_stream, env); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "end:axis2_udp_worker_process_request"); return AXIS2_SUCCESS; }
axiom_node_t * return_policy_element( axis2_char_t * name, const axutil_env_t * env, axis2_char_t * wsdl_name) { axiom_element_t *ele1 = NULL, *ele2 = NULL; axiom_document_t *document = NULL; axiom_node_t *node1 = NULL, *node2 = NULL, *policy_node = NULL; axiom_namespace_t *ns = NULL; axiom_xml_reader_t *reader = NULL; axiom_stax_builder_t *builder = NULL; char *buffer = NULL; axiom_attribute_t *attr = NULL; axis2_char_t *value = NULL; axis2_char_t *val = NULL; axutil_hash_t *attr_hash = NULL; axis2_char_t *xml_output = NULL; axutil_hash_index_t *hi; /* f = fopen(wsdl_name, "r"); if (!f) return NULL; reader = axiom_xml_reader_create_for_io(env, read_input, NULL , NULL, NULL); */ reader = axiom_xml_reader_create_for_file(env, wsdl_name, NULL); if (!reader) { printf("ERROR CREATING PULLPARSER"); return NULL; } builder = axiom_stax_builder_create(env, reader); if (!builder) { printf("ERROR CREATING PULL PARSER"); return NULL; } document = axiom_stax_builder_get_document(builder, env); if (!document) return NULL; node1 = axiom_document_get_root_element(document, env); if (!node1) { printf(" root element null "); axiom_stax_builder_free(builder, env); return NULL; } do { node2 = axiom_document_build_next(document, env); if (!node2) break; if (axiom_node_get_node_type(node2, env) == AXIOM_ELEMENT) { ele2 = (axiom_element_t *) axiom_node_get_data_element(node2, env); attr_hash = axiom_element_get_all_attributes(ele2, env); if (attr_hash) { hi = axutil_hash_first(attr_hash, env); axutil_hash_this(hi, NULL, NULL, &attr); if (axutil_strcmp(axiom_attribute_get_value(attr, env), name) == 0) { policy_node = node2; } } } } while (node2); return policy_node; }
AXIS2_EXTERN axutil_array_list_t* AXIS2_CALL security_admin_load_scenarios( const axutil_env_t* env, axis2_msg_ctx_t* msg_ctx) { /* Read senarios from config file*/ axis2_conf_ctx_t* conf_ctx = NULL; axis2_char_t* repo_path = NULL; axis2_char_t* scenario_config_file_path = NULL; axiom_xml_reader_t* xml_reader = NULL; axiom_document_t* document = NULL; axiom_stax_builder_t* stax_builder = NULL; axiom_node_t* scenario_config_root_node = NULL; axiom_element_t* scenario_config_root_element = NULL; axiom_children_iterator_t* children_ite = NULL; axutil_array_list_t* scenarios = NULL; /* Form absolute path to config file*/ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); repo_path = axis2_conf_ctx_get_root_dir(conf_ctx, env); scenario_config_file_path = axutil_strcat(env, repo_path, AXIS2_PATH_SEP_STR, "services", AXIS2_PATH_SEP_STR, "SecurityAdminService", AXIS2_PATH_SEP_STR, "scenario-config.xml", NULL); xml_reader = axiom_xml_reader_create_for_file(env, scenario_config_file_path, NULL); AXIS2_FREE(env->allocator, scenario_config_file_path); if (!xml_reader) return NULL; stax_builder = axiom_stax_builder_create(env, xml_reader); if (!stax_builder) return NULL; document = axiom_stax_builder_get_document(stax_builder, env); if (!document) return NULL; /* Build XML document*/ axiom_document_build_all(document, env); scenario_config_root_node = axiom_document_get_root_element(document, env); scenario_config_root_element = axiom_node_get_data_element(scenario_config_root_node, env); axiom_stax_builder_free_self(stax_builder, env); children_ite = axiom_element_get_children(scenario_config_root_element, env, scenario_config_root_node); if (children_ite) { /* Get Scenario nodes and build hash*/ while (axiom_children_iterator_has_next(children_ite, env)) { axiom_node_t* node = NULL; node = axiom_children_iterator_next(children_ite, env); if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT) { axis2_char_t* localname = NULL; axiom_element_t* scenario_ele = NULL; axiom_children_iterator_t* ite = NULL; scenario_ele = axiom_node_get_data_element(node, env); localname = axiom_element_get_localname(scenario_ele, env); if (0 == axutil_strcmp(localname, "Scenario")) /* Scenario */ { axis2_char_t* id = NULL; security_admin_scenario_data_t* data = NULL; /* Create scenarios hash*/ if (!scenarios) scenarios = axutil_array_list_create(env, SEC_ADMIN_SCENARIO_COUNT); data = security_admin_scenario_data_create(env); /* Current scenario*/ security_admin_scenario_data_set_current_scenario(data, AXIS2_TRUE); /* id*/ id = axiom_element_get_attribute_value_by_name(scenario_ele, env, "id"); security_admin_scenario_data_set_id(data, axutil_strdup(env, id)); ite = axiom_element_get_children(scenario_ele, env, node); while (axiom_children_iterator_has_next(ite, env)) { axiom_node_t* node = NULL; node = axiom_children_iterator_next(ite, env); if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT) { axiom_element_t* node_ele = NULL; axis2_char_t* localname = NULL; axis2_char_t* text = NULL; node_ele = axiom_node_get_data_element(node, env); localname = axiom_element_get_localname(node_ele, env); text = axiom_element_get_text(node_ele, env, node); if (0 == axutil_strcmp(localname, "Summary")) /* Summary */ { security_admin_scenario_data_set_summary(data, axutil_strdup(env, text)); } else if (0 == axutil_strcmp(localname, "Description")) /* Description */ { security_admin_scenario_data_set_description(data, axutil_strdup(env, text)); } else if (0 == axutil_strcmp(localname, "Category")) /* Category */ { security_admin_scenario_data_set_category(data, axutil_strdup(env, text)); } /*else if (0 == axutil_strcmp(localname, "WsuId")*/ /* WsuId */ /*{ }*/ else if (0 == axutil_strcmp(localname, "Type")) /* Type */ { security_admin_scenario_data_set_type(data, axutil_strdup(env, text)); } else if (0 == axutil_strcmp(localname, "Modules")) /* Modules */ { } } } /* Add scenario data into the hash map*/ axutil_array_list_add(scenarios, env, data); } } } } return scenarios; }