Click here to Skip to main content
15,881,092 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am creating a sample wcf service to test with one of my client.
I am getting result using SOAP, But REST is not working. It shows "Endpoint Not Found" error.
Here is my Web.Config for WCF service. Can anybody tells me what's wrong with this config file.

XML
<?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="web">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    <endpointBehaviors>
      <behavior name="restbehavior">
        <webHttp/>
      </behavior>
    </endpointBehaviors>
    </behaviors>
    
    
    <services>
      <service name ="s2HCloudService.Service1"
      behaviorConfiguration="web" >
 
        <endpoint name ="SOAPEndPoint"
        contract ="s2HCloudService.IService1"
        binding ="basicHttpBinding"
        address ="soap" />
        
        <endpoint name ="RESTEndPoint"
        contract ="s2HCloudService.IService1"
        binding ="webHttpBinding"
        address ="rest"
        behaviorConfiguration ="restbehavior"/>
 
        <endpoint contract="IMetadataExchange"
        binding="mexHttpBinding"
        address="mex" />
      </service>
    </services>
      
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
    -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>
Posted

1 solution

To make the service available over REST protocol the binding that needs to be used is the webHttpBinding. Also, we need to set the endpoint's behavior configuration and define the webHttp parameter in the endpointBehavior.
A Beginner's Tutorial on Creating WCF REST Services[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900