[How To]:Converting a WCF Service to REST Enabled – Part 1

Below are the steps to convert make the service REST enabled :

Step 1 :

In IserviceRequestManager.cs, replace the [Operation Contract] with [WebGet] and add reference “System.ServiceModel.Web”

Step 2 :

In ServiceRequestManager.svc markup, add the attribute “Factory=”System.ServiceModel.Activation.WebServiceHostFactory”.

As shown below :

<%@
ServiceHost
Language=”C#”
Debug=”true”
Service=”XYZ.ServiceManagement.Services.ServiceRequestManager”
CodeBehind=”ServiceRequestManager.svc.cs”
Factory=”System.ServiceModel.Activation.WebServiceHostFactory”
%>

Step 3 :

In web.config within the <system.ServiceModel> add the following configuration :

“<standardEndpoints>
<webHttpEndpoint>
<!– the “” standard endpoint is used by WebServiceHost for auto creating a web endpoint. –>
<standardEndpoint name=”” helpEnabled=”true”/>
</webHttpEndpoint>
</standardEndpoints>”

As shown below :

Happy Exploring J