title: ProtocolException Unhandled/(405) Method not allowed with WCF; Bindings and Endpoints look right though
body: <p>I'm just learning how to use WCF and I am trying to write a little HelloWorld program from scratch (both the host and client sides).  I've been getting a <code>ProtocolException Unhandled</code> whenever my client tries to use the service, and I can't figure out why.  I'm hosting the service using IIS.</p>
  
  <p>Regarding the way I have things set up: I'm doing my best to separate the client, proxy, host, service, and contract as detailed in this <a href="http://www.dnrtv.com/default.aspx?showNum=122" rel="noreferrer">video</a> and as outlined in this <a href="http://www.codeproject.com/Articles/114139/WCF-The-Right-Way-A-Quick-Reference-Guide" rel="noreferrer">article</a>.  Basically I've got different projects within the solution for each of those.</p>
  
  <p>Here are some different files showing what I'm talking about:</p>
  
  <h2>Service</h2>
  
  <pre><code>namespace HelloWorld
  {
    public class HelloWorldService : IHelloWorldService
    {
      public String GetMessage(String name)
      {
          return "Hello World from " + name + "!";
      }
    }
  }
  </code></pre>
  
  <h2>Contract</h2>
  
  <pre><code>namespace HelloWorld
  {
    [ServiceContract]
    public interface IHelloWorldService
    {
        [OperationContract]
        String GetMessage(String name);
    }
  }
  </code></pre>
  
  <h2>Proxy</h2>
  
  <pre><code>namespace HelloWorld
  {
    public class Proxy : ClientBase&lt;IHelloWorldService&gt;, IHelloWorldService
    {
      #region IHelloWorldService Members
  
      public String GetMessage(String name)
      {
          return Channel.GetMessage(name);
      }
  
      #endregion
  
    }
  </code></pre>
  
  <p>}</p>
  
  <h2>Client</h2>
  
  <pre><code>namespace Client
  {
    public partial class Form1 : Form
    {
      public Form1()
      {
          InitializeComponent();
      }
  
      private void button1_Click_1(object sender, EventArgs e)
      {
          Proxy proxy = new Proxy();
          MessageBox.Show(proxy.GetMessage(textBox1.Text));
      }
    }
  </code></pre>
  
  <p>}</p>
  
  <p>The client is just a form with a textbox and a button, and it tries to execute GetMessage() using whatever is in the textbox as a parameter.  There is another class that actually creates an instance of the form.</p>
  
  <p>Here's my web.config for the website:</p>
  
  <h2>Web.config</h2>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.0" /&gt;
    &lt;/system.web&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
    &lt;/system.webServer&gt;
    &lt;system.serviceModel&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="MyServiceTypeBehaviors"&gt;
            &lt;serviceMetadata httpGetEnabled="true" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
          &lt;/behavior&gt; 
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;services&gt;
        &lt;service name="HelloWorld.HelloWorldService" behaviorConfiguration="MyServiceTypeBehaviors"&gt;
          &lt;endpoint address="http://localhost:8002/" binding="basicHttpBinding" contract="HelloWorld.IHelloWorldService"/&gt;
          &lt;endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/&gt;
        &lt;/service&gt;
      &lt;/services&gt;
    &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>And here's my app.config that goes with the client:</p>
  
  <h2>app.config</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;system.serviceModel&gt;
      &lt;client&gt;
        &lt;endpoint address="http://localhost:8002/" binding="basicHttpBinding" contract="HelloWorld.IHelloWorldService" /&gt;
      &lt;/client&gt;
    &lt;/system.serviceModel&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>My svc file is very short, just:</p>
  
  <h2>HelloWorldService.svc</h2>
  
  <pre><code>&lt;%@ServiceHost Service="HelloWorld.HelloWorldService"%&gt;
  </code></pre>
  
  <p>I know the service is running, because when I navigate to <code>http://localhost:8002/HelloWorldService.svc</code> in my browser I get the screen that says </p>
  
  <blockquote>
    <p>You have created a service.</p>
    
    <p>To test this service, you will need to create a client and use it to
    call the service.</p>
  </blockquote>
  
  <p>So here's where the snag happens: the service is running using IIS, I start an instance of the client, the window with the textbox and the button come up, I type in some letters, hit the button, and then the program crashes and I get the <code>ProtocolException Unhandled, (405) Method not allowed.</code>  The error happens on this line of the Proxy class:</p>
  
  <pre><code>return Channel.GetMessage(name);
  </code></pre>
  
  <p>I've been trying to figure this out for hours and hours, and I haven't made much progress.  If someone could at least point me in the right direction, I would be very appreciative.</p>
  
  <p>Last thing: I want to write the client and proxy from scratch, without using svcutil.exe.</p>