示例#1
0
        public JsonResult GetPlc(string data)
        {
            string    url     = "http://172.18.157.36:8084/Service1.svc";
            IService1 proxy   = WcfInvokeFactory.CreateServiceByUrl <IService1>(url);
            string    wcfdata = proxy.GetData(Convert.ToInt32(data)) + "hello";
            string    message = "ok Plc" + wcfdata;

            return(Json(new { IsSuccess = true, message }));
        }
示例#2
0
        public JsonResult GetMen()
        {
            string    url   = "http://172.18.157.36:8084/Service1.svc";
            IService1 proxy = WcfInvokeFactory.CreateServiceByUrl <IService1>(url);
            //string wcfdata = proxy.GetData(s);
            //Console.WriteLine(result);

            string wcfdata = proxy.ControlLock() + "hello";
            string message = "ok Men" + wcfdata;

            return(Json(new { IsSuccess = true, message }));
        }
示例#3
0
        public JsonResult GetData1(string name, string data)
        {
            //string wcfdata = "hello,this is second   "+data;
            //需要将泵站的名称传过来。
            string port = "8084";
            string ip   = new MasterData_BLL().GetIpByName(name);
            string url  = "http://" + ip + ":" + port + "/Service1.svc";
            //string url= "http://192.168.1.101:8051/Service1.svc";
            IService1 proxy   = WcfInvokeFactory.CreateServiceByUrl <IService1>(url);
            string    wcfdata = proxy.GetData(Convert.ToInt32(data)) + "hello" + data;

            return(Json(new { IsSuccess = true, wcfdata }));
        }
示例#4
0
        public JsonResult GetData(string num, string name)
        {
            //string wcfdata = "hello"+num;
            //从这里进行查询
            //string url = "http://192.168.2.7:8072/Service1.svc";
            string    ip    = new MasterData_BLL().GetIpByName(name);
            string    port  = "8084";
            string    url   = "http://" + ip + ":" + port + "/Service1.svc";
            IService1 proxy = WcfInvokeFactory.CreateServiceByUrl <IService1>(url);
            //string wcfdata = proxy.GetData(s);
            //Console.WriteLine(result);
            string wcfdata = proxy.ControlLock() + "hello" + num;

            return(Json(new { IsSuccess = true, wcfdata }));
            //return Json(new { IsSuccess = true, wcfdata });
        }
示例#5
0
        public static string GetWcfMethod()
        {
            string result = string.Empty;
            string url    = "http://127.0.0.1:8888/HelloService/";
            //第一种方式
            IIHelloService proxy = WcfInvokeFactory.CreateServiceByUrl <IIHelloService>(url);

            //第二种方式
            // ChannelFactory<IIHelloService> ddd = WcfInvokeFactory.GetChannelFactory11<IIHelloService>(url);
            //第三种方式
            WcfInvokeFactory.Invoke <IIHelloService>(url, wcfService =>
            {
                result            = wcfService.DoWork();
                var name          = wcfService.GetName();
                var sex           = wcfService.GetSex();
                UserInfo userinfo = new UserInfo();
                userinfo.name     = "zhangsan";
                userinfo.age      = "12";
                var userInfo      = wcfService.GetUserInfo(userinfo);
            });
            return(proxy.DoWork());
        }