Search code examples
wcfwcf-rest

Got 404 when consume WCF in REST mode


I used this url in browser, and I expect to see an XML, I only got 404 not found error. Can you help please?

--http://SomeIP:65001/WCFPilot/Service1/REST/GetData

web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
        <authentication mode="Windows" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WCFPilot.Service1">
        <endpoint address="REST" binding="webHttpBinding" contract="WCFPilot.IService1" behaviorConfiguration="REST">          
        </endpoint>

      </service>

    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="REST">
          <webHttp faultExceptionEnabled="true" helpEnabled="true" />          
        </behavior>

      </endpointBehaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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="true" />

        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>

</configuration>

Service Contract

 [ServiceContract]
    public interface IService1
    {

        [OperationContract]
        [WebGet(ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "GetData")]
        string GetData();


    }

Thanks


Solution

  • The URL for the service should be

    http://SomeIP:65001/Service1.svc/REST/GetData