title: How do you consume a RESTful WCF service from an ASP project using a service reference?
body: <p>I am developing a RESTful WCF service which I then want to consume from a separate ASP.net Project.</p>
  
  <p><strong>Is it possible to use a service reference from within the ASP project to consume the service using REST or are all service references treated as SOAP?</strong></p>
  
  <p>There are plenty of examples of using a service library as a service reference or consuming a REST service using the WCF starter toolkit using HttpClient but I've not found one that does what I was hoping to do.</p>
  
  <p>Below is an extract from the ASP.Net web.config file that gets auto generated when the service reference is added. As you can see it mentions SOAP. </p>
  
  <pre><code>  &lt;system.serviceModel&gt;
    &lt;bindings&gt;
     &lt;customBinding&gt;
      &lt;binding name="WebHttpBinding_IDataCaptureService"&gt;
       &lt;textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
        messageVersion="Soap12" writeEncoding="utf-8"&gt;
        &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
         maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
       &lt;/textMessageEncoding&gt;
      &lt;/binding&gt;
     &lt;/customBinding&gt;
    &lt;/bindings&gt;
    &lt;client&gt;
     &lt;endpoint binding="customBinding" bindingConfiguration="WebHttpBinding_IDataCaptureService"
      contract="testRef.IDataCaptureService" name="WebHttpBinding_IDataCaptureService" /&gt;
    &lt;/client&gt;
   &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>Here is an extract from the service web.config</p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;services&gt;
          &lt;service behaviorConfiguration="DataCaptureService.Service1Behavior" name="eCRB.Service.DataCapture"&gt;
              &lt;endpoint address="" behaviorConfiguration="webBehaviour" binding="webHttpBinding" bindingConfiguration="" contract="eCRB.Service.IDataCaptureService"&gt;
              &lt;/endpoint&gt;
              &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/&gt;
          &lt;/service&gt;
      &lt;/services&gt;
      &lt;behaviors&gt;
          &lt;endpointBehaviors&gt;
              &lt;behavior name="webBehaviour"&gt;
                  &lt;webHttp/&gt;
              &lt;/behavior&gt;
          &lt;/endpointBehaviors&gt;
          &lt;serviceBehaviors&gt;
              &lt;behavior name="DataCaptureService.Service1Behavior"&gt;
                  &lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&gt;
                  &lt;serviceMetadata httpGetEnabled="true"/&gt;
                  &lt;!-- 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 --&gt;
                  &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
              &lt;/behavior&gt;
          &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;bindings&gt;
          &lt;webHttpBinding&gt;
              &lt;binding name="webBinding"&gt;
                  &lt;security mode="None"&gt;
                      &lt;transport clientCredentialType="None"/&gt;
                  &lt;/security&gt;
              &lt;/binding&gt;
          &lt;/webHttpBinding&gt;
      &lt;/bindings&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>