AXIS2_EXTERN axiom_node_t *AXIS2_CALL axiom_soap_header_get_base_node( axiom_soap_header_t * soap_header, const axutil_env_t * env) { if(!soap_header->om_ele_node) { axiom_node_t *parent_node = NULL; axiom_element_t *parent_ele = NULL; axiom_namespace_t *parent_ns = NULL; axiom_element_t *this_ele = NULL; axiom_node_t *this_node = NULL; axiom_soap_body_t *soap_body = NULL; axiom_node_t *body_node = NULL; parent_node = axiom_soap_envelope_get_base_node(soap_header->soap_envelope, env); if(!parent_node || axiom_node_get_node_type(parent_node, env) != AXIOM_ELEMENT) { axiom_soap_header_free(soap_header, env); return NULL; } parent_ele = (axiom_element_t *)axiom_node_get_data_element(parent_node, env); if(!parent_ele) { axiom_soap_header_free(soap_header, env); return NULL; } parent_ns = axiom_element_get_namespace(parent_ele, env, parent_node); this_ele = axiom_element_create(env, NULL, AXIOM_SOAP_HEADER_LOCAL_NAME, parent_ns, &this_node); if(!this_ele) { axiom_soap_header_free(soap_header, env); return NULL; } soap_body = axiom_soap_envelope_get_body(soap_header->soap_envelope, env); if(soap_body) { body_node = axiom_soap_body_get_base_node(soap_body, env); axiom_node_insert_sibling_before(body_node, env, this_node); } else { axiom_node_add_child(parent_node, env, this_node); } soap_header->om_ele_node = this_node; } return soap_header->om_ele_node; }
WSF_WSDL_EXTERN axis2_bool_t WSF_WSDL_CALL wsf_wsdl_request( const axutil_env_t* env, axis2_char_t* wsdl_file_name, const axis2_char_t* operation_name, wsf_wsdl_data_t* parameters, axis2_char_t* script_binding_home, axis2_svc_client_t* svc_client, axutil_hash_t* svc_client_user_options, axis2_char_t* service_name, axis2_char_t* port_name, wsf_wsdl_data_t** response) { int soap_version = 2; int has_fault = AXIS2_FALSE; int binding_style = WSDL_BINDING_STYLE_DOC_LIT_W; axis2_char_t* payload = NULL; axiom_node_t* payload_node = NULL; axis2_char_t* request_buffer = NULL; axiom_node_t* type_map = NULL; axis2_char_t *res_text = NULL; axiom_node_t* sig_axiom = NULL; axiom_node_t *fault_node = NULL; axiom_node_t* wsdl_axiom = NULL; axiom_node_t* params_node = NULL; axiom_node_t* returns_node = NULL; axiom_soap_body_t *soap_body = NULL; axiom_node_t *body_base_node = NULL; /*axis2_char_t *wrapper_element = NULL;*/ axiom_node_t* operation_axiom = NULL; axiom_soap_fault_t *soap_fault = NULL; axis2_options_t *client_options = NULL; /*axis2_char_t *wrapper_element_ns = NULL;*/ /*axiom_node_t *axiom_soap_base_node = NULL; */ axiom_soap_envelope_t *response_envelope = NULL; wsf_wsdl_data_template_t* input_template = NULL; wsf_wsdl_data_template_t* output_template = NULL; axis2_bool_t is_version1_wsdl = AXIS2_FALSE; axis2_char_t* xslt_location = NULL; axis2_char_t* type_map_file = NULL; AXIS2_LOG_TRACE_MSG(env->log, "Starting execution of wsf_wsdl_request..."); xslt_location = axutil_strcat(env, script_binding_home, WSF_WSDL_XSLT_LOCATION_POSTFIX, NULL); type_map_file = axutil_strcat(env, script_binding_home, WSF_WSDL_TYPE_MAP_POSTFIX, NULL); client_options = (axis2_options_t *)axis2_svc_client_get_options(svc_client, env); axis2_options_set_xml_parser_reset(client_options, env, AXIS2_FALSE); if (!wsf_wsdl_parser_load_wsdl(env, wsdl_file_name, xslt_location, &wsdl_axiom, &sig_axiom, &is_version1_wsdl, AXIS2_FALSE)) return AXIS2_FALSE; wsdl_util_create_type_map(env, type_map_file, &type_map); wsdl_util_manage_client_options(env, svc_client, svc_client_user_options, client_options, operation_name, wsdl_axiom, is_version1_wsdl, sig_axiom, service_name, port_name, &operation_axiom, &soap_version); wsdl_util_identify_binding_style(env, operation_axiom, &binding_style); if (!operation_axiom) { AXIS2_LOG_ERROR_MSG(env->log, "Operation axiom is NULL"); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } wsdl_util_get_params_node(env, operation_axiom, ¶ms_node); wsdl_util_get_returns_node(env, operation_axiom, &returns_node); wsdl_data_util_axiom_to_template(env, params_node, &input_template); wsdl_data_util_axiom_to_template(env, returns_node, &output_template); #ifdef WSDL_DEBUG_MODE { axis2_char_t* buffer = NULL; wsdl_data_util_serialize_data(env, parameters, &buffer); AXIS2_LOG_DEBUG_MSG(env->log, buffer); AXIS2_FREE(env->allocator, buffer); wsdl_data_util_serialize_template(env, input_template, &buffer); AXIS2_LOG_DEBUG_MSG(env->log, buffer); AXIS2_FREE(env->allocator, buffer); buffer = NULL; } #endif if (wsdl_data_util_validate_data(env, type_map, input_template, parameters, VALIDATION_CRITERIA_REQUEST_MODE_TYPE) == AXIS2_TRUE) { payload_node = wsdl_data_util_create_payload(env, parameters, binding_style); payload = payload_node? axiom_node_to_string(payload_node, env) : NULL; // axiom_node_free_tree(payload_node, env); } else { AXIS2_LOG_ERROR_MSG(env->log, "User data is not valid or not in proper format"); if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } if (!payload_node) { AXIS2_LOG_ERROR_MSG(env->log, "Request payload is not found"); if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } request_buffer = (axis2_char_t*)wsdl_util_create_request_envelope(env, payload_node, soap_version); if (!request_buffer) { AXIS2_LOG_ERROR_MSG(env->log, "Error in creating request payload dom"); if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } response_envelope = (axiom_soap_envelope_t*)wsdl_util_send_receive_soap_envelope_with_op_client(env, svc_client, client_options, request_buffer); if (response_envelope) { has_fault = AXIS2_TRUE; soap_body = axiom_soap_envelope_get_body (response_envelope, env); if (soap_body) { soap_fault = axiom_soap_body_get_fault (soap_body, env); } if (soap_fault) { soap_version = axis2_options_get_soap_version(client_options, env); fault_node = axiom_soap_fault_get_base_node(soap_fault, env); if (fault_node) { res_text = axiom_node_to_string(fault_node, env); AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI, "Fault payload is %s", res_text); if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } } if (soap_body) { body_base_node = axiom_soap_body_get_base_node(soap_body, env); } if (body_base_node && !soap_fault) { axis2_char_t *response_buffer = NULL; wsf_wsdl_data_t *response_data = NULL; response_buffer = axiom_node_to_string(body_base_node, env); AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI, "Response buffer is %s", response_buffer); AXIS2_FREE(env->allocator, response_buffer); wsdl_data_util_axiom_to_data(env, body_base_node, &response_data); #ifdef WSDL_DEBUG_MODE { axis2_char_t* buffer = NULL; wsdl_data_util_serialize_data(env, response_data, &buffer); AXIS2_LOG_DEBUG_MSG(env->log, buffer); AXIS2_FREE(env->allocator, buffer); wsdl_data_util_serialize_template(env, output_template, &buffer); AXIS2_LOG_DEBUG_MSG(env->log, buffer); AXIS2_FREE(env->allocator, buffer); buffer = NULL; } #endif if (wsdl_data_util_validate_data(env, type_map, output_template, response_data, VALIDATION_CRITERIA_RESPONSE_MODE) == AXIS2_TRUE) { AXIS2_LOG_DEBUG_MSG(env->log, "Valid response!!!"); *response = response_data; if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_TRUE; } else { AXIS2_LOG_ERROR_MSG(env->log, "Response data is not valid or not in proper format"); if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; } } } else /* response_envelope == NULL */ { AXIS2_LOG_ERROR_MSG(env->log, "Response envelope not found"); } if (input_template) wsdl_data_template_free(env, input_template); if (output_template) wsdl_data_template_free(env, output_template); if (wsdl_axiom) axiom_node_free_tree(wsdl_axiom, env); if (sig_axiom) axiom_node_free_tree(sig_axiom, env); if (type_map) axiom_node_free_tree(type_map, env); return AXIS2_FALSE; }
axis2_status_t AXIS2_CALL axis2_stub_on_complete_IIp2Location_get(axis2_callback_t *callback, const axutil_env_t *env) { axis2_status_t ( AXIS2_CALL *on_complete ) (const axutil_env_t *, adb_getResponse_t* _getResponse, void *data); struct axis2_stub_IIp2Location_get_callback_data* callback_data = NULL; void *user_data = NULL; axis2_status_t status = AXIS2_SUCCESS; adb_getResponse_t* ret_val; axiom_node_t *ret_node = NULL; axiom_soap_envelope_t *soap_envelope = NULL; callback_data = (struct axis2_stub_IIp2Location_get_callback_data*)axis2_callback_get_data(callback); soap_envelope = axis2_callback_get_envelope(callback, env); if(soap_envelope) { axiom_soap_body_t *soap_body; soap_body = axiom_soap_envelope_get_body(soap_envelope, env); if(soap_body) { axiom_soap_fault_t *soap_fault = NULL; axiom_node_t *body_node = axiom_soap_body_get_base_node(soap_body, env); if(body_node) { ret_node = axiom_node_get_first_child(body_node, env); } } } user_data = callback_data->data; on_complete = callback_data->on_complete; if(ret_node != NULL) { ret_val = adb_getResponse_create(env); if(adb_getResponse_deserialize(ret_val, env, &ret_node, NULL, AXIS2_FALSE ) == AXIS2_FAILURE) { AXIS2_LOG_ERROR( env->log, AXIS2_LOG_SI, "NULL returnted from the LendResponse_deserialize: " "This should be due to an invalid XML"); adb_getResponse_free(ret_val, env); ret_val = NULL; } } else { ret_val = NULL; } status = on_complete(env, ret_val, user_data); if(callback_data) { AXIS2_FREE(env->allocator, callback_data); } return status; }
axis2_status_t AXIS2_CALL sandesha2_rm_elements_from_soap_envelope( sandesha2_rm_elements_t *rm_elements, const axutil_env_t *env, axiom_soap_envelope_t *soap_envelope, axis2_char_t *action) { axiom_soap_header_t *soap_header = NULL; axiom_soap_body_t *soap_body = NULL; axiom_node_t *header_node = NULL; axiom_element_t *body_element = NULL; axiom_node_t *body_node = NULL; axiom_element_t *header_element = NULL; axiom_node_t *seq_node = NULL; axiom_element_t *seq_ack_element = NULL; axiom_node_t *seq_ack_node = NULL; axiom_node_t *create_seq_node = NULL; axiom_node_t *create_seq_res_node = NULL; axiom_node_t *terminate_seq_node = NULL; axiom_node_t *terminate_seq_res_node = NULL; axiom_node_t *close_seq_node = NULL; axiom_node_t *close_seq_res_node = NULL; axiom_node_t *ack_requested_node = NULL; axiom_node_t *make_conn_node = NULL; axiom_node_t *msg_pending_node = NULL; axutil_qname_t *qname = NULL; axis2_char_t *rm_ns_val = NULL; axis2_char_t *addr_ns_val = NULL; AXIS2_PARAM_CHECK(env->error, soap_envelope, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, action, AXIS2_FAILURE); rm_ns_val = sandesha2_rm_elements_get_rm_ns_val(env, soap_envelope, action); if(!rm_ns_val) return AXIS2_SUCCESS; addr_ns_val = sandesha2_rm_elements_get_addr_ns_val_from_env(env, soap_envelope, action); if(!addr_ns_val) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]Cannot find the addressing version"); return AXIS2_FAILURE; } soap_header = axiom_soap_envelope_get_header(soap_envelope, env); header_node = axiom_soap_header_get_base_node(soap_header, env); header_element = axiom_node_get_data_element(header_node, env); soap_body = axiom_soap_envelope_get_body(soap_envelope, env); body_node = axiom_soap_body_get_base_node(soap_body, env); body_element = axiom_node_get_data_element(body_node, env); qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_SEQ, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(header_element, env, qname, header_node, &seq_node); if(qname) axutil_qname_free(qname, env); if(seq_node) { rm_elements->seq = sandesha2_seq_create(env, rm_ns_val); sandesha2_seq_from_om_node( rm_elements->seq, env, seq_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_SEQ_ACK, rm_ns_val, NULL); seq_ack_element = axiom_element_get_first_child_with_qname(header_element, env, qname, header_node, &seq_ack_node); if(qname) axutil_qname_free(qname, env); if(seq_ack_element) { rm_elements->seq_ack = sandesha2_seq_ack_create(env, rm_ns_val); sandesha2_seq_ack_from_om_node( rm_elements->seq_ack, env, seq_ack_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_CREATE_SEQ, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(body_element, env, qname, body_node, &create_seq_node); if(qname) axutil_qname_free(qname, env); if(create_seq_node) { rm_elements->create_seq = sandesha2_create_seq_create(env, addr_ns_val, rm_ns_val); sandesha2_create_seq_from_om_node( rm_elements->create_seq, env, create_seq_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_CREATE_SEQ_RESPONSE, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(body_element, env, qname, body_node, &create_seq_res_node); if(qname) { axutil_qname_free(qname, env); } if(create_seq_res_node) { rm_elements->create_seq_res = sandesha2_create_seq_res_create(env, rm_ns_val, addr_ns_val); sandesha2_create_seq_res_from_om_node(rm_elements->create_seq_res, env, create_seq_res_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_TERMINATE_SEQ, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(body_element, env, qname, body_node, &terminate_seq_node); if(qname) { axutil_qname_free(qname, env); } if(terminate_seq_node) { rm_elements->terminate_seq = sandesha2_terminate_seq_create(env, rm_ns_val); sandesha2_terminate_seq_from_om_node(rm_elements->terminate_seq, env, terminate_seq_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_TERMINATE_SEQ_RESPONSE, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(body_element, env, qname, body_node, &terminate_seq_res_node); if(qname) { axutil_qname_free(qname, env); } if(terminate_seq_res_node) { rm_elements->terminate_seq_res = sandesha2_terminate_seq_res_create(env, rm_ns_val); sandesha2_terminate_seq_res_from_om_node(rm_elements->terminate_seq_res, env, terminate_seq_res_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_CLOSE_SEQ, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(body_element, env, qname, body_node, &close_seq_node); if(qname) { axutil_qname_free(qname, env); } if(close_seq_node) { rm_elements->close_seq = sandesha2_close_seq_create(env, rm_ns_val); sandesha2_close_seq_from_om_node(rm_elements->close_seq, env, close_seq_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_CLOSE_SEQ_RESPONSE, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(body_element, env, qname, body_node, &close_seq_res_node); if(qname) { axutil_qname_free(qname, env); } if(close_seq_res_node) { rm_elements->close_seq_res = sandesha2_close_seq_res_create(env, rm_ns_val); sandesha2_close_seq_res_from_om_node(rm_elements->close_seq_res, env, close_seq_res_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_MAKE_CONNECTION, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(body_element, env, qname, body_node, &make_conn_node); if(qname) { axutil_qname_free(qname, env); } if(make_conn_node) { rm_elements->make_connection = sandesha2_make_connection_create(env, rm_ns_val); sandesha2_make_connection_from_om_node(rm_elements->make_connection, env, make_conn_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_ACK_REQUESTED, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(header_element, env, qname, header_node, &ack_requested_node); if(qname) axutil_qname_free(qname, env); if(ack_requested_node) { rm_elements->ack_requested = sandesha2_ack_requested_create(env, rm_ns_val); sandesha2_ack_requested_from_om_node( rm_elements->ack_requested, env, ack_requested_node); } qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_MESSAGE_PENDING, rm_ns_val, NULL); axiom_element_get_first_child_with_qname(header_element, env, qname, header_node, &msg_pending_node); if(qname) axutil_qname_free(qname, env); if(msg_pending_node) { rm_elements->msg_pending = sandesha2_msg_pending_create(env, rm_ns_val); sandesha2_msg_pending_from_om_node( rm_elements->msg_pending, env, msg_pending_node); } return AXIS2_SUCCESS; }
axiom_soap_envelope_t* AXIS2_CALL sandesha2_rm_elements_to_soap_envelope( sandesha2_rm_elements_t *rm_elements, const axutil_env_t *env, axiom_soap_envelope_t *soap_envelope) { axiom_soap_header_t *soap_header = NULL; axiom_soap_body_t *soap_body = NULL; axiom_node_t *body_node = NULL; AXIS2_PARAM_CHECK(env->error, soap_envelope, NULL); soap_header = axiom_soap_envelope_get_header(soap_envelope, env); soap_body = axiom_soap_envelope_get_body(soap_envelope, env); body_node = axiom_soap_body_get_base_node(soap_body, env); if(rm_elements->seq) { sandesha2_seq_to_om_node( rm_elements->seq, env, soap_header); } if(rm_elements->seq_ack) { sandesha2_seq_ack_to_om_node( rm_elements->seq_ack, env, soap_header); } if(rm_elements->msg_pending) { sandesha2_msg_pending_to_om_node( rm_elements->msg_pending, env, soap_header); } if(rm_elements->create_seq) { sandesha2_create_seq_to_om_node( rm_elements->create_seq, env, body_node); } if(rm_elements->create_seq_res) { sandesha2_create_seq_res_to_om_node( rm_elements->create_seq_res, env, body_node); } if(rm_elements->terminate_seq) { sandesha2_terminate_seq_to_om_node( rm_elements->terminate_seq, env, body_node); } if(rm_elements->terminate_seq_res) { sandesha2_terminate_seq_res_to_om_node( rm_elements->terminate_seq_res, env, body_node); } if(rm_elements->close_seq) { sandesha2_close_seq_to_om_node(rm_elements->close_seq, env, body_node); } if(rm_elements->close_seq_res) { sandesha2_close_seq_res_to_om_node(rm_elements->close_seq_res, env, body_node); } if(rm_elements->make_connection) { sandesha2_make_connection_to_om_node( rm_elements->make_connection, env, body_node); } return soap_envelope; }
AXIS2_EXTERN void AXIS2_CALL savan_default_publisher_publish( savan_publisher_t *publishermod, const axutil_env_t *env, void *msg_ctx, savan_subs_mgr_t *subs_mgr) { savan_default_publisher_t *publishermodimpl = NULL; axutil_array_list_t *subs_store = NULL; int i = 0, size = 0; savan_filter_mod_t *filtermod = NULL; const axis2_char_t *path = NULL; axiom_node_t *payload = NULL; axiom_soap_envelope_t *envelope = NULL; axiom_soap_body_t *body = NULL; axiom_node_t *body_node = NULL; const axis2_char_t *filter = NULL; axis2_conf_ctx_t *conf_ctx = NULL; axutil_property_t *topic_property = NULL; publishermodimpl = SAVAN_INTF_TO_IMPL(publishermod); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Entry:savan_default_publisher_publish"); topic_property = axis2_msg_ctx_get_property(msg_ctx, env, ELEM_NAME_TOPIC); if(topic_property) { filter = axutil_property_get_value(topic_property, env); } axutil_allocator_switch_to_global_pool(env->allocator); if(subs_mgr) { subs_store = savan_subs_mgr_retrieve_all_subscribers(subs_mgr, env, filter); } if (!subs_store) { axutil_allocator_switch_to_local_pool(env->allocator); AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "[savan] Subscriber store is NULL"); } conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); path = axis2_conf_ctx_get_root_dir(conf_ctx, env); if(!path) { path = AXIS2_GETENV("AXIS2C_HOME"); } envelope = axis2_msg_ctx_get_soap_envelope((axis2_msg_ctx_t *) msg_ctx, env); if (!envelope) { axutil_allocator_switch_to_local_pool(env->allocator); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] Failed to extract the soap envelop"); } body = axiom_soap_envelope_get_body(envelope, env); if (!body) { axutil_allocator_switch_to_local_pool(env->allocator); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] Failed to extract the soap body"); } body_node = axiom_soap_body_get_base_node(body, env); payload = axiom_node_get_first_child(body_node, env); size = axutil_array_list_size(subs_store, env); for(i = 0; i < size; i++) { axis2_svc_client_t *svc_client = NULL; savan_subscriber_t *sub = NULL; sub = (savan_subscriber_t *)axutil_array_list_get(subs_store, env, i); if (sub) { axis2_char_t *id = savan_subscriber_get_id(sub, env); AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Publishing to:%s", id); svc_client = axis2_svc_client_create(env, path); filtermod = savan_util_get_filter_module(env, publishermodimpl->conf); /* Ideally publishing to each subscriber should happen within a thread for each * subscriber. However until Axis2/C provide a good thread pool to handle * such tasks I use this sequential publishing to subscribers. */ if(!savan_default_publisher_publish_to_subscriber(publishermod, env, svc_client, sub, filtermod, payload)) { axis2_endpoint_ref_t *notifyto = savan_subscriber_get_notify_to(sub, env); const axis2_char_t *address = NULL; if(notifyto) { address = axis2_endpoint_ref_get_address(notifyto, env); } AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Publishing to the Data Sink:%s proviced by subscriber:%s Failed. Check "\ "whether the Data Sink url is correct", address, id); } if(svc_client) { axis2_svc_client_free(svc_client, env); } } } axutil_allocator_switch_to_local_pool(env->allocator); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Exit:savan_default_publisher_publish"); }
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 = axutil_strdup(env,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; }
axis2_status_t AXIS2_CALL wsf_xml_msg_recv_invoke_business_logic_sync( axis2_msg_recv_t * msg_recv, const axutil_env_t * env, axis2_msg_ctx_t * in_msg_ctx, axis2_msg_ctx_t * out_msg_ctx) { axis2_op_ctx_t *op_ctx = NULL; axis2_op_t *op_desc = NULL; axiom_namespace_t *env_ns = NULL; int soap_version = AXIOM_SOAP12; axis2_status_t status = AXIS2_SUCCESS; axis2_bool_t skel_invoked = AXIS2_FALSE; const axis2_char_t *style = NULL; axis2_char_t *local_name = NULL; axis2_char_t *soap_ns = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; axis2_char_t *operation_name = NULL; char *classname = NULL; axutil_property_t *svc_info_prop = NULL; axutil_property_t *req_info_prop = NULL; wsf_svc_info_t *svc_info = NULL; wsf_request_info_t *req_info = NULL; /** store in_msg_ctx envelope */ axiom_soap_envelope_t *envelope = NULL; axiom_soap_body_t *body = NULL; axiom_node_t *in_body_node = NULL; /* store out_msg_ctx envelope */ axiom_soap_envelope_t *default_envelope = NULL; axiom_soap_body_t *out_body = NULL; axiom_soap_header_t *out_header = NULL; axiom_soap_fault_t *out_soap_fault = NULL; axiom_node_t *result_node = NULL; axiom_node_t *out_body_content_node = NULL; axiom_element_t *out_body_content_element = NULL; axiom_node_t *out_node = NULL; zval **output_headers_zval = NULL; TSRMLS_FETCH(); AXIS2_PARAM_CHECK(env->error, in_msg_ctx, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, out_msg_ctx, AXIS2_FAILURE); op_ctx = axis2_msg_ctx_get_op_ctx(in_msg_ctx, env); op_desc = axis2_op_ctx_get_op(op_ctx, env); style = axis2_op_get_style(op_desc, env); envelope = axis2_msg_ctx_get_soap_envelope(in_msg_ctx, env); body = axiom_soap_envelope_get_body(envelope, env); in_body_node = axiom_soap_body_get_base_node(body, env); if (0 == axutil_strcmp(AXIS2_STYLE_DOC, style)) { local_name = wsf_xml_msg_recv_get_method_name(in_msg_ctx, env); if (!local_name) { return AXIS2_FAILURE; } } else if (0 == axutil_strcmp(AXIS2_STYLE_RPC, style)) { axiom_node_t *op_node = NULL; axiom_element_t *op_element = NULL; op_node = axiom_node_get_first_child(in_body_node, env); if (!op_node) { return AXIS2_FAILURE; } op_element = axiom_node_get_data_element(op_node, env); if (!op_element) { return AXIS2_FAILURE; } local_name = axiom_element_get_localname(op_element, env); if (!local_name) { return AXIS2_FAILURE; } } /** set soap version and soap namespace to local variables */ if (in_msg_ctx && axis2_msg_ctx_get_is_soap_11(in_msg_ctx, env)) { soap_ns = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; /* default is 1.2 */ soap_version = AXIOM_SOAP11; } svc_info_prop = axis2_msg_ctx_get_property(in_msg_ctx, env, WSF_SVC_INFO); if (svc_info_prop) { svc_info = (wsf_svc_info_t *) axutil_property_get_value(svc_info_prop, env); if (svc_info) { operation_name = axutil_hash_get(svc_info->ops_to_functions, local_name, AXIS2_HASH_KEY_STRING); if (!operation_name) { return AXIS2_FAILURE; } } else { return AXIS2_FAILURE; } if (svc_info->ops_to_classes) { classname = axutil_hash_get(svc_info->ops_to_classes, local_name, AXIS2_HASH_KEY_STRING); } } req_info_prop = axis2_msg_ctx_get_property(in_msg_ctx, env, WSF_REQ_INFO); if (req_info_prop) { req_info = (wsf_request_info_t *) axutil_property_get_value(req_info_prop, env); if (axis2_msg_ctx_get_doing_rest(in_msg_ctx, env)) { axis2_op_t *op = NULL; axiom_node_t *body_child_node = NULL; axiom_element_t *body_child = NULL; int i = 0; body_child_node = axiom_node_get_first_child(in_body_node, env); if (!body_child_node) { op = axis2_msg_ctx_get_op(in_msg_ctx, env); if (op) { body_child = axiom_element_create_with_qname(env, NULL, axis2_op_get_qname(op, env), &body_child_node); axiom_soap_body_add_child(body, env, body_child_node); } } if (req_info->param_keys && req_info->param_values) { int i = 0; for (i = 0; i < axutil_array_list_size(req_info->param_keys, env); i++) { axiom_node_t *node = NULL; axiom_element_t *element = NULL; axis2_char_t *param_key = NULL; axis2_char_t *param_value = NULL; param_key = axutil_array_list_get(req_info->param_keys, env, i); param_value = axutil_array_list_get(req_info->param_values, env, i); element = axiom_element_create(env, NULL, param_key, NULL, &node); axiom_element_set_text(element, env, param_value, node); axiom_node_add_child(body_child_node, env, node); AXIS2_FREE(env->allocator, param_key); AXIS2_FREE(env->allocator, param_value); } axutil_array_list_free(req_info->param_keys, env); axutil_array_list_free(req_info->param_values, env); } } } if (svc_info->ht_op_params) { zval **tmp; char *function_type = NULL; if (zend_hash_find(svc_info->ht_op_params, operation_name, strlen(operation_name) + 1, (void **) & tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_STRING) { function_type = Z_STRVAL_PP(tmp); if (strcmp(function_type, WSF_MIXED) == 0) { result_node = wsf_xml_msg_recv_invoke_mixed(env, svc_info, in_msg_ctx, out_msg_ctx, operation_name, classname, &output_headers_zval TSRMLS_CC); } else if (strcmp(function_type, WSF_WSMESSAGE) == 0) { result_node = wsf_xml_msg_recv_invoke_wsmsg(env, operation_name, in_msg_ctx, out_msg_ctx, svc_info, classname, req_info->content_type TSRMLS_CC); } } } else { /* this is where the default value for opParam is set, If the wsdl option is set go for the MIXED mode by default */ if (svc_info->wsdl == NULL || svc_info->omit_wsdl) { result_node = wsf_xml_msg_recv_invoke_wsmsg(env, operation_name, in_msg_ctx, out_msg_ctx, svc_info, classname, req_info->content_type TSRMLS_CC); } else { result_node = wsf_xml_msg_recv_invoke_mixed(env, svc_info, in_msg_ctx, out_msg_ctx, operation_name, classname, &output_headers_zval TSRMLS_CC); } } if (!result_node) { status = AXIS2_ERROR_GET_STATUS_CODE(env->error); } else { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "Response node is not null"); } if (result_node) { if (0 == axutil_strcmp(style, AXIS2_STYLE_RPC)) { axiom_namespace_t *ns = NULL; axis2_char_t *response_name = NULL; response_name = axutil_stracat(env, local_name, "Response"); ns = axiom_namespace_create(env, "http://soapenc/", "res"); if (!ns) { return AXIS2_FAILURE; } out_body_content_element = axiom_element_create(env, NULL, response_name, ns, &out_body_content_node); axiom_node_add_child(out_body_content_node, env, result_node); } else { out_body_content_node = result_node; } } if (axis2_msg_ctx_get_soap_envelope(out_msg_ctx, env)) { /* service implementation has set the envelope, useful when setting a SOAP fault. No need to further process */ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "soap fault is set"); return AXIS2_SUCCESS; } /* create the soap envelope here */ env_ns = axiom_namespace_create(env, soap_ns, AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX); if (!env_ns) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] error seting the namespces for the " AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX); return AXIS2_FAILURE; } default_envelope = axiom_soap_envelope_create(env, env_ns); if (!default_envelope) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "failed in creating the response soap envelope"); return AXIS2_FAILURE; } out_body = axiom_soap_body_create_with_parent(env, default_envelope); if (!out_body) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] failed in creating the response soap body"); return AXIS2_FAILURE; } out_header = axiom_soap_header_create_with_parent(env, default_envelope); if (!out_header) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "failed in creating the response soap headers"); return AXIS2_FAILURE; } if (output_headers_zval) { axiom_node_t *header_base_node = NULL; HashPosition pos; zval **param; char *header_str; axiom_node_t *header_node; for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(output_headers_zval), &pos); zend_hash_get_current_data_ex(Z_ARRVAL_PP(output_headers_zval), (void **) & param, &pos) == SUCCESS; zend_hash_move_forward_ex(Z_ARRVAL_PP(output_headers_zval), &pos)) { if (Z_TYPE_PP(param) == IS_STRING) { header_base_node = axiom_soap_header_get_base_node(out_header, env); if (header_base_node) { header_str = Z_STRVAL_PP(param); header_node = wsf_util_deserialize_buffer(env, header_str); axiom_node_add_child(header_base_node, env, header_node); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] failed in retrieving the response soap headers node"); return AXIS2_FAILURE; } } } } out_node = axiom_soap_body_get_base_node(out_body, env); if (!out_node) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] failed in retrieving the response soap body node"); return AXIS2_FAILURE; } if (status != AXIS2_SUCCESS) { /* something went wrong, set a SOAP Fault */ axis2_char_t *fault_value_str = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":" AXIOM_SOAP12_SOAP_FAULT_VALUE_SENDER; axis2_char_t *fault_reason_str = NULL; axis2_char_t *err_msg = NULL; if (!skel_invoked) fault_value_str = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":" AXIOM_SOAP12_SOAP_FAULT_VALUE_RECEIVER; ; err_msg = (char *) AXIS2_ERROR_GET_MESSAGE(env->error); if (err_msg) { fault_reason_str = err_msg; } else { fault_reason_str = "Error occurred while processing SOAP message"; } out_soap_fault = axiom_soap_fault_create_default_fault(env, out_body, fault_value_str, fault_reason_str, soap_version); } if (out_body_content_node) { axiom_node_add_child(out_node, env, out_body_content_node); status = axis2_msg_ctx_set_soap_envelope(out_msg_ctx, env, default_envelope); } else if (out_soap_fault) { axis2_msg_ctx_set_soap_envelope(out_msg_ctx, env, default_envelope); status = AXIS2_FAILURE; /* if there is a failure we have to return a failure code */ } else { /* we should free the memory as the envelope is not used, one way case */ axiom_soap_envelope_free(default_envelope, env); default_envelope = NULL; } return AXIS2_SUCCESS; }
axis2_op_t *AXIS2_CALL axis2_rest_disp_find_op( axis2_msg_ctx_t * msg_ctx, const axutil_env_t * env, axis2_svc_t * svc) { axis2_endpoint_ref_t *endpoint_ref = NULL; axis2_op_t *op = NULL; axiom_soap_envelope_t *soap_env = NULL; axiom_soap_body_t *soap_body = NULL; axiom_element_t *body_child = NULL; axiom_node_t *body_child_node = NULL; axiom_node_t *body_element_node = NULL; axis2_bool_t soap_env_exists = AXIS2_TRUE; int i = 0; axutil_array_list_t *param_keys = NULL; axutil_array_list_t *param_values = NULL; AXIS2_PARAM_CHECK(env->error, svc, NULL); if(!axis2_msg_ctx_get_doing_rest(msg_ctx, env)) return NULL; endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env); if(endpoint_ref) { const axis2_char_t *address = NULL; address = axis2_endpoint_ref_get_address(endpoint_ref, env); if(address) { axis2_char_t **url_tokens = NULL; url_tokens = axutil_parse_request_url_for_svc_and_op(env, address); if(url_tokens) { if(url_tokens[0]) { axis2_char_t *location = NULL; location = strstr(address, url_tokens[0]); if(location) { const axis2_char_t *method = NULL; location += strlen(url_tokens[0]); param_keys = axutil_array_list_create(env, 10); if(!param_keys) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create the live rest parameter maps"); return NULL; } param_values = axutil_array_list_create(env, 10); if(!param_values) { axutil_array_list_free(param_keys, env); AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create the live rest parameter maps"); return NULL; } method = axis2_msg_ctx_get_rest_http_method(msg_ctx, env); op = axis2_core_utils_get_rest_op_with_method_and_location(svc, env, method, location, param_keys, param_values); } } if(url_tokens[0]) AXIS2_FREE(env->allocator, url_tokens[0]); if(url_tokens[1]) AXIS2_FREE(env->allocator, url_tokens[1]); AXIS2_FREE(env->allocator, url_tokens); } } } if(!op) { if(param_keys) { for(i = 0; i < axutil_array_list_size(param_keys, env); i++) { void *value = axutil_array_list_get(param_keys, env, i); AXIS2_FREE(env->allocator, value); } axutil_array_list_free(param_keys, env); } if(param_values) { for(i = 0; i < axutil_array_list_size(param_values, env); i++) { void *value = axutil_array_list_get(param_values, env, i); AXIS2_FREE(env->allocator, value); } axutil_array_list_free(param_values, env); } return NULL; } soap_env = axis2_msg_ctx_get_soap_envelope(msg_ctx, env); if(!soap_env) { soap_env_exists = AXIS2_FALSE; soap_env = axiom_soap_envelope_create_default_soap_envelope(env, AXIOM_SOAP11); } if(soap_env) { soap_body = axiom_soap_envelope_get_body(soap_env, env); } if(!soap_body) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL, AXIS2_FAILURE); if(param_keys) { for(i = 0; i < axutil_array_list_size(param_keys, env); i++) { void *value = axutil_array_list_get(param_keys, env, i); AXIS2_FREE(env->allocator, value); } axutil_array_list_free(param_keys, env); } if(param_values) { for(i = 0; i < axutil_array_list_size(param_values, env); i++) { void *value = axutil_array_list_get(param_values, env, i); AXIS2_FREE(env->allocator, value); } axutil_array_list_free(param_values, env); } return NULL; } body_element_node = axiom_soap_body_get_base_node(soap_body, env); if(body_element_node) { body_child_node = axiom_node_get_first_child(body_element_node, env); } if(!body_child_node) { body_child = axiom_element_create_with_qname(env, NULL, axis2_op_get_qname(op, env), &body_child_node); axiom_soap_body_add_child(soap_body, env, body_child_node); } if(param_keys && param_values) { for(i = 0; i < axutil_array_list_size(param_keys, env); i++) { axis2_char_t *param_key = NULL; axis2_char_t *param_value = NULL; axiom_node_t *node = NULL; axiom_element_t *element = NULL; param_key = axutil_array_list_get(param_keys, env, i); param_value = axutil_array_list_get(param_values, env, i); element = axiom_element_create(env, NULL, param_key, NULL, &node); axiom_element_set_text(element, env, param_value, node); axiom_node_add_child(body_child_node, env, node); AXIS2_FREE(env->allocator, param_key); AXIS2_FREE(env->allocator, param_value); } axutil_array_list_free(param_keys, env); axutil_array_list_free(param_values, env); } if(!soap_env_exists) { axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_env); } return op; }
static axis2_status_t AXIS2_CALL axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync( axis2_msg_recv_t * msg_recv, const axutil_env_t * env, axis2_msg_ctx_t * msg_ctx, axis2_msg_ctx_t * new_msg_ctx) { axis2_svc_skeleton_t *svc_obj = NULL; axis2_op_ctx_t *op_ctx = NULL; axis2_op_t *op_desc = NULL; const axis2_char_t *style = NULL; axiom_node_t *om_node = NULL; axiom_element_t *om_element = NULL; axis2_char_t *local_name = NULL; axiom_node_t *result_node = NULL; axiom_node_t *body_content_node = NULL; axiom_element_t *body_content_element = NULL; axiom_soap_envelope_t *default_envelope = NULL; axiom_soap_body_t *out_body = NULL; axiom_soap_header_t *out_header = NULL; axiom_soap_fault_t *soap_fault = NULL; axiom_node_t *out_node = NULL; axis2_status_t status = AXIS2_SUCCESS; axis2_bool_t skel_invoked = AXIS2_FALSE; const axis2_char_t *soap_ns = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; int soap_version = AXIOM_SOAP12; axiom_namespace_t *env_ns = NULL; axiom_node_t *fault_node = NULL; axiom_soap_fault_detail_t *fault_detail; axis2_bool_t is_fault = AXIS2_FALSE; AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, new_msg_ctx, AXIS2_FAILURE); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[axis2]Entry:axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync"); /* get the implementation class for the Web Service */ svc_obj = axis2_msg_recv_make_new_svc_obj(msg_recv, env, msg_ctx); if(!svc_obj) { const axis2_char_t *svc_name = NULL; axis2_svc_t *svc = axis2_msg_ctx_get_svc(msg_ctx, env); if(svc) { svc_name = axis2_svc_get_name(svc, env); } else { svc_name = "unknown"; } AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Impl object for service '%s' not set in message receiver. %d :: %s", svc_name, env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error)); status = AXIS2_FAILURE; } else { op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env); op_desc = axis2_op_ctx_get_op(op_ctx, env); style = axis2_op_get_style(op_desc, env); if(0 == axutil_strcmp(AXIS2_STYLE_DOC, style)) { axiom_soap_envelope_t *envelope = NULL; axiom_soap_body_t *body = NULL; envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env); body = axiom_soap_envelope_get_body(envelope, env); om_node = axiom_soap_body_get_base_node(body, env); om_element = axiom_node_get_data_element(om_node, env); om_node = axiom_node_get_first_element(om_node, env); } else if(0 == axutil_strcmp(AXIS2_STYLE_RPC, style)) { axiom_soap_envelope_t *envelope = NULL; axiom_soap_body_t *body = NULL; axiom_node_t *op_node = NULL; axiom_element_t *op_element = NULL; envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env); body = axiom_soap_envelope_get_body(envelope, env); op_node = axiom_soap_body_get_base_node(body, env); op_element = axiom_node_get_data_element(op_node, env); if(op_element) { local_name = axiom_element_get_localname(op_element, env); if(local_name) { axutil_array_list_t *function_arr = NULL; int i = 0; int size = 0; axis2_bool_t matches = AXIS2_FALSE; function_arr = svc_obj->func_array; if(function_arr) { size = axutil_array_list_size(function_arr, env); } for(i = 0; i < size; i++) { axis2_char_t *function_name = NULL; function_name = (axis2_char_t *)axutil_array_list_get(function_arr, env, i); if(!axutil_strcmp(function_name, local_name)) { matches = AXIS2_TRUE; } } if(matches) { om_node = axiom_node_get_first_child(op_node, env); om_element = axiom_node_get_data_element(om_node, env); } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_OM_ELEMENT_MISMATCH, AXIS2_FAILURE); status = AXIS2_FAILURE; } } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_OM_ELEMENT_INVALID_STATE, AXIS2_FAILURE); status = AXIS2_FAILURE; } } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_RPC_NEED_MATCHING_CHILD, AXIS2_FAILURE); status = AXIS2_FAILURE; } } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_UNKNOWN_STYLE, AXIS2_FAILURE); status = AXIS2_FAILURE; } if(status == AXIS2_SUCCESS) { skel_invoked = AXIS2_TRUE; result_node = AXIS2_SVC_SKELETON_INVOKE(svc_obj, env, om_node, new_msg_ctx); } if(result_node) { if(0 == axutil_strcmp(style, AXIS2_STYLE_RPC)) { axiom_namespace_t *ns = NULL; axis2_char_t *res_name = NULL; res_name = axutil_stracat(env, local_name, "Response"); ns = axiom_namespace_create(env, "http://soapenc/", "res"); if(!ns) { status = AXIS2_FAILURE; } else { body_content_element = axiom_element_create(env, NULL, res_name, ns, &body_content_node); axiom_node_add_child(body_content_node, env, result_node); } } else { body_content_node = result_node; } } else { axis2_char_t *mep = (axis2_char_t *)axis2_op_get_msg_exchange_pattern(op_desc, env); if(axutil_strcmp(mep, AXIS2_MEP_URI_IN_ONLY) && axutil_strcmp(mep, AXIS2_MEP_URI_ROBUST_IN_ONLY) && axutil_strcmp(mep, AXIS2_MEP_URI_IN_ONLY_WSDL2) && axutil_strcmp(mep, AXIS2_MEP_URI_ROBUST_IN_ONLY_WSDL2)) { status = AXIS2_ERROR_GET_STATUS_CODE(env->error); if(status == AXIS2_SUCCESS) { axis2_msg_ctx_set_no_content(new_msg_ctx, env, AXIS2_TRUE); } else { axis2_msg_ctx_set_status_code(msg_ctx, env, axis2_msg_ctx_get_status_code( new_msg_ctx, env)); } /* The new_msg_ctx is passed to the service. The status code must * be taken from here and set to the old message context which is * used by the worker when the request processing fails. */ if(svc_obj->ops->on_fault) { fault_node = AXIS2_SVC_SKELETON_ON_FAULT(svc_obj, env, om_node); } is_fault = AXIS2_TRUE; } else { /* If we have a in only message result node is NULL. We create fault only if * an error is set */ status = AXIS2_ERROR_GET_STATUS_CODE(env->error); if(status == AXIS2_SUCCESS) { axis2_msg_ctx_set_no_content(new_msg_ctx, env, AXIS2_TRUE); } else { axis2_msg_ctx_set_status_code(msg_ctx, env, axis2_msg_ctx_get_status_code( new_msg_ctx, env)); if((!axutil_strcmp(mep, AXIS2_MEP_URI_ROBUST_IN_ONLY)) || (!axutil_strcmp(mep, AXIS2_MEP_URI_ROBUST_IN_ONLY_WSDL2))) { /* The new_msg_ctx is passed to the service. The status code must * be taken from here and set to the old message context which is * used by the worker when the request processing fails. */ if(svc_obj->ops->on_fault) { fault_node = AXIS2_SVC_SKELETON_ON_FAULT(svc_obj, env, om_node); } is_fault = AXIS2_TRUE; } } } } } if(msg_ctx && axis2_msg_ctx_get_is_soap_11(msg_ctx, env)) { soap_ns = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; /* default is 1.2 */ soap_version = AXIOM_SOAP11; } if(axis2_msg_ctx_get_soap_envelope(new_msg_ctx, env)) { /* service implementation has set the envelope, useful when setting a SOAP fault. No need to further process */ return AXIS2_SUCCESS; } /* create the soap envelope here */ env_ns = axiom_namespace_create(env, soap_ns, "soapenv"); if(!env_ns) { return AXIS2_FAILURE; } default_envelope = axiom_soap_envelope_create(env, env_ns); axiom_namespace_free(env_ns, env); if(!default_envelope) { return AXIS2_FAILURE; } out_header = axiom_soap_header_create_with_parent(env, default_envelope); if(!out_header) { return AXIS2_FAILURE; } out_body = axiom_soap_body_create_with_parent(env, default_envelope); if(!out_body) { return AXIS2_FAILURE; } out_node = axiom_soap_body_get_base_node(out_body, env); if(!out_node) { return AXIS2_FAILURE; } if(status != AXIS2_SUCCESS || is_fault) { /* something went wrong. set a SOAP Fault */ const axis2_char_t *fault_value_str = "soapenv:Sender"; const axis2_char_t *fault_reason_str = NULL; const axis2_char_t *err_msg = NULL; if(!skel_invoked) { if(axis2_msg_ctx_get_is_soap_11(msg_ctx, env)) { fault_value_str = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":" AXIOM_SOAP11_FAULT_CODE_RECEIVER; } else { fault_value_str = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":" AXIOM_SOAP12_SOAP_FAULT_VALUE_RECEIVER; } } err_msg = AXIS2_ERROR_GET_MESSAGE(env->error); if (err_msg && axutil_strcmp(err_msg, "")) { if(!axutil_strcmp(err_msg, "No Error")) { fault_reason_str = "An error has occurred, but could not determine exact details"; } else { fault_reason_str = err_msg; } } else { fault_reason_str = "An error has occurred, but could not determine exact details"; } soap_fault = axiom_soap_fault_create_default_fault(env, out_body, fault_value_str, fault_reason_str, soap_version); if (fault_node) { axiom_node_t *fault_detail_node = NULL; axis2_char_t *om_str = NULL; fault_detail = axiom_soap_fault_detail_create_with_parent(env, soap_fault); fault_detail_node = axiom_soap_fault_detail_get_base_node(fault_detail, env); om_str = axiom_node_to_string(fault_detail_node, env); if (om_str) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "fault_detail:%s", om_str); AXIS2_FREE(env->allocator, om_str); } axiom_soap_fault_detail_add_detail_entry(fault_detail, env, fault_node); } } if (body_content_node) { axiom_node_add_child(out_node, env, body_content_node); status = axis2_msg_ctx_set_soap_envelope(new_msg_ctx, env, default_envelope); } else if (soap_fault) { axis2_msg_ctx_set_soap_envelope(new_msg_ctx, env, default_envelope); status = AXIS2_SUCCESS; } else { /* we should free the memory as the envelope is not used, one way case */ axiom_soap_envelope_free(default_envelope, env); default_envelope = NULL; } AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[axis2]Exit:axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync"); return status; }
static int ngx_squ_xml_serialize(squ_State *l) { int top; char *uri, *prefix; axiom_node_t *node; axutil_env_t *env; axutil_log_t *log; axutil_error_t *error; axiom_output_t *output; ngx_squ_thread_t *thr; axiom_namespace_t *ns; axiom_soap_body_t *body; axutil_allocator_t *a; axiom_xml_writer_t *writer; axiom_soap_header_t *header; axiom_soap_envelope_t *envelope; thr = ngx_squ_thread(l); ngx_log_debug0(NGX_LOG_DEBUG_CORE, thr->log, 0, "squ xml serialize"); top = squ_gettop(l); if (!squ_istable(l, top)) { return squL_error(l, "invalid argument, must be a table"); } 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); squ_getfield(l, top, "uri"); uri = (char *) squL_optstring(l, -1, "http://www.w3.org/2003/05/soap-envelope"); squ_getfield(l, top, "prefix"); prefix = (char *) squL_optstring(l, -1, "soap"); ns = axiom_namespace_create(env, uri, prefix); envelope = axiom_soap_envelope_create(env, ns); squ_getfield(l, top, "header"); if (!squ_isnil(l, -1)) { if (!squ_istable(l, -1)) { return squL_error(l, "the value of \"header\" must be a table"); } header = axiom_soap_header_create_with_parent(env, envelope); node = axiom_soap_header_get_base_node(header, env); ngx_squ_xml_serialize_tables(l, env, node); } squ_getfield(l, top, "body"); if (!squ_isnil(l, -1)) { if (!squ_istable(l, -1)) { return squL_error(l, "the value of \"body\" must be a table"); } body = axiom_soap_body_create_with_parent(env, envelope); node = axiom_soap_body_get_base_node(body, env); ngx_squ_xml_serialize_tables(l, env, node); } squ_settop(l, top); writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE, AXIS2_XML_PARSER_TYPE_BUFFER); output = axiom_output_create(env, writer); axiom_soap_envelope_serialize(envelope, env, output, AXIS2_FALSE); squ_pushstring(l, axiom_xml_writer_get_xml(writer, env)); return 1; }
/** * Create a new create_seq_response message. * @param env axis2 environment struct * @param create_seq_msg * @param out_msg * @param new_seq_id * @param seq_prop_mgr * @return sandesha2_msg_ctx_t */ sandesha2_msg_ctx_t * sandesha2_msg_creator_create_create_seq_res_msg( const axutil_env_t *env, sandesha2_msg_ctx_t *create_seq_msg, axis2_msg_ctx_t *out_msg, axis2_char_t *new_seq_id, sandesha2_seq_property_mgr_t *seq_prop_mgr) { axis2_conf_ctx_t *conf_ctx = NULL; axis2_msg_ctx_t *temp_msg_ctx = NULL; axis2_char_t *rm_version = NULL; axis2_char_t *rm_ns_value = NULL; axis2_char_t *addressing_ns_value = NULL; axis2_char_t *new_msg_id = NULL; axis2_char_t *temp_action = NULL; axutil_string_t *soap_action = NULL; axiom_soap_envelope_t *envelope = NULL; axiom_soap_envelope_t *temp_envelope = NULL; axiom_soap_body_t *temp_soap_body = NULL; axiom_node_t *temp_om_node = NULL; sandesha2_create_seq_res_t *create_seq_res = NULL; sandesha2_identifier_t *identifier = NULL; sandesha2_seq_offer_t *offer = NULL; sandesha2_msg_ctx_t *create_seq_res_rm_msg_ctx = NULL; sandesha2_create_seq_t *cs = NULL; int soap_version = -1; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_msg_creator_create_create_seq_res_msg"); temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); conf_ctx = axis2_msg_ctx_get_conf_ctx(temp_msg_ctx, env); cs = sandesha2_msg_ctx_get_create_seq(create_seq_msg, env); rm_version = sandesha2_utils_get_rm_version(env, temp_msg_ctx); if(!rm_version) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find rm version of given message"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_RM_VERSION_OF_GIVEN_MSG, AXIS2_FAILURE); return NULL; } rm_ns_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, rm_version); addressing_ns_value = sandesha2_utils_get_seq_property(env, new_seq_id, SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, seq_prop_mgr); if(!addressing_ns_value) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find addressing namespace value"); return NULL; } create_seq_res = sandesha2_create_seq_res_create(env, rm_ns_value, addressing_ns_value); identifier = sandesha2_identifier_create(env, rm_ns_value); sandesha2_identifier_set_identifier(identifier, env, new_seq_id); sandesha2_create_seq_res_set_identifier(create_seq_res, env, identifier); offer = sandesha2_create_seq_get_seq_offer(cs, env); if(offer) { axis2_char_t *out_seq_id = NULL; sandesha2_identifier_t *temp_identifier = NULL; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Offer present"); temp_identifier = sandesha2_seq_offer_get_identifier(offer, env); out_seq_id = sandesha2_identifier_get_identifier(temp_identifier, env); if(out_seq_id && axutil_strcmp("", out_seq_id)) { sandesha2_accept_t *accept = NULL; axis2_endpoint_ref_t *acks_to_epr = NULL; sandesha2_acks_to_t *acks_to = NULL; sandesha2_address_t *address = NULL; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] out_seq_id present"); accept = sandesha2_accept_create(env, rm_ns_value, addressing_ns_value); if(accept) { axis2_endpoint_ref_t *temp_to_epr = NULL; acks_to_epr = sandesha2_msg_ctx_get_to(create_seq_msg, env); if(acks_to_epr) { temp_to_epr = sandesha2_util_endpoint_ref_clone(env, acks_to_epr); } address = sandesha2_address_create(env, addressing_ns_value, temp_to_epr); acks_to = sandesha2_acks_to_create(env, address, rm_ns_value, addressing_ns_value); sandesha2_accept_set_acks_to(accept, env, acks_to); sandesha2_create_seq_res_set_accept(create_seq_res, env, accept); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Could not create accept element"); return NULL; } } } temp_envelope = sandesha2_msg_ctx_get_soap_envelope(create_seq_msg, env); soap_version = sandesha2_utils_get_soap_version(env, temp_envelope); envelope = axiom_soap_envelope_create_default_soap_envelope(env, soap_version); temp_soap_body = axiom_soap_envelope_get_body(envelope, env); temp_om_node = axiom_soap_body_get_base_node(temp_soap_body, env); sandesha2_create_seq_res_to_om_node(create_seq_res, env, temp_om_node); temp_action = sandesha2_spec_specific_consts_get_create_seq_res_action(env, rm_version); axis2_msg_ctx_set_wsa_action(out_msg, env, temp_action); soap_action = axutil_string_create(env, temp_action); /*if(soap_action) { axis2_msg_ctx_set_soap_action(out_msg, env, soap_action); axutil_string_free(soap_action, env); }*/ if(addressing_ns_value) { AXIS2_FREE(env->allocator, addressing_ns_value); } new_msg_id = axutil_uuid_gen(env); if(new_msg_id) { axis2_msg_ctx_set_message_id(out_msg, env, new_msg_id); AXIS2_FREE(env->allocator, new_msg_id); } axis2_msg_ctx_set_soap_envelope(out_msg, env, envelope); temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); sandesha2_msg_creator_init_creation(env, temp_msg_ctx, out_msg); create_seq_res_rm_msg_ctx = sandesha2_msg_init_init_msg(env, out_msg); sandesha2_msg_ctx_set_create_seq_res(create_seq_res_rm_msg_ctx, env, create_seq_res); temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); sandesha2_msg_creator_finalize_creation(env, temp_msg_ctx, out_msg); axis2_msg_ctx_set_server_side(temp_msg_ctx, env, AXIS2_TRUE); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Exit:sandesha2_msg_creator_create_create_seq_res_msg"); return create_seq_res_rm_msg_ctx; }
AXIS2_EXTERN axiom_node_t *AXIS2_CALL axis2_svc_client_send_receive_with_op_qname( axis2_svc_client_t * svc_client, const axutil_env_t * env, const axutil_qname_t * op_qname, const axiom_node_t * payload) { axiom_soap_envelope_t *soap_envelope = NULL; axiom_soap_body_t *soap_body = NULL; axiom_node_t *soap_node = NULL; axis2_op_t *op = NULL; axutil_param_t *param = NULL; axutil_uri_t *action_uri = NULL; axis2_char_t *action_str = NULL; axis2_bool_t qname_free_flag = AXIS2_FALSE; axis2_msg_ctx_t *res_msg_ctx = NULL; axis2_msg_ctx_t *msg_ctx = NULL; AXIS2_PARAM_CHECK(env->error, svc_client, NULL); svc_client->last_response_soap_envelope = NULL; svc_client->last_response_has_fault = AXIS2_FALSE; svc_client->auth_failed = AXIS2_FALSE; svc_client->required_auth_is_http = AXIS2_FALSE; if(svc_client->auth_type) { AXIS2_FREE(env->allocator, svc_client->auth_type); } svc_client->auth_type = NULL; op = axis2_svc_get_op_with_qname(svc_client->svc, env, op_qname); if(op) { param = axis2_op_get_param(op, env, AXIS2_SOAP_ACTION); if(param) { action_uri = (axutil_uri_t *)axutil_param_get_value(param, env); action_str = axutil_uri_to_string(action_uri, env, AXIS2_URI_UNP_OMITUSERINFO); axis2_options_set_action(svc_client->options, env, action_str); } } if(!op_qname) { op_qname = axutil_qname_create(env, AXIS2_ANON_OUT_IN_OP, NULL, NULL); if(!op_qname) return NULL; qname_free_flag = AXIS2_TRUE; } /* If dual channel blocking. We come to this block if the client indicate to use * a separate listener but don't provide a callback function to acted upon when * response is received in the listener thread. What we do here is we create a callback * and call axis2_svc_client_send_receive_non_blocking_with_op_qname with it. */ if(axis2_options_get_use_separate_listener(svc_client->options, env)) { axis2_callback_t *callback = NULL; axis2_msg_ctx_t *msg_ctx = NULL; long index = 0; /* This means doing a Request-Response invocation using two channels. If the transport is a two way transport (e.g. http), only one channel is used (e.g. in http cases 202 OK is sent to say no response available). Axis2 gets blocked and return when the response is available. */ callback = axis2_callback_create(env); if(!callback) { return NULL; } /* Call two channel non blocking invoke to do the work and wait on the callback. We don't * set a callback function for the callback. That functionality is handled here. */ axis2_svc_client_send_receive_non_blocking_with_op_qname(svc_client, env, op_qname, payload, callback); index = axis2_options_get_timeout_in_milli_seconds(svc_client->options, env) / 10; while(!axis2_callback_get_complete(callback, env)) { if(index-- >= 0) { AXIS2_USLEEP(10000); } else { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_RESPONSE_TIMED_OUT, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Response time out."); return NULL; } } soap_envelope = axis2_callback_get_envelope(callback, env); msg_ctx = axis2_callback_get_msg_ctx(callback, env); axis2_op_client_add_in_msg_ctx(svc_client->op_client, env, msg_ctx); /* start of hack to get rid of memory leak */ /*msg_ctx = axis2_msg_ctx_create(env, axis2_svc_ctx_get_conf_ctx(svc_client-> svc_ctx, env), NULL, NULL); if(!msg_ctx) return NULL; axis2_op_client_add_in_msg_ctx(svc_client->op_client, env, msg_ctx); axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope);*/ /* end of hack to get rid of memory leak */ /* process the result of the invocation */ if(!soap_envelope) { if(axis2_callback_get_error(callback, env) != AXIS2_ERROR_NONE) { AXIS2_ERROR_SET(env->error, axis2_callback_get_error(callback, env), AXIS2_FAILURE); return NULL; } } } else { msg_ctx = axis2_msg_ctx_create(env, axis2_svc_ctx_get_conf_ctx(svc_client->svc_ctx, env), NULL, NULL); if(!msg_ctx) return NULL; if(!axis2_svc_client_fill_soap_envelope(env, svc_client, msg_ctx, payload)) { return NULL; } if(!axis2_svc_client_create_op_client(svc_client, env, op_qname)) { return NULL; } axis2_op_client_add_msg_ctx(svc_client->op_client, env, msg_ctx); axis2_op_client_execute(svc_client->op_client, env, AXIS2_TRUE); axis2_svc_client_set_http_info(svc_client, env, msg_ctx); svc_client->auth_failed = axis2_msg_ctx_get_auth_failed(msg_ctx, env); svc_client->required_auth_is_http = axis2_msg_ctx_get_required_auth_is_http(msg_ctx, env); if(axis2_msg_ctx_get_auth_type(msg_ctx, env)) { svc_client->auth_type = axutil_strdup(env, axis2_msg_ctx_get_auth_type(msg_ctx, env)); } res_msg_ctx = (axis2_msg_ctx_t *)axis2_op_client_get_msg_ctx(svc_client-> op_client, env, AXIS2_WSDL_MESSAGE_LABEL_IN); if(res_msg_ctx) { soap_envelope = axis2_msg_ctx_get_soap_envelope(res_msg_ctx, env); } else { axis2_op_client_add_msg_ctx(svc_client->op_client, env, res_msg_ctx); /* set in msg_ctx to be NULL to reset */ } } if(qname_free_flag) { axutil_qname_free((axutil_qname_t *)op_qname, env); } if(!soap_envelope) { return NULL; } svc_client->last_response_soap_envelope = soap_envelope; soap_body = axiom_soap_envelope_get_body(soap_envelope, env); if(!soap_body) { axiom_node_t *node = axiom_soap_envelope_get_base_node(soap_envelope, env); if(node) { axiom_element_t *envelope_element = (axiom_element_t *)axiom_node_get_data_element( node, env); axiom_util_get_first_child_element_with_localname(envelope_element, env, node, AXIOM_SOAP_BODY_LOCAL_NAME, &soap_node); if(soap_node) { return axiom_node_get_first_element(soap_node, env); } } return NULL; } if(axis2_msg_ctx_get_doing_rest(res_msg_ctx, env)) { /* All HTTP 4xx and 5xx status codes are treated as errors */ if(axis2_msg_ctx_get_status_code(res_msg_ctx, env) >= 400) { svc_client->last_response_has_fault = AXIS2_TRUE; } else { svc_client->last_response_has_fault = AXIS2_FALSE; } } else { svc_client->last_response_has_fault = axiom_soap_body_has_fault(soap_body, env); } if(AXIOM_SOAP11 == axiom_soap_envelope_get_soap_version(soap_envelope, env)) { axiom_soap_body_convert_fault_to_soap11(soap_body, env); } soap_node = axiom_soap_body_get_base_node(soap_body, env); if(!soap_node) { return NULL; } return axiom_node_get_first_element(soap_node, env); }
static axis2_bool_t axis2_svc_client_fill_soap_envelope( const axutil_env_t * env, axis2_svc_client_t * svc_client, axis2_msg_ctx_t * msg_ctx, const axiom_node_t * payload) { const axis2_char_t *soap_version_uri; int soap_version; axiom_soap_envelope_t *envelope = NULL; AXIS2_PARAM_CHECK(env->error, svc_client, AXIS2_FAILURE); soap_version_uri = axis2_options_get_soap_version_uri(svc_client->options, env); if(!soap_version_uri) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot find soap version uri."); return AXIS2_FALSE; } if(axutil_strcmp(soap_version_uri, AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI) == 0) { soap_version = AXIOM_SOAP11; } else { soap_version = AXIOM_SOAP12; } envelope = axiom_soap_envelope_create_default_soap_envelope(env, soap_version); if(!envelope) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create default soap envelope."); return AXIS2_FALSE; } if(svc_client->headers) { axiom_soap_header_t *soap_header = NULL; soap_header = axiom_soap_envelope_get_header(envelope, env); if(soap_header) { axiom_node_t *header_node = NULL; header_node = axiom_soap_header_get_base_node(soap_header, env); if(header_node) { int size = 0; int i = 0; size = axutil_array_list_size(svc_client->headers, env); while(i < size) { axiom_node_t *node = NULL; node = axutil_array_list_remove(svc_client->headers, env, 0); /* This removes and retrieves data. The order of the * removal is chosen such that the headers are appended * in the order they were added. */ size--; if(node) { axiom_node_add_child(header_node, env, node); } } } } } if(payload) { axiom_soap_body_t *soap_body = NULL; soap_body = axiom_soap_envelope_get_body(envelope, env); if(soap_body) { axiom_node_t *node = NULL; node = axiom_soap_body_get_base_node(soap_body, env); if(node) { axiom_node_add_child(node, env, (axiom_node_t *)payload); } } } axis2_msg_ctx_set_soap_envelope(msg_ctx, env, envelope); return AXIS2_TRUE; }