示例#1
0
        public static string AddWithParameter(NumberService obj)
        {
            using (HttpResponseMessage  response = new HttpClient().Post(uri,HttpContentExtensions.CreateDataContract(obj)))
            {

                int res = response.Content.ReadAsDataContract<int>();
                return res.ToString();
             }
        }
示例#2
0
 static void Main(string[] args)
 {
     uri = "http://localhost:3602/RestService.svc/";
     // Calling without parameter
     Console.WriteLine(AddWithoutParameter());
     Console.Read();
     //Calling with parameter
     NumberService obj = new NumberService() { Number1 = 7, Number2 = 2 };
     Console.WriteLine(AddWithParameter(obj));
     Console.Read();
 }
示例#3
0
 public int Add(NumberService n1)
 {
     res = Convert.ToInt32(n1.Number1) + Convert.ToInt32(n1.Number2);
     return res;
 }