axis2_status_t AXIS2_CALL sandesha2_msg_ctx_set_soap_envelope( sandesha2_msg_ctx_t *rm_msg_ctx, const axutil_env_t *env, axiom_soap_envelope_t *soap_envelope) { AXIS2_PARAM_CHECK(env->error, soap_envelope, AXIS2_FAILURE); return axis2_msg_ctx_set_soap_envelope(rm_msg_ctx->msg_ctx, env, soap_envelope); }
axiom_soap_envelope_t * wsdl_util_send_receive_soap_envelope_with_op_client( const axutil_env_t* env, axis2_svc_client_t* svc_client, axis2_options_t* options, axis2_char_t* buffer) { axiom_soap_envelope_t *res_envelope = NULL, *req_envelope = NULL; axis2_svc_ctx_t *svc_ctx = NULL; axis2_conf_ctx_t *conf_ctx = NULL; axis2_msg_ctx_t *req_msg_ctx = NULL, *res_msg_ctx = NULL; axutil_qname_t *op_qname = NULL; axis2_op_client_t *op_client = NULL; axis2_char_t *soap_version_uri = NULL; svc_ctx = axis2_svc_client_get_svc_ctx (svc_client, env); conf_ctx = axis2_svc_ctx_get_conf_ctx (svc_ctx, env); req_msg_ctx = axis2_msg_ctx_create (env, conf_ctx, NULL, NULL); op_qname = axutil_qname_create (env, AXIS2_ANON_OUT_IN_OP, NULL, NULL); op_client = axis2_svc_client_create_op_client (svc_client, env, op_qname); soap_version_uri = (axis2_char_t *) axis2_options_get_soap_version_uri (options, env); req_envelope = wsdl_util_create_soap_envelope_from_buffer (env, buffer, soap_version_uri); axis2_msg_ctx_set_soap_envelope (req_msg_ctx, env, req_envelope); axis2_op_client_add_msg_ctx (op_client, env, req_msg_ctx); axis2_op_client_execute (op_client, env, AXIS2_TRUE); res_msg_ctx = (axis2_msg_ctx_t *)axis2_op_client_get_msg_ctx (op_client, env, AXIS2_WSDL_MESSAGE_LABEL_IN); if (res_msg_ctx) { res_envelope = axis2_msg_ctx_get_soap_envelope (res_msg_ctx, env); } else { res_envelope = NULL; } return res_envelope; }
static axis2_status_t AXIS2_CALL axis2_msg_recv_receive_impl( axis2_msg_recv_t * msg_recv, const axutil_env_t * env, axis2_msg_ctx_t * msg_ctx, void *callback_recv_param) { axis2_msg_ctx_t *out_msg_ctx = NULL; axis2_engine_t *engine = NULL; axis2_conf_ctx_t *conf_ctx = NULL; axis2_op_ctx_t *op_ctx = NULL; axis2_svc_ctx_t *svc_ctx = NULL; axis2_status_t status = AXIS2_FAILURE; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[axis2]Entry:axis2_msg_recv_receive_impl"); out_msg_ctx = axis2_core_utils_create_out_msg_ctx(env, msg_ctx); if(!out_msg_ctx) { return AXIS2_FAILURE; } op_ctx = axis2_msg_ctx_get_op_ctx(out_msg_ctx, env); if(!op_ctx) { axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx); axis2_msg_ctx_free(out_msg_ctx, env); return AXIS2_FAILURE; } status = axis2_op_ctx_add_msg_ctx(op_ctx, env, out_msg_ctx); if(!status) { axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx); axis2_msg_ctx_free(out_msg_ctx, env); return status; } status = axis2_op_ctx_add_msg_ctx(op_ctx, env, msg_ctx); if(!status) { return status; } status = axis2_msg_recv_invoke_business_logic(msg_recv, env, msg_ctx, out_msg_ctx); if(AXIS2_SUCCESS != status) { axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx); axis2_msg_ctx_free(out_msg_ctx, env); return status; } svc_ctx = axis2_op_ctx_get_parent(op_ctx, env); conf_ctx = axis2_svc_ctx_get_conf_ctx(svc_ctx, env); engine = axis2_engine_create(env, conf_ctx); if(!engine) { axis2_msg_ctx_free(out_msg_ctx, env); return AXIS2_FAILURE; } if(axis2_msg_ctx_get_soap_envelope(out_msg_ctx, env)) { axiom_soap_envelope_t *soap_envelope = axis2_msg_ctx_get_soap_envelope(out_msg_ctx, env); if(soap_envelope) { axiom_soap_body_t *body = axiom_soap_envelope_get_body(soap_envelope, env); if(body) { /* in case of a SOAP fault, we got to return failure so that transport gets to know that it should send 500 */ if(axiom_soap_body_has_fault(body, env)) { status = AXIS2_FAILURE; axis2_msg_ctx_set_fault_soap_envelope(msg_ctx, env, soap_envelope); axis2_msg_ctx_set_soap_envelope(out_msg_ctx, env, NULL); } else { /* if it is two way and not a fault then send through engine. if it is one way we do not need to do an engine send */ status = axis2_engine_send(engine, env, out_msg_ctx); } } } } axis2_engine_free(engine, env); /* Reset the out message context to avoid double freeing at http worker. For example if this is * not done here both in and out message context will try to free the transport out stream * which will result in memory corruption. */ if(!axis2_msg_ctx_is_paused(out_msg_ctx, env) && !axis2_msg_ctx_is_keep_alive(out_msg_ctx, env)) { axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx); } AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[axis2]Exit:axis2_msg_recv_receive_impl"); return status; (void)callback_recv_param; }
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; }
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; }
/** * Create a new create_seq_response message. * @param env axis2 environment struct * @param create_seq_msg * @param out_msg * @param new_seq_id * @param seq_prop_mgr * @return sandesha2_msg_ctx_t */ sandesha2_msg_ctx_t * sandesha2_msg_creator_create_create_seq_res_msg( const axutil_env_t *env, sandesha2_msg_ctx_t *create_seq_msg, axis2_msg_ctx_t *out_msg, axis2_char_t *new_seq_id, sandesha2_seq_property_mgr_t *seq_prop_mgr) { axis2_conf_ctx_t *conf_ctx = NULL; axis2_msg_ctx_t *temp_msg_ctx = NULL; axis2_char_t *rm_version = NULL; axis2_char_t *rm_ns_value = NULL; axis2_char_t *addressing_ns_value = NULL; axis2_char_t *new_msg_id = NULL; axis2_char_t *temp_action = NULL; axutil_string_t *soap_action = NULL; axiom_soap_envelope_t *envelope = NULL; axiom_soap_envelope_t *temp_envelope = NULL; axiom_soap_body_t *temp_soap_body = NULL; axiom_node_t *temp_om_node = NULL; sandesha2_create_seq_res_t *create_seq_res = NULL; sandesha2_identifier_t *identifier = NULL; sandesha2_seq_offer_t *offer = NULL; sandesha2_msg_ctx_t *create_seq_res_rm_msg_ctx = NULL; sandesha2_create_seq_t *cs = NULL; int soap_version = -1; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_msg_creator_create_create_seq_res_msg"); temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); conf_ctx = axis2_msg_ctx_get_conf_ctx(temp_msg_ctx, env); cs = sandesha2_msg_ctx_get_create_seq(create_seq_msg, env); rm_version = sandesha2_utils_get_rm_version(env, temp_msg_ctx); if(!rm_version) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find rm version of given message"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_RM_VERSION_OF_GIVEN_MSG, AXIS2_FAILURE); return NULL; } rm_ns_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, rm_version); addressing_ns_value = sandesha2_utils_get_seq_property(env, new_seq_id, SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, seq_prop_mgr); if(!addressing_ns_value) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find addressing namespace value"); return NULL; } create_seq_res = sandesha2_create_seq_res_create(env, rm_ns_value, addressing_ns_value); identifier = sandesha2_identifier_create(env, rm_ns_value); sandesha2_identifier_set_identifier(identifier, env, new_seq_id); sandesha2_create_seq_res_set_identifier(create_seq_res, env, identifier); offer = sandesha2_create_seq_get_seq_offer(cs, env); if(offer) { axis2_char_t *out_seq_id = NULL; sandesha2_identifier_t *temp_identifier = NULL; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Offer present"); temp_identifier = sandesha2_seq_offer_get_identifier(offer, env); out_seq_id = sandesha2_identifier_get_identifier(temp_identifier, env); if(out_seq_id && axutil_strcmp("", out_seq_id)) { sandesha2_accept_t *accept = NULL; axis2_endpoint_ref_t *acks_to_epr = NULL; sandesha2_acks_to_t *acks_to = NULL; sandesha2_address_t *address = NULL; AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] out_seq_id present"); accept = sandesha2_accept_create(env, rm_ns_value, addressing_ns_value); if(accept) { axis2_endpoint_ref_t *temp_to_epr = NULL; acks_to_epr = sandesha2_msg_ctx_get_to(create_seq_msg, env); if(acks_to_epr) { temp_to_epr = sandesha2_util_endpoint_ref_clone(env, acks_to_epr); } address = sandesha2_address_create(env, addressing_ns_value, temp_to_epr); acks_to = sandesha2_acks_to_create(env, address, rm_ns_value, addressing_ns_value); sandesha2_accept_set_acks_to(accept, env, acks_to); sandesha2_create_seq_res_set_accept(create_seq_res, env, accept); } else { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Could not create accept element"); return NULL; } } } temp_envelope = sandesha2_msg_ctx_get_soap_envelope(create_seq_msg, env); soap_version = sandesha2_utils_get_soap_version(env, temp_envelope); envelope = axiom_soap_envelope_create_default_soap_envelope(env, soap_version); temp_soap_body = axiom_soap_envelope_get_body(envelope, env); temp_om_node = axiom_soap_body_get_base_node(temp_soap_body, env); sandesha2_create_seq_res_to_om_node(create_seq_res, env, temp_om_node); temp_action = sandesha2_spec_specific_consts_get_create_seq_res_action(env, rm_version); axis2_msg_ctx_set_wsa_action(out_msg, env, temp_action); soap_action = axutil_string_create(env, temp_action); /*if(soap_action) { axis2_msg_ctx_set_soap_action(out_msg, env, soap_action); axutil_string_free(soap_action, env); }*/ if(addressing_ns_value) { AXIS2_FREE(env->allocator, addressing_ns_value); } new_msg_id = axutil_uuid_gen(env); if(new_msg_id) { axis2_msg_ctx_set_message_id(out_msg, env, new_msg_id); AXIS2_FREE(env->allocator, new_msg_id); } axis2_msg_ctx_set_soap_envelope(out_msg, env, envelope); temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); sandesha2_msg_creator_init_creation(env, temp_msg_ctx, out_msg); create_seq_res_rm_msg_ctx = sandesha2_msg_init_init_msg(env, out_msg); sandesha2_msg_ctx_set_create_seq_res(create_seq_res_rm_msg_ctx, env, create_seq_res); temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env); sandesha2_msg_creator_finalize_creation(env, temp_msg_ctx, out_msg); axis2_msg_ctx_set_server_side(temp_msg_ctx, env, AXIS2_TRUE); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Exit:sandesha2_msg_creator_create_create_seq_res_msg"); return create_seq_res_rm_msg_ctx; }
axis2_status_t axis2_amqp_process_request( const axutil_env_t* env, axis2_amqp_request_processor_resource_pack_t* request_resource_pack) { axiom_xml_reader_t* xml_reader = NULL; axiom_stax_builder_t* stax_builder = NULL; axiom_soap_builder_t* soap_builder = NULL; axis2_transport_out_desc_t* out_desc = NULL; axis2_transport_in_desc_t* in_desc = NULL; axis2_msg_ctx_t* msg_ctx = NULL; axiom_soap_envelope_t* soap_envelope = NULL; axis2_engine_t* engine = NULL; const axis2_char_t* soap_ns_uri = NULL; axis2_bool_t is_soap_11 = AXIS2_FALSE; axis2_char_t *soap_body_str = NULL; int soap_body_len = 0; axis2_bool_t is_mtom = AXIS2_FALSE; axis2_status_t status = AXIS2_FAILURE; axutil_hash_t *binary_data_map = NULL; axiom_soap_body_t *soap_body = NULL; axutil_property_t* reply_to_property = NULL; /* Create msg_ctx */ if(!request_resource_pack->conf_ctx) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Conf Context not Available"); return AXIS2_FAILURE; } out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf( request_resource_pack->conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_AMQP); if(!out_desc) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport Out Descriptor not Found"); return AXIS2_FAILURE; } in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(request_resource_pack->conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_AMQP); if(!in_desc) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport In Descriptor not Found"); return AXIS2_FAILURE; } /* Create msg_ctx */ msg_ctx = axis2_msg_ctx_create(env, request_resource_pack->conf_ctx, in_desc, out_desc); axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE); /* Handle MTOM */ if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED)) { axis2_char_t* mime_boundary = axis2_amqp_util_get_value_from_content_type(env, request_resource_pack->content_type, AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY); if(mime_boundary) { axiom_mime_parser_t *mime_parser = NULL; int soap_body_len = 0; axutil_param_t *buffer_size_param = NULL; axutil_param_t *max_buffers_param = NULL; axutil_param_t *attachment_dir_param = NULL; axis2_char_t *value_size = NULL; axis2_char_t *value_num = NULL; axis2_char_t *value_dir = NULL; int size = 0; int num = 0; mime_parser = axiom_mime_parser_create(env); buffer_size_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_BUFFER_SIZE); if(buffer_size_param) { value_size = (axis2_char_t*)axutil_param_get_value(buffer_size_param, env); if(value_size) { size = atoi(value_size); axiom_mime_parser_set_buffer_size(mime_parser, env, size); } } max_buffers_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_MAX_BUFFERS); if(max_buffers_param) { value_num = (axis2_char_t*)axutil_param_get_value(max_buffers_param, env); if(value_num) { num = atoi(value_num); axiom_mime_parser_set_max_buffers(mime_parser, env, num); } } /* If this paramter is there mime_parser will cached the attachment * using to the directory for large attachments. */ attachment_dir_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_ATTACHMENT_DIR); if(attachment_dir_param) { value_dir = (axis2_char_t*)axutil_param_get_value(attachment_dir_param, env); if(value_dir) { axiom_mime_parser_set_attachment_dir(mime_parser, env, value_dir); } } if(mime_parser) { axis2_callback_info_t *callback_ctx = NULL; axutil_stream_t *stream = NULL; callback_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_callback_info_t)); stream = axutil_stream_create_basic(env); if(stream) { axutil_stream_write(stream, env, request_resource_pack->request_content, request_resource_pack->content_length); callback_ctx->env = env; callback_ctx->in_stream = stream; callback_ctx->content_length = request_resource_pack->content_length; callback_ctx->unread_len = request_resource_pack->content_length; callback_ctx->chunked_stream = NULL; } /*binary_data_map = axiom_mime_parser_parse(mime_parser, env, axis2_amqp_util_on_data_request, (void*)callback_ctx, mime_boundary);*/ if(!binary_data_map) { return AXIS2_FAILURE; } soap_body_str = axiom_mime_parser_get_soap_body_str(mime_parser, env); soap_body_len = axiom_mime_parser_get_soap_body_len(mime_parser, env); axutil_stream_free(stream, env); AXIS2_FREE(env->allocator, callback_ctx); axiom_mime_parser_free(mime_parser, env); } AXIS2_FREE(env->allocator, mime_boundary); } is_mtom = AXIS2_TRUE; } else { soap_body_str = request_resource_pack->request_content; soap_body_len = request_resource_pack->content_length; } soap_body_len = axutil_strlen(soap_body_str); xml_reader = axiom_xml_reader_create_for_memory(env, soap_body_str, soap_body_len, NULL, AXIS2_XML_PARSER_TYPE_BUFFER); if(!xml_reader) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Reader"); return AXIS2_FAILURE; } stax_builder = axiom_stax_builder_create(env, xml_reader); if(!stax_builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create StAX Builder"); return AXIS2_FAILURE; } soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; if(request_resource_pack->content_type) { if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML)) { is_soap_11 = AXIS2_TRUE; soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; } /*if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_APPL_SOAP)) { is_soap_11 = AXIS2_FALSE; soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; } else if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML)) { is_soap_11 = AXIS2_TRUE; soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; }*/ } soap_builder = axiom_soap_builder_create(env, stax_builder, soap_ns_uri); if(!soap_builder) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create SOAP Builder"); return AXIS2_FAILURE; } if(binary_data_map) { axiom_soap_builder_set_mime_body_parts(soap_builder, env, binary_data_map); } soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env); axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope); soap_body = axiom_soap_envelope_get_body(soap_envelope, env); if(!soap_body) { return AXIS2_FAILURE; } /* SOAPAction */ if(request_resource_pack->soap_action) { axis2_msg_ctx_set_soap_action(msg_ctx, env, axutil_string_create(env, request_resource_pack->soap_action)); } /* SOAP version */ axis2_msg_ctx_set_is_soap_11(msg_ctx, env, is_soap_11); /* Set ReplyTo in the msg_ctx as a property. This is used by the server when * 1. WS-A is not in use * 2. ReplyTo is an anonymous EPR - Sandesha2/Dual-channel */ reply_to_property = axutil_property_create_with_args(env, AXIS2_SCOPE_REQUEST, 0, 0, (void*)request_resource_pack->reply_to); axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO, reply_to_property); engine = axis2_engine_create(env, request_resource_pack->conf_ctx); if(AXIS2_TRUE == axiom_soap_body_has_fault(soap_body, env)) { status = axis2_engine_receive_fault(engine, env, msg_ctx); } else { status = axis2_engine_receive(engine, env, msg_ctx); } if(engine) { axis2_engine_free(engine, env); } if(soap_body_str && is_mtom) { AXIS2_FREE(env->allocator, soap_body_str); } return status; }
AXIS2_EXTERN axis2_msg_ctx_t * AXIS2_CALL axis2_engine_create_fault_msg_ctx( axis2_engine_t * engine, const axutil_env_t * env, axis2_msg_ctx_t * processing_context, const axis2_char_t * code_value, const axis2_char_t * reason_text) { axis2_msg_ctx_t *fault_ctx = NULL; axis2_endpoint_ref_t *fault_to = NULL; axis2_endpoint_ref_t *reply_to = NULL; axutil_stream_t *stream = NULL; axiom_soap_envelope_t *envelope = NULL; const axis2_char_t *wsa_action = NULL; const axis2_char_t *msg_id = NULL; axis2_relates_to_t *relates_to = NULL; axis2_char_t *msg_uuid = NULL; axis2_msg_info_headers_t *msg_info_headers = NULL; axis2_bool_t doing_rest = AXIS2_FALSE; AXIS2_PARAM_CHECK(env->error, processing_context, NULL); if(axis2_msg_ctx_get_process_fault(processing_context, env)) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_PROCESSING_FAULT_ALREADY, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating fault message contex failed"); return NULL; } fault_ctx = axis2_msg_ctx_create(env, engine->conf_ctx, axis2_msg_ctx_get_transport_in_desc( processing_context, env), axis2_msg_ctx_get_transport_out_desc(processing_context, env)); axis2_msg_ctx_set_process_fault(fault_ctx, env, AXIS2_TRUE); fault_to = axis2_msg_ctx_get_fault_to(processing_context, env); if(fault_to) { const axis2_char_t *address = axis2_endpoint_ref_get_address(fault_to, env); if(!address) { fault_to = NULL; } else if(axutil_strcmp(AXIS2_WSA_NONE_URL, address) == 0 || axutil_strcmp( AXIS2_WSA_NONE_URL_SUBMISSION, address) == 0) { reply_to = axis2_msg_ctx_get_reply_to(processing_context, env); if(reply_to) { axis2_msg_ctx_set_fault_to(fault_ctx, env, reply_to); } else { axis2_msg_ctx_set_fault_to(fault_ctx, env, fault_to); } } else { axis2_msg_ctx_set_fault_to(fault_ctx, env, fault_to); } } stream = axis2_msg_ctx_get_transport_out_stream(processing_context, env); if(stream) { axis2_msg_ctx_set_transport_out_stream(fault_ctx, env, stream); axis2_msg_ctx_reset_transport_out_stream(processing_context, env); } if(!fault_to && !stream) { AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NOWHERE_TO_SEND_FAULT, AXIS2_FAILURE); AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Soap fault target destination not found"); return NULL; } /* Set WSA action */ msg_info_headers = axis2_msg_ctx_get_msg_info_headers(processing_context, env); if(msg_info_headers) { wsa_action = axis2_msg_info_headers_get_action(msg_info_headers, env); if(wsa_action) { /* We have to use the action set by user, cannot use the default always. wsa_action = "http://www.w3.org/2005/08/addressing/fault"; */ axis2_msg_ctx_set_wsa_action(fault_ctx, env, wsa_action); } } /* Set relates to */ msg_id = axis2_msg_ctx_get_msg_id(processing_context, env); /* we can create with default Relates to namespace. Actual namespace based on addressing version will be created in addressing out handler */ relates_to = axis2_relates_to_create(env, msg_id, AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE); axis2_msg_ctx_set_relates_to(fault_ctx, env, relates_to); /* Set msg id */ msg_uuid = axutil_uuid_gen(env); axis2_msg_ctx_set_message_id(fault_ctx, env, msg_uuid); if(msg_uuid) { AXIS2_FREE(env->allocator, msg_uuid); msg_uuid = NULL; } /** Copy the property map from the current message context to the newly created fault message context. */ { axis2_ctx_t *ctx = axis2_msg_ctx_get_base(processing_context, env); axis2_ctx_t *fault_base_ctx = axis2_msg_ctx_get_base(fault_ctx, env); if(ctx && fault_ctx) { axis2_ctx_set_property_map(fault_base_ctx, env, axis2_ctx_get_property_map(ctx, env)); } } axis2_msg_ctx_set_op_ctx(fault_ctx, env, axis2_msg_ctx_get_op_ctx(processing_context, env)); axis2_msg_ctx_set_process_fault(fault_ctx, env, AXIS2_TRUE); axis2_msg_ctx_set_server_side(fault_ctx, env, AXIS2_TRUE); envelope = axis2_msg_ctx_get_fault_soap_envelope(processing_context, env); if(!envelope) { if(axis2_msg_ctx_get_is_soap_11(processing_context, env)) { envelope = axiom_soap_envelope_create_default_soap_fault_envelope(env, code_value, reason_text, AXIOM_SOAP11, NULL, NULL); } else { envelope = axiom_soap_envelope_create_default_soap_fault_envelope(env, code_value, reason_text, AXIOM_SOAP12, NULL, NULL); } if(!envelope) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Creating default soap envelope failed"); return NULL; } } else { axis2_msg_ctx_set_fault_soap_envelope(processing_context, env, NULL); } doing_rest = axis2_msg_ctx_get_doing_rest(processing_context, env); axis2_msg_ctx_set_doing_rest(fault_ctx, env, doing_rest); axis2_msg_ctx_set_soap_envelope(fault_ctx, env, envelope); axis2_msg_ctx_set_out_transport_info(fault_ctx, env, axis2_msg_ctx_get_out_transport_info( processing_context, env)); axis2_msg_ctx_reset_out_transport_info(processing_context, env); return fault_ctx; }
/* 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; }
axis2_status_t AXIS2_CALL sandesha2_msg_ctx_add_soap_envelope( sandesha2_msg_ctx_t *rm_msg_ctx, const axutil_env_t *env) { int soap_ver = AXIOM_SOAP11; axiom_soap_envelope_t *soap_envelope = NULL; if(!axis2_msg_ctx_get_is_soap_11(rm_msg_ctx->msg_ctx, env)) { soap_ver = AXIOM_SOAP12; } soap_envelope = axis2_msg_ctx_get_soap_envelope(rm_msg_ctx->msg_ctx, env); if(!soap_envelope) { soap_envelope = axiom_soap_envelope_create_default_soap_envelope(env, soap_ver); axis2_msg_ctx_set_soap_envelope(rm_msg_ctx->msg_ctx, env, soap_envelope); } if(rm_msg_ctx->close_seq) { sandesha2_close_seq_to_soap_envelope(rm_msg_ctx->close_seq, env, soap_envelope); } if(rm_msg_ctx->close_seq_res) { sandesha2_close_seq_res_to_soap_envelope(rm_msg_ctx->close_seq_res, env, soap_envelope); } if(rm_msg_ctx->create_seq) { sandesha2_create_seq_to_soap_envelope(rm_msg_ctx->create_seq, env, soap_envelope); } if(rm_msg_ctx->create_seq_res) { sandesha2_create_seq_res_to_soap_envelope(rm_msg_ctx->create_seq_res, env, soap_envelope); } if(rm_msg_ctx->make_connection) { sandesha2_make_connection_to_soap_envelope(rm_msg_ctx->make_connection, env, soap_envelope); } if(rm_msg_ctx->msg_pending) { sandesha2_msg_pending_to_soap_envelope(rm_msg_ctx->msg_pending, env, soap_envelope); } if(rm_msg_ctx->seq_ack) { sandesha2_seq_ack_to_soap_envelope(rm_msg_ctx->seq_ack, env, soap_envelope); } if(rm_msg_ctx->seq) { sandesha2_seq_to_soap_envelope(rm_msg_ctx->seq, env, soap_envelope); } if(rm_msg_ctx->terminate_seq) { sandesha2_terminate_seq_to_soap_envelope(rm_msg_ctx->terminate_seq, env, soap_envelope); } if(rm_msg_ctx->terminate_seq_res) { sandesha2_terminate_seq_res_to_soap_envelope(rm_msg_ctx->terminate_seq_res, env, soap_envelope); } return AXIS2_SUCCESS; }
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; }
static axis2_status_t AXIS2_CALL sandesha2_ack_req_msg_processor_process_in_msg ( sandesha2_msg_processor_t *msg_processor, const axutil_env_t *env, sandesha2_msg_ctx_t *rm_msg_ctx) { sandesha2_ack_requested_t *ack_requested = NULL; axis2_msg_ctx_t *msg_ctx = NULL; axis2_char_t *seq_id = NULL; axis2_conf_ctx_t *conf_ctx = NULL; sandesha2_storage_mgr_t *storage_mgr = NULL; sandesha2_seq_property_mgr_t *seq_prop_mgr = NULL; sandesha2_seq_property_bean_t *acks_to_bean = NULL; axis2_endpoint_ref_t *acks_to = NULL; axis2_char_t *acks_to_str = NULL; axis2_op_t *ack_op = NULL; axis2_op_t *rm_msg_op = NULL; axis2_msg_ctx_t *ack_msg_ctx = NULL; axutil_property_t *property = NULL; sandesha2_msg_ctx_t *ack_rm_msg = NULL; axiom_soap_envelope_t *envelope = NULL; axis2_char_t *wsa_version = NULL; axis2_char_t *dbname = NULL; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Entry:sandesha2_ack_req_msg_processor_process_in_msg"); AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE); ack_requested = sandesha2_msg_ctx_get_ack_requested(rm_msg_ctx, env); if(!ack_requested) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]Ack requested part is missing"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING, AXIS2_FAILURE); return AXIS2_FAILURE; } sandesha2_ack_requested_set_must_understand(ack_requested, env, AXIS2_FALSE); sandesha2_msg_ctx_add_soap_envelope(rm_msg_ctx, env); msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env); seq_id = sandesha2_identifier_get_identifier( sandesha2_ack_requested_get_identifier(ack_requested, env), env); conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env); dbname = sandesha2_util_get_dbname(env, conf_ctx); storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname); if(!storage_mgr) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Could not create storage manager."); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_COULD_NOT_CREATE_STORAGE_MANAGER, AXIS2_FAILURE); return AXIS2_FAILURE; } seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname); acks_to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, seq_id, SANDESHA2_SEQ_PROP_ACKS_TO_EPR); acks_to_str = sandesha2_seq_property_bean_get_value(acks_to_bean, env); if(!acks_to_str) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]acks_to_str"\ " seqeunce property is not set correctly"); if(seq_prop_mgr) sandesha2_seq_property_mgr_free(seq_prop_mgr, env); if(storage_mgr) sandesha2_storage_mgr_free(storage_mgr, env); return AXIS2_FAILURE; } acks_to = axis2_endpoint_ref_create(env, acks_to_str); ack_op = axis2_op_create(env); axis2_op_set_msg_exchange_pattern(ack_op, env, AXIS2_MEP_URI_IN_ONLY); rm_msg_op = axis2_msg_ctx_get_op(msg_ctx, env); if(rm_msg_op) { axutil_array_list_t *out_flow = NULL; axutil_array_list_t *new_out_flow = NULL; axutil_array_list_t *out_fault_flow = NULL; axutil_array_list_t *new_out_fault_flow = NULL; out_flow = axis2_op_get_out_flow(rm_msg_op, env); new_out_flow = axis2_phases_info_copy_flow(env, out_flow); out_fault_flow = axis2_op_get_out_flow(rm_msg_op, env); new_out_fault_flow = axis2_phases_info_copy_flow(env, out_fault_flow); if(new_out_flow) axis2_op_set_out_flow(ack_op, env, new_out_flow); if(new_out_fault_flow) axis2_op_set_fault_out_flow(ack_op, env, new_out_fault_flow); } ack_msg_ctx = sandesha2_utils_create_new_related_msg_ctx(env, rm_msg_ctx); property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE); axis2_msg_ctx_set_property(ack_msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, property); ack_rm_msg = sandesha2_msg_init_init_msg(env, ack_msg_ctx); sandesha2_msg_ctx_set_rm_ns_val(ack_rm_msg, env, sandesha2_msg_ctx_get_rm_ns_val(rm_msg_ctx, env)); axis2_msg_ctx_set_message_id(ack_msg_ctx, env, axutil_uuid_gen(env)); envelope = axiom_soap_envelope_create_default_soap_envelope(env, sandesha2_utils_get_soap_version(env, axis2_msg_ctx_get_soap_envelope(msg_ctx, env))); axis2_msg_ctx_set_soap_envelope(ack_msg_ctx, env, envelope); axis2_msg_ctx_set_to(ack_msg_ctx, env, acks_to); axis2_msg_ctx_set_reply_to(ack_msg_ctx, env, axis2_msg_ctx_get_to(msg_ctx, env)); sandesha2_msg_creator_add_ack_msg(env, ack_rm_msg, seq_id, seq_prop_mgr); axis2_msg_ctx_set_server_side(ack_msg_ctx, env, AXIS2_TRUE); property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_WSA_VERSION); if(property) wsa_version = axutil_property_get_value(property, env); property = axutil_property_create_with_args(env, 0, 0, 0, wsa_version); if(property) { axis2_msg_ctx_set_property(ack_msg_ctx, env, AXIS2_WSA_VERSION, property); property = NULL; } if(sandesha2_utils_is_anon_uri(env, acks_to_str)) { axis2_engine_t *engine = NULL; axis2_op_ctx_t *op_ctx = NULL; if(!axis2_msg_ctx_get_op(msg_ctx, env)) { axis2_op_t *operation = NULL; axis2_op_ctx_t *op_ctx = NULL; operation = axis2_op_create(env); axis2_op_set_msg_exchange_pattern(operation, env, AXIS2_MEP_URI_IN_OUT); op_ctx = axis2_op_ctx_create(env, operation, NULL); axis2_msg_ctx_set_op(msg_ctx, env, operation); axis2_msg_ctx_set_op_ctx(msg_ctx, env, op_ctx); } op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env); axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_TRUE); property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE); axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_ACK_WRITTEN, property); engine = axis2_engine_create(env, conf_ctx); if(AXIS2_FAILURE == axis2_engine_send(engine, env, ack_msg_ctx)) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]ack sending failed"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SENDING_ACK, AXIS2_FAILURE); if(engine) { axis2_engine_free(engine, env); engine = NULL; } if(seq_prop_mgr) sandesha2_seq_property_mgr_free(seq_prop_mgr, env); if(storage_mgr) sandesha2_storage_mgr_free(storage_mgr, env); return AXIS2_FAILURE; } if(engine) { axis2_engine_free(engine, env); engine = NULL; } } else { sandesha2_sender_mgr_t *sender_mgr = NULL; axis2_char_t *key = NULL; sandesha2_sender_bean_t *ack_bean = NULL; sandesha2_sender_bean_t *find_bean = NULL; sandesha2_property_bean_t *prop_bean = NULL; long ack_interval = 0; long time_to_send = 0; axutil_array_list_t *found_list = NULL; axis2_msg_ctx_t *msg_ctx = NULL; axis2_engine_t *engine = NULL; axis2_transport_out_desc_t *transport_out = NULL; axis2_svc_t *svc = NULL; sender_mgr = sandesha2_permanent_sender_mgr_create(env, dbname); key = axutil_uuid_gen(env); ack_bean = sandesha2_sender_bean_create(env); sandesha2_sender_bean_set_msg_ctx_ref_key(ack_bean, env, key); sandesha2_sender_bean_set_msg_id(ack_bean, env, (axis2_char_t*)axis2_msg_ctx_get_msg_id(ack_msg_ctx, env)); sandesha2_sender_bean_set_resend(ack_bean, env, AXIS2_FALSE); sandesha2_sender_bean_set_seq_id(ack_bean, env, seq_id); sandesha2_sender_bean_set_send(ack_bean, env, AXIS2_TRUE); sandesha2_sender_bean_set_msg_type(ack_bean, env, SANDESHA2_MSG_TYPE_ACK); property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_FALSE); axis2_msg_ctx_set_property(ack_msg_ctx, env, SANDESHA2_QUALIFIED_FOR_SENDING, property); /* Avoid retrieving property bean from operation until it is availbale */ /*prop_bean = sandesha2_utils_get_property_bean_from_op(env, axis2_msg_ctx_get_op(msg_ctx, env));*/ svc = axis2_msg_ctx_get_svc(ack_msg_ctx, env); if(!svc) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2][ack_req_msg_processor.c] service is NULL"); return AXIS2_FAILURE; } prop_bean = sandesha2_utils_get_property_bean(env, svc); if(!prop_bean) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2][ack_req_msg_processor.c] Property bean is NULL"); return AXIS2_FAILURE; } /*prop_bean = sandesha2_utils_get_property_bean(env, axis2_conf_ctx_get_conf(conf_ctx, env));*/ prop_bean = sandesha2_utils_get_property_bean(env, svc); ack_interval = sandesha2_property_bean_get_ack_interval(prop_bean, env); time_to_send = sandesha2_utils_get_current_time_in_millis(env) + ack_interval; find_bean = sandesha2_sender_bean_create(env); sandesha2_sender_bean_set_resend(find_bean, env, AXIS2_FALSE); sandesha2_sender_bean_set_send(find_bean, env, AXIS2_TRUE); sandesha2_sender_bean_set_msg_type(find_bean, env, SANDESHA2_MSG_TYPE_ACK); found_list = sandesha2_sender_mgr_find_by_sender_bean(sender_mgr, env, find_bean); if(find_bean) sandesha2_sender_bean_free(find_bean, env); if(found_list) { int i = 0; for(i = 0; i < axutil_array_list_size(found_list, env); i++) { axis2_char_t *msg_stored_key = NULL; sandesha2_sender_bean_t *old_ack_bean = NULL; old_ack_bean = axutil_array_list_get(found_list, env, i); time_to_send = sandesha2_sender_bean_get_time_to_send( old_ack_bean, env); /*char *msg_id = sandesha2_sender_bean_get_msg_id(old_ack_bean, env);*/ sandesha2_sender_mgr_remove(sender_mgr, env, sandesha2_sender_bean_get_msg_id(old_ack_bean, env)); /* Removing the message from the storage */ msg_stored_key = sandesha2_sender_bean_get_msg_ctx_ref_key( old_ack_bean, env); sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, msg_stored_key, conf_ctx, -1); } } sandesha2_sender_bean_set_time_to_send(ack_bean, env, time_to_send); /*axis2_msg_ctx_set_keep_alive(ack_msg_ctx, env, AXIS2_TRUE);*/ sandesha2_storage_mgr_store_msg_ctx(storage_mgr, env, key, ack_msg_ctx, AXIS2_FALSE); sandesha2_sender_mgr_insert(sender_mgr, env, ack_bean); transport_out = axis2_msg_ctx_get_transport_out_desc(ack_msg_ctx, env); property = axutil_property_create_with_args(env, 0, 0, axis2_transport_out_desc_free_void_arg, transport_out); axis2_msg_ctx_set_property(ack_msg_ctx, env, SANDESHA2_ORIGINAL_TRANSPORT_OUT_DESC, property); property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE); axis2_msg_ctx_set_property(ack_msg_ctx, env, SANDESHA2_SET_SEND_TO_TRUE, property); property = axutil_property_create_with_args(env, 0, 0, 0, key); axis2_msg_ctx_set_property(ack_msg_ctx, env, SANDESHA2_MESSAGE_STORE_KEY, property); axis2_msg_ctx_set_transport_out_desc(ack_msg_ctx, env, sandesha2_utils_get_transport_out(env)); engine = axis2_engine_create(env, conf_ctx); if(AXIS2_FAILURE == axis2_engine_send(engine, env, ack_msg_ctx)) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]ack sending failed"); AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SENDING_ACK, AXIS2_FAILURE); if(engine) axis2_engine_free(engine, env); if(seq_prop_mgr) sandesha2_seq_property_mgr_free(seq_prop_mgr, env); if(sender_mgr) sandesha2_sender_mgr_free(sender_mgr, env); if(storage_mgr) sandesha2_storage_mgr_free(storage_mgr, env); return AXIS2_FAILURE; } if(engine) axis2_engine_free(engine, env); sandesha2_utils_start_sender_for_seq(env, conf_ctx, seq_id, AXIS2_FALSE); axis2_msg_ctx_set_paused(msg_ctx, env, AXIS2_TRUE); if(sender_mgr) sandesha2_sender_mgr_free(sender_mgr, env); } if(seq_prop_mgr) sandesha2_seq_property_mgr_free(seq_prop_mgr, env); if(storage_mgr) sandesha2_storage_mgr_free(storage_mgr, env); AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Exit:sandesha2_ack_req_msg_processor_process_in_msg"); return AXIS2_SUCCESS; }