WCF 4.0 REST POX Service with Help Page

Representational State Transfer (REST) support was included in WCF 3.5. In WCF 4.0, this feature has been enhanced with Help page support. This facility was added as WCF REST allows direct call to OperationContracts, using HTTP protocol by the client application. Now the problem is if the WCF service has several OperationContracts, then how does the client application know and distinguish between the urls for method calls? WCF 4.0 REST Help page enhancements provides this feature so that when the WCF service is published on the Web Server, the client application can decide which method to call using the help page and can also view the expected response message generated.

Step 1: Open VS2010 and create a WCF Service application, name it as ‘WCF_REST_POX_Service_Help’. Rename IService1.cs to IService.cs and Service1.svc to Service.svc. In the IService.Svc, add ServiceContract , OperationContract and DataContract, as shown below:


Step 2: In the web.config file, define the EndPointBehavior and define the HelpEnabled attribute for the <webHttp> as below:


Step 3: Right-Click on Service.Svc and select ‘View In Browser’, the following message will be displayed:


Click on the Service help Page and you will see the following

WCF Service Help Page

Click on the First Url and you can see an example of the response XML body. Very useful!

WCF Response Body

About The Author

Mahesh Sabnis is a Microsoft MVP having over 18 years of experience in IT education and development. He is a Microsoft Certified Trainer (MCT) since 2005 and has conducted various Corporate Training programs for .NET Technologies (all versions). He also blogs regularly at DotNetCurry.com. Follow him on twitter @maheshdotnet


Sushi Boi said...

Any idea how you would make the content of [WebHelp(Comment = "...")] appear?... or better still make the whole feed appear as RSS as described in the WCF Rest Whitepaper.

Help said...

In that Employee class
I want Child columns for EmpName is LastName,MiddleName

How can i do?