title: WCF How to enable metadata?
body: <p>I am trying to get my svc file working under IIS. In my project, when I press F5 I got the svc working. So I know everything is okay, right? Except for IIS.</p>
  
  <p>I am working on a Windows XP Pro machine and in IIS I've added a virtual directory.</p>
  
  <p>Here's my code:
  IcarePlanActions (project: A)</p>
  
  <pre><code>namespace WcfServiceLibrary
  {
      [ServiceContract]
      public interface ICarePlanActions
      {
          [OperationContract]
          List&lt;string&gt; GetAllClients();
      }
  }
  </code></pre>
  
  <p>Client: (project: A)</p>
  
  <pre><code>namespace WcfServiceLibrary
  {
      public class Client : ICarePlanActions
      {
          public List&lt;string&gt; GetAllClients()
          {
              List&lt;string&gt; clients = new List&lt;string&gt;();
              clients.Add("Hendrik de Jong");
              clients.Add("Miep de Berg");
              clients.Add("Jaap Jongeneel");
              clients.Add("Joop Prakman");
              clients.Add("Pieter Schaakman");
  
              return clients;
  
          }
      }
  }
  </code></pre>
  
  <p>Web.config (project: B)</p>
  
  <pre><code>  &lt;configuration&gt;
      &lt;system.serviceModel&gt;
        &lt;services&gt;
          &lt;service behaviorConfiguration="CarePlanService.Service1Behavior"
            name="WcfServiceLibrary.Client"&gt;
            &lt;endpoint address="" binding="wsHttpBinding" contract="WcfServiceLibrary.ICarePlanActions"&gt;
              &lt;identity&gt;
                &lt;dns value="localhost" /&gt;
              &lt;/identity&gt;
            &lt;/endpoint&gt;
            &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
          &lt;/service&gt;
        &lt;/services&gt;
        &lt;behaviors&gt;
          &lt;serviceBehaviors&gt;
            &lt;behavior name="CarePlanService.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;/system.serviceModel&gt;
    &lt;/configuration&gt;
  </code></pre>
  
  <p>CarePlan.svc</p>
  
  <pre><code>&lt;%@ ServiceHost Language="C#" Debug="true" Service="WcfServiceLibrary.Client" %&gt;
  </code></pre>
  
  <p>When I run this service (which is on IIS) with wfctestclient I get this error </p>
  
  <blockquote>
    <p>Error: Cannot obtain Metadata from
    <a href="http://localhost/CarePlanService/CarePlan.svc" rel="noreferrer">http://localhost/CarePlanService/CarePlan.svc</a>
    If this is a Windows (R) Communication
    Foundation service to which you have
    access,  please check that you have
    enabled metadata publishing at the
    specified address.</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>I didn't get the service working under IIS. First I manually create a virtual directory and pointed to the directiry where the svc is located. This didn't work. I don't know why.</p>
  
  <p>Then I went to Visual Studio and changed the server setting (Right mouse on the project, properties, tab Web, click <code>Use local IIS Web Server</code> and click <code>Create Virtual Directory</code>. When I did this, it worked under IIS with the code above.</p>