title: Consolidating redundant declarations for a REST-full WCF service
body: <p>I'm using .NET 4 WCF to expose the following REST-full webservice  </p>
  
  <pre><code>  [OperationContract]
    [WebGet]
    void Test();
  </code></pre>
  
  <p>Since this is a developer oriented program, I want to support REST-full HTTP developers and also developers that like to use a WSDL.  My approach is to declare the service <em>twice</em> to expose both a traditional WSDL and also a REST endpoint:</p>
  
  <p>Web.config</p>
  
  <pre><code>&lt;serviceHostingEnvironment  aspNetCompatibilityEnabled="True" multipleSiteBindingsEnabled="true" &gt;
    &lt;serviceActivations &gt;
      &lt;add relativeAddress ="~/KeyService.svc" service="SecretDistroMVC3.Services.KeyService3"/&gt;
    &lt;/serviceActivations&gt;
  &lt;/serviceHostingEnvironment&gt;
  </code></pre>
  
  <p>Global.asax</p>
  
  <pre><code>   void Application_Start(object sender, EventArgs e)
          { 
              //  The following enables the WCF REST endpoint
              //ASP.NET routing integration feature requires ASP.NET compatibility. Please see 
              // 'http://msdn.microsoft.com/en-us/library/ms731336.aspx
              RouteTable.Routes.Add(new ServiceRoute("KeyService3", new WebServiceHostFactory(), typeof(KeyService3)));
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>Since I don't like to have the service declared in two locations, how do I either configure both endpoints in config, or both endpoints in <code>Application_Start</code>?</p>
  
  <p>Examples</p>
  
  <p><a href="https://www.agent7.net/Services/KeyService3/help" rel="nofollow">WCF's REST Help Endpoint</a></p>
  
  <p><a href="https://www.agent7.net/Services/KeyService3.svc?wsdl" rel="nofollow">WCF's sample WSDL</a></p>