Where in the web.config
should the following blocks of code go for a WCF RESTful service?
<endpoint address="" binding="webHttpBinding"contract="Wcf_Test.IMyService"
behaviorConfiguration="httpEndpointBehavour">
<identity>
<dns value="localhost"/>
<Identity>
</endpoint>
and
<behaviors>
<serviceBehaviors>
<behavior name="httpBehaviour"> <serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
and
<endpointBehaviors>
<behavior name="httpEndpointBehavour">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
In order to configure a WCF REST service, you need a few things in your web.config file
1) Declare your service and its endpoint
Service name will be [project name].[service name] Behavior configuration will be same name as the behavior you declare in the next step Binding must be webHttpBinding because you want it as REST. If you want SOAP, you declare as basicHttpBinding Contract is the [project name].[interface name] Behavior configuration in the endpoint will be the name you declare in next step
2) Declare the service behavior (usually default)
Behavior name can be anything, but it will be used to match BehaviorConfiguration you declared in step 1 Leave the rest alone
3) Declare your endpoint behavior
Behavior name can be anything, but it will be used to match the behaviorConfiguration in endpoint.
In the end, this is what the web.config should look like for a simple REST service:
for the rest type using WCFservice
Web config changes.
Interface: we have to use WebGet for httpGet / WebInvoke for HttpPost & Put & Delete.
Ref : https://www.codeproject.com/Articles/571813/A-Beginners-Tutorial-on-Creating-WCF-REST-Services