글

라벨이 Fiddler인 게시물 표시

WCF Create REST WebService and GET/POST Testing with Fiddler

이미지
  WCF로 간단하게 SOAP를 이용해서 Helloworld WebService 를 만들어봤습니다. 이번에는 REST 웹 서비스를 만들어보겠습니다. 1. WCF REST 웹서비스 생성 namespace WCFServiceTest { [ServiceContract] public interface IService1 { [OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json)] string GetTest(string strTemp); [OperationContract] [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)] string PostTest(string strTemp); } }  먼저 Helloworld WebService 를 그대로 만들고 생성된 IService1.cs의 내용을 위와같이 수정해줍니다. GetTest라는 GET 메소드와 PostTest라는 POST 메소드를 만들었습니다. ResponseFormat는 모두 JSON입니다. namespace WCFServiceTest { public class Service1 : IService1 { public string GetTest(string strTemp) { string response = strTemp + " success get"; return response; } public ...