We will understand steps with an example of maintaining players list
Steps to create Wcf REST service
5. Service config settings
Steps to create Wcf REST service
- It requires webHttpBinding.
- It requires <webHttp /> tag inside behavior tag.
- Create wcf service application
- Create methods for add, update, delete, get playerPlayer GetPlayer(string id);void AddPlayer(string name);void UpdatePlayer(string id, string name);void DeletePlayer(string id);List<Player> GetPlayers();
- Mark created methods with below given methods
1. WebGet
2. WebInvoke - Assign values of parameters in WebGet and WebInvoke as required
- UriTemplate : Set url format to access the method
- GetPlayer/{id}
- UpdatePlayer/{id}/{name}
- Method
- POST : To submit data to process
- PUT : To update resource
- DELETE : To delete resource
- RequestFormat
- RequestFormat= WebMessageFormat.Xml
- RequestFormat= WebMessageFormat.Json
- ResponseFormat
- ResponseFormat= WebMessageFormat.Xml
- ResponseFormat= WebMessageFormat.Json
- BodyStyle
- Bare
- Wrapped
- WrappedRequest
- WrappedRespons
5. Service config settings
Note : In below given config settings 4th & 5th points are not compulsory.


No comments:
Post a Comment