static void Main(string[] args) { TTransport transport = new TSocket("127.0.0.1", 7911); TProtocol protocol = new TBinaryProtocol(transport); ThriftCase.Client client = new ThriftCase.Client(protocol); transport.Open(); try { int i = client.testCase1(1, 2, "3"); Console.WriteLine(i); Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("num1", "1"); dic.Add("num2", "2"); List <string> values = client.testCase2(dic); foreach (var item in values) { Console.WriteLine(item); } } catch (Thrift.TApplicationException x) { Console.WriteLine(x.StackTrace); } finally { transport.Close(); } Console.ReadKey(); }
static void Main(string[] args) { MessageObject mo1 = new MessageObject { TimeStamp = DateTime.Now, Message = "begin process...." }; LogHelper.WriteLogInfo(typeof(Program), mo1); TTransport transport = new TSocket("localhost", 7911); TProtocol protocol = new TBinaryProtocol(transport); ThriftCase.Client client = new ThriftCase.Client(protocol); transport.Open(); Console.WriteLine("Client calls ....."); map.Add("blog", "http://www.javabloger.com"); client.testCase1(10, 21, "3"); client.testCase2(map); client.testCase3(); Blog blog = new Blog(); //blog.setContent("this is blog content".getBytes()); blog.CreatedTime = DateTime.Now.Ticks; blog.Id = "123456"; blog.IpAddress = "127.0.0.1"; blog.Topic = "this is blog topic"; blogs.Add(blog); client.testCase4(blogs); transport.Close(); //LogHelper.WriteLog(typeof(Program), "end process......"); Console.ReadKey(); }
//请求页面会访问的方法 public void OnGet() { IndexModel ob1 = new IndexModel(); Text1 = ob1.Click1(); // 下面代码与thrift相关 TTransport transport = new TSocket("localhost", 7911); TProtocol protocol = new TBinaryProtocol(transport); ThriftCase.Client client = new ThriftCase.Client(protocol); transport.Open(); Text2 = "Client calls ....."; //获取请求参数 string blog1; blog1 = Request.Query["id"];//获取get请求参数 if (blog1 == null) { blog1 = "blog"; } // 获取post请求参数Request.Form["Key"] map.Add(blog1, "http://www.javabloger.com"); int a = client.testCase1(10, 21, "3"); Text3 = a.ToString(); List <string> b = client.testCase2(map); Text4 = string.Join(",", b.ToArray()); client.testCase3(); Blog blog = new Blog(); blog.CreatedTime = DateTime.Now.Ticks; blog.Id = "123456"; blog.IpAddress = "127.0.0.1"; blog.Topic = "this is blog topic"; blogs.Add(blog); client.testCase4(blogs); transport.Close(); }