/// <summary> /// 请求响应调用 /// </summary> /// <param name="serviceName">服务名称</param> /// <param name="methodName">方法名称</param> /// <param name="message">消息内容</param> /// <param name="version">服务版本:0代表调用默认版本</param> /// <returns></returns> public String Invoke(String serviceName, String methodName, String message, Int32 version = 0, AdvanceInvokeParam invokeParam = null) { DateTime reqStartTime = DateTime.Now; String hostName = m_ConsumerConfig.ApplicationName; if (invokeParam != null && !String.IsNullOrWhiteSpace(invokeParam.ConsumerAppName)) { hostName = invokeParam.ConsumerAppName; } ESB.Core.Schema.务请求 req = new ESB.Core.Schema.务请求(); req.务名称 = serviceName; req.方法名称 = methodName; req.请求时间 = reqStartTime; req.主机名称 = hostName; req.消息内容 = message; req.消息编码 = ""; req.密码 = ""; //--从ESBConfig中获取到服务版本信息 ServiceItem si = GetServiceItem(serviceName, version); //--从ESBConfig中获取到服务版本信息 EsbView_ServiceConfig sc = this.ESBConfig.GetServiceConfig(serviceName, GetMethodName(methodName)); String msg = EsbClient.DynamicalCallWebService(true, req, si.Binding, si.Version, sc, invokeParam).消息内容; return(msg); }
/// <summary> /// 请求响应端口 /// </summary> /// <param name="request"></param> /// <returns></returns> public String ReceiveRequest(String serviceName, String methodName, String message) { ESB.Core.Schema.务请求 req = new ESB.Core.Schema.务请求(); req.务名称 = serviceName; req.方法名称 = methodName; req.请求时间 = DateTime.Now; req.主机名称 = m_ConsumerConfig.ApplicationName; req.消息内容 = message; req.消息编码 = ""; req.密码 = ""; return(EsbClient.DynamicalCallWebService(true, req).消息内容); }
static void Test() { var uri = "http://localhost:22451/ProductService.svc"; using (var client = new EsbClient()) { var service = client.GetClientProxy <IProductService>(uri); for (var i = 0; i < 1000; i++) { var name = service.GetByCode($"{Guid.NewGuid()}"); Console.WriteLine(name); } } }