locked
How to configure a wcf rest service in the web.config file RRS feed

  • Question

  • User-1548746331 posted

    I need to know after which tag in web.config file i need to put the following blocks of code of a wcf rest 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>

    I am new to WCF concept.

    Thanks in advance

    Regards,

    RAJAN CRP

    Sunday, July 14, 2013 6:24 PM

Answers

  • User-1000095884 posted

    Hi,

    Below is an example of the web.config file of a Rest service, hope this helps.

    <configuration>
      <system.serviceModel>
        <services>
          <service
              name="Microsoft.ServiceModel.Samples.BasicWebProgramming.Service"
              behaviorConfiguration="MyServiceBehavior">
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8000/"/>
              </baseAddresses>
            </host>
            <endpoint address="" 
                      binding="webHttpBinding"
                      contract="Microsoft.ServiceModel.Samples.BasicWebProgramming.IService" />
    
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="MyServiceBehavior">
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    </configuration>
    

    #How to: Create a Basic WCF REST Service

    http://msdn.microsoft.com/en-us/library/vstudio/bb412178(v=vs.90).aspx

    #Create RESTful WCF Service API: Step By Step Guide

    http://www.codeproject.com/Articles/105273/Create-RESTful-WCF-Service-API-Step-By-Step-Guide

    Best Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 17, 2013 10:30 AM