Client

  1. http://localhost:8000/Service1.svc/Rest/add/9/3

  2. GET http://localhost:8000/Service1.svc/Rest/add/9/3 HTTP/1.1
    Host: localhost:8000
    Connection: keep-alive
    Upgrade-Insecure-Requests: 1
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Whale/1.4.64.6 Safari/537.36
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8
    Accept-Encoding: gzip, deflate, br
    Accept-Language: ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7

  1. WebClient RESTProxy = new WebClient();
    byte[] data = RESTProxy.DownloadData(new Uri("http://localhost:8000/Service1.svc/Rest/add/7/2"));
    Stream stream = new MemoryStream(data);
    DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(string));
    string result = obj.ReadObject(stream).ToString();
    Console.WriteLine(result);
  1. this.Text = "";
    ChannelFactory<IService2> factory = new ChannelFactory<IService2>();
    // Address
    string address = "http://localhost:8000/Service1.svc/rest";
    factory.Endpoint.Address = new EndpointAddress(address);
    // Binding : WEB 사용
    factory.Endpoint.Binding = new WebHttpBinding();
    // Contract 설정
    factory.Endpoint.Contract.ContractType = typeof(IService2);
    // Channel Factory 만들기
    factory.Endpoint.Behaviors.Add(new WebHttpBehavior());
    IService2 channel = factory.CreateChannel();
    // Server 쪽 함수 호출
    var result = channel.AddRest("9", "3");
    // Close Channel
    ((ICommunicationObject)channel).Close();
    this.Text = result.ToString();