title: Failed to lookup a channel to receive an incoming message. Either the endpoint or the SOAP action was not found
body: <p>I am very new to WCF services. I have 1 WCF service created with NetHttpBinding and I have a Form application as a client of this service and I am trying to make a simple example of 2 way communication using this.</p>
  
  <p>Here is my </p>
  
  <p>ITestService.cs</p>
  
  <pre><code>namespace TestService
  {
      [ServiceContract(CallbackContract = typeof(ITestServiceCallback), SessionMode = SessionMode.Required)]
      public interface ITestService
      {
          [OperationContract]
          void DoWork();
      }
  
      [ServiceContract]
      public interface ITestServiceCallback
      {
          [OperationContract(IsOneWay = true)]
          void test(string hello);
      }
  }
  </code></pre>
  
  <p>TestService.svc.cs:</p>
  
  <pre><code>namespace TestService
  {
      [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]
      public class TestService : ITestService
      {
          public void DoWork()
          {
              Debug.WriteLine("Inside Do Work");
              ITestServiceCallback callback = OperationContext.Current.
                  GetCallbackChannel&lt;ITestServiceCallback&gt;();
  
              Debug.WriteLine(OperationContext.Current.Channel.RemoteAddress.ToString());
  
              callback.test("Hello by WebSockets");
          }
      }
  }
  </code></pre>
  
  <p>web.config: </p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;appSettings&gt;
      &lt;add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /&gt;
    &lt;/appSettings&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.5" /&gt;
      &lt;httpRuntime targetFramework="4.5"/&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;netHttpBinding&gt;
          &lt;binding name="TextOverWebSockets" messageEncoding="Text"/&gt;
        &lt;/netHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;services&gt;
        &lt;service name="TestService.TestService"
                 behaviorConfiguration="TestServiceBehavior"&gt;
          &lt;endpoint address=""
                    binding="netHttpBinding"
                    bindingConfiguration="TextOverWebSockets"
                    contract="TestService.ITestService" &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="TestServiceBehavior"&gt;
            &lt;!-- To avoid disclosing metadata information, set the values below to false before deployment --&gt;
            &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="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;protocolMapping&gt;
        &lt;add binding="netHttpBinding" scheme="http" /&gt;
        &lt;add binding="netHttpsBinding" scheme="https" /&gt;
      &lt;/protocolMapping&gt;
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" /&gt;
    &lt;/system.serviceModel&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
      &lt;directoryBrowse enabled="true"/&gt;
    &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Here is my form application details : </p>
  
  <p>Form1.cs:</p>
  
  <pre><code>public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          TestServiceClient Client = new TestServiceClient(new InstanceContext(new CallbackHandler()));
          Debug.WriteLine(Client.Endpoint.Address.ToString());
          Debug.WriteLine("asd Startttttt");
          Client.Open();
          Client.DoWork();
      }
  
      public class CallbackHandler : ITestServiceCallback
      {
          public void test(string hello)
          {
              Debug.WriteLine("asd Finallllly");
          }
      }
  }
  </code></pre>
  
  <p>App.config :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;startup&gt; 
          &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /&gt;
      &lt;/startup&gt;
      &lt;system.serviceModel&gt;
          &lt;bindings&gt;
              &lt;netHttpBinding&gt;
                  &lt;binding name="NetHttpBinding_ITestService" messageEncoding="Text"&gt;
                      &lt;webSocketSettings transportUsage="Always" /&gt;
                  &lt;/binding&gt;
              &lt;/netHttpBinding&gt;
          &lt;/bindings&gt;
          &lt;client&gt;
              &lt;endpoint address="ws://localhost:64375/TestService.svc" binding="netHttpBinding"
                  bindingConfiguration="NetHttpBinding_ITestService" contract="TestService.ITestService"
                  name="NetHttpBinding_ITestService"&gt;
              &lt;/endpoint&gt;
          &lt;/client&gt;
      &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I tried debugging it and I could see that My call from Client to WCF service succeeds cause I could see "Inside Do Work" also. But I was not able to make the call back to the Client at </p>
  
  <p>"callback.test("Hello by WebSockets");" , I had enabled the trace view logging in web.config and I could see following error in traceView : "Failed to lookup a channel to receive an incoming message. Either the endpoint or the SOAP action was not found"</p>
  
  <p>Could you please let me know what could I be missing. Any help is appreciated. </p>
  
  <p>Thank you in Advance,</p>
  
  <p>Aalap..</p>