axis2_status_t wsclient_set_https_transport_parameretes (const axutil_env_t *env, axis2_svc_client_t *svc_client) { axis2_conf_ctx_t *conf_ctx; axis2_svc_ctx_t *svc_ctx; axis2_conf_t *conf; axutil_qname_t *qname; axis2_transport_out_desc_t *transport_out; axis2_transport_sender_t *transport_sender; axutil_param_t *param; AXIS2_TRANSPORT_ENUMS transport_enum=AXIS2_TRANSPORT_ENUM_HTTP; if (svc_client) svc_ctx = axis2_svc_client_get_svc_ctx (svc_client, env); else return AXIS2_FAILURE; if (svc_ctx) conf_ctx = axis2_svc_ctx_get_conf_ctx(svc_ctx, env); else return AXIS2_FAILURE; if (conf_ctx) conf = axis2_conf_ctx_get_conf(conf_ctx, env); else return AXIS2_FAILURE; qname = axutil_qname_create (env, "https", NULL, NULL); if (qname) transport_out = axis2_transport_out_desc_create(env, transport_enum); else return AXIS2_FAILURE; transport_sender = (axis2_transport_sender_t *)axis2_http_transport_sender_create (env); param = axutil_param_create (env, NULL, NULL); if (param) { axutil_param_set_name(param, env, (void *)axutil_strdup (env, AXIS2_HTTP_PROTOCOL_VERSION)); axutil_param_set_value(param, env, (void *)axutil_strdup (env, AXIS2_HTTP_HEADER_PROTOCOL_11)); axutil_param_set_locked(param, env, AXIS2_FALSE); } else return AXIS2_FAILURE; if (transport_out && conf) { axis2_transport_out_desc_add_param (transport_out, env, param); axis2_transport_out_desc_set_sender(transport_out, env, transport_sender); axis2_conf_add_transport_out (conf, env, transport_out, AXIS2_TRANSPORT_ENUM_HTTP); } else return AXIS2_FAILURE; return AXIS2_SUCCESS; }
axis2_status_t AXIS2_CALL axis2_statistics_admin_out_op_count_handler_invoke(struct axis2_handler *handler, const axutil_env_t *env, struct axis2_msg_ctx *msg_ctx) { axis2_status_t status = AXIS2_SUCCESS; service_admin_counter_t *counter = NULL; axutil_param_t *param = NULL; axis2_op_t *op = NULL; axis2_svc_t *svc = NULL; const axis2_char_t *svc_name = NULL; AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[adminservices] Start:axis2_statistics_admin_out_op_count_handler_invoke"); AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE); svc = axis2_msg_ctx_get_svc(msg_ctx, env); if(svc) { svc_name = axis2_svc_get_name(svc, env); } op = axis2_msg_ctx_get_op(msg_ctx, env); if(op) { param = axis2_op_get_param(op, env, AXIS2_OUT_OPERATION_COUNTER); if(param) { counter = axutil_param_get_value(param, env); if(counter) { service_admin_counter_increment(counter, env, msg_ctx); } } else { axis2_char_t *op_name = NULL; op_name = axutil_qname_get_localpart(axis2_op_get_qname(op, env), env); axutil_allocator_switch_to_global_pool(env->allocator); counter = service_admin_counter_create(env, svc_name, op_name); if(counter) { service_admin_counter_increment(counter, env, msg_ctx); param = axutil_param_create(env, AXIS2_OUT_OPERATION_COUNTER, counter); if(param) { axis2_op_add_param(op, env, param); } } axutil_allocator_switch_to_local_pool(env->allocator); } } AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[adminservices] End:axis2_statistics_admin_out_op_count_handler_invoke"); return status; }
axis2_status_t wsf_wsdl_util_add_security_to_svc_configuration( const axutil_env_t* env, axutil_hash_t* security_token_hash, axis2_svc_t* svc) { rampart_context_t* rampart_ctx = NULL; axutil_param_t *security_param = NULL; rampart_ctx = rampart_context_create(env); wsf_wsdl_util_set_security_token_options_to_rampart_ctx (env, security_token_hash, rampart_ctx); security_param = axutil_param_create (env, WSF_WSDL_RAMPART_CONFIGURATION, (void *)rampart_ctx); return axis2_svc_add_param (svc, env, security_param); }
bool Axis2UtilsCreateVirtualService(const staff::ServiceWrapper* pServiceWrapper, const struct axutil_env* pEnv, struct axis2_conf* pConf) { if (!pServiceWrapper) { staff::LogError() << "pService is NULL"; return false; } const std::string& sServiceName = pServiceWrapper->GetName(); std::string sServiceGroupName = sServiceName + "SvcGroup"; std::string sServiceUri = "http://staff.tempui.org:9090/axis2/services/"; sServiceUri += sServiceName.c_str(); std::string sWsdlPath = staff::Runtime::Inst().GetComponentHome(pServiceWrapper->GetComponent()->GetName()) + STAFF_PATH_SEPARATOR + pServiceWrapper->GetName() + ".wsdl"; axutil_qname_t* pQName = axutil_qname_create(pEnv, sServiceName.c_str(), sServiceUri.c_str(), NULL); if (!pQName) { staff::LogError() << "pQName"; return false; } axis2_svc_t* pAxis2Service = axis2_svc_create_with_qname(pEnv, pQName); if (!pAxis2Service) { axutil_qname_free(pQName, pEnv); staff::LogError() << "pAxis2Service"; return false; } axutil_qname_free(pQName, pEnv); // set "virtual" service flag static char szParamName[] = "IsStaffVirtualService"; // allocate data C-way, so axis2/c can free it int* pnParam = reinterpret_cast<int*>(AXIS2_MALLOC(pEnv->allocator, sizeof(int))); if (!pnParam) { axis2_svc_free(pAxis2Service, pEnv); staff::LogError() << "can't allocate param"; return false; } *pnParam = 1; axutil_param_t* pParam = axutil_param_create(pEnv, static_cast<axis2_char_t*>(szParamName), pnParam); if (!pParam) { axis2_svc_free(pAxis2Service, pEnv); staff::LogError() << "pParam"; return false; } if (axis2_svc_add_param(pAxis2Service, pEnv, pParam) != AXIS2_SUCCESS) { axis2_svc_free(pAxis2Service, pEnv); staff::LogError() << "pParam"; return false; } { // adding operations const staff::DataObject& rdoOperations = pServiceWrapper->GetOperations(); for (staff::DataObject tdoOperation = rdoOperations.FirstChild(); !tdoOperation.IsNull(); tdoOperation.SetNextSibling()) { const std::string& sOpName = tdoOperation.GetChildByLocalName("Name").GetText(); struct axis2_op* pOperation = axis2_op_create(pEnv); pQName = axutil_qname_create(pEnv, sOpName.c_str(), NULL, NULL); if (!pQName) { axis2_svc_free(pAxis2Service, pEnv); staff::LogError() << "pQName(op)"; return false; } if (axis2_op_set_qname(pOperation, pEnv, pQName) != AXIS2_SUCCESS) { axutil_qname_free(pQName, pEnv); axis2_svc_free(pAxis2Service, pEnv); staff::LogError() << "axis2_op_set_qname"; return false; } axutil_qname_free(pQName, pEnv); // add REST params if exists std::string sRestMethod; std::string sRestLocation; { const staff::DataObject& rdoOperationConst = tdoOperation; staff::DataObject::ConstIterator itRestTmp = rdoOperationConst.FindChildByLocalName("RestMethod"); if (itRestTmp != rdoOperationConst.End()) { sRestMethod = itRestTmp->GetText(); } itRestTmp = rdoOperationConst.FindChildByLocalName("RestLocation"); if (itRestTmp != rdoOperationConst.End()) { sRestLocation = itRestTmp->GetText(); } } if (!sRestLocation.empty() && !sRestMethod.empty()) { if (axis2_op_set_rest_http_method(pOperation, pEnv, sRestMethod.c_str()) != AXIS2_SUCCESS) { staff::LogError() << "Failed to set \"RESTMethod\" to service [" << sServiceName <<"] operation " << sOpName; } else { staff::LogDebug2() << "\"RESTMethod=" << sRestMethod << "\" param set to service [" << sServiceName <<"] operation " << sOpName; } if (axis2_op_set_rest_http_location(pOperation, pEnv, sRestLocation.c_str()) != AXIS2_SUCCESS) { staff::LogError() << "Failed to set \"RESTLocation\" to service [" << sServiceName <<"] operation " << sOpName; } else { staff::LogDebug2() << "\"RESTLocation=" << sRestLocation << "\" param set to service [" << sServiceName <<"] operation " << sOpName; } if (axis2_svc_add_rest_mapping(pAxis2Service, pEnv, sRestMethod.c_str(), sRestLocation.c_str(), pOperation) != AXIS2_SUCCESS) { staff::LogError() << "Failed to set REST mapping to service [" << sServiceName <<"] operation " << sOpName; } } // add service operation if (axis2_svc_add_op(pAxis2Service, pEnv, pOperation) != AXIS2_SUCCESS) { axis2_svc_free(pAxis2Service, pEnv); staff::LogError() << "axis2_svc_add_op"; return false; } } } std::string sServiceDescr = pServiceWrapper->GetDescr(); FILE* pFile = fopen(sWsdlPath.c_str(), "rb"); if (pFile) { fclose(pFile); sServiceDescr += " <sup>[<a style='font-size: x-small' href='/axis2/services/staff.wsdl.Wsdl/get/" + pServiceWrapper->GetComponent()->GetName() + "/" + pServiceWrapper->GetName() + ".wsdl'>wsdl</a>]</sup>"; if (axis2_svc_set_svc_wsdl_path(pAxis2Service, pEnv, sWsdlPath.c_str()) != AXIS2_SUCCESS) { staff::LogError() << "axis2_svc_set_svc_wsdl_path"; } } if (axis2_svc_set_svc_desc(pAxis2Service, pEnv, sServiceDescr.c_str()) != AXIS2_SUCCESS) { axis2_svc_free(pAxis2Service, pEnv); staff::LogError() << "axis2_svc_set_svc_desc"; return false; } // creating service group axis2_svc_grp_t* pServiceGroup = axis2_svc_grp_create_with_conf(pEnv, pConf); if (!pServiceGroup) { axis2_svc_free(pAxis2Service, pEnv); staff::LogError() << "axis2_svc_grp_create_with_conf"; return false; } if (axis2_svc_grp_set_name(pServiceGroup, pEnv, sServiceGroupName.c_str()) != AXIS2_SUCCESS) { axis2_svc_grp_free(pServiceGroup, pEnv); axis2_svc_free(pAxis2Service, pEnv); staff::LogError() << "axis2_svc_grp_set_name"; return false; } if (axis2_svc_grp_add_svc(pServiceGroup, pEnv, pAxis2Service) != AXIS2_SUCCESS) { axis2_svc_grp_free(pServiceGroup, pEnv); axis2_svc_free(pAxis2Service, pEnv); staff::LogError() << "axis2_svc_grp_add_svc"; return false; } // adding to configuration if (axis2_conf_add_svc_grp(pConf, pEnv, pServiceGroup) != AXIS2_SUCCESS) { axis2_svc_grp_free(pServiceGroup, pEnv); axis2_svc_free(pAxis2Service, pEnv); staff::LogError() << "axis2_conf_add_svc_grp"; return false; } return true; }
AXIS2_EXTERN axis2_status_t AXIS2_CALL axis2_svc_client_set_proxy_with_auth( axis2_svc_client_t * svc_client, const axutil_env_t * env, axis2_char_t * proxy_host, axis2_char_t * proxy_port, axis2_char_t * username, axis2_char_t * password) { axis2_transport_out_desc_t *trans_desc = NULL; axis2_conf_t *conf = NULL; axutil_param_container_t *param_container; axutil_param_t *param; axis2_char_t *proxy = AXIS2_HTTP_PROXY_API; axutil_hash_t *attribute; axutil_generic_obj_t *host_obj = NULL; axutil_generic_obj_t *port_obj = NULL; axutil_generic_obj_t *username_obj = NULL; axutil_generic_obj_t *password_obj = NULL; axiom_attribute_t *host_attr = NULL; axiom_attribute_t *port_attr = NULL; axiom_attribute_t *username_attr = NULL; axiom_attribute_t *password_attr = NULL; AXIS2_PARAM_CHECK(env->error, svc_client, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, proxy_host, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, proxy_port, AXIS2_FAILURE); if(svc_client->conf) { conf = svc_client->conf; trans_desc = axis2_conf_get_transport_out(conf, env, AXIS2_TRANSPORT_ENUM_HTTP); if(!trans_desc) { return AXIS2_FAILURE; } param_container = axis2_transport_out_desc_param_container(trans_desc, env); param = axutil_param_create(env, proxy, (void *)NULL); if(!param) { return AXIS2_FAILURE; } attribute = axutil_hash_make(env); host_obj = axutil_generic_obj_create(env); port_obj = axutil_generic_obj_create(env); host_attr = axiom_attribute_create(env, AXIS2_HTTP_PROXY_HOST, proxy_host, NULL); port_attr = axiom_attribute_create(env, AXIS2_HTTP_PROXY_PORT, proxy_port, NULL); axutil_generic_obj_set_value(host_obj, env, host_attr); axutil_generic_obj_set_free_func(host_obj, env, axiom_attribute_free_void_arg); axutil_generic_obj_set_value(port_obj, env, port_attr); axutil_generic_obj_set_free_func(port_obj, env, axiom_attribute_free_void_arg); axutil_hash_set(attribute, AXIS2_HTTP_PROXY_HOST, AXIS2_HASH_KEY_STRING, host_obj); axutil_hash_set(attribute, AXIS2_HTTP_PROXY_PORT, AXIS2_HASH_KEY_STRING, port_obj); if(username && password) { username_obj = axutil_generic_obj_create(env); password_obj = axutil_generic_obj_create(env); username_attr = axiom_attribute_create(env, AXIS2_HTTP_PROXY_USERNAME, username, NULL); password_attr = axiom_attribute_create(env, AXIS2_HTTP_PROXY_PASSWORD, password, NULL); axutil_generic_obj_set_value(username_obj, env, username_attr); axutil_generic_obj_set_value(password_obj, env, password_attr); axutil_generic_obj_set_free_func(username_obj, env, axiom_attribute_free_void_arg); axutil_generic_obj_set_free_func(password_obj, env, axiom_attribute_free_void_arg); axutil_hash_set(attribute, AXIS2_HTTP_PROXY_USERNAME, AXIS2_HASH_KEY_STRING, username_obj); axutil_hash_set(attribute, AXIS2_HTTP_PROXY_PASSWORD, AXIS2_HASH_KEY_STRING, password_obj); } axutil_param_set_attributes(param, env, attribute); axutil_param_container_add_param(param_container, env, param); } return AXIS2_SUCCESS; }