Search code examples
wcfnettcpbindingendpointwebhttpbinding

WCF unable to find netTcpBinding


I am trying to create a WCF service that is accessible through both webHttpBinding and netTcpBinding. I have been successful in getting the webHttpBinding to be accessible through a Java client and now I'm working on trying to get the netTcpBinding working.

I have set up the configuration like this;

<system.serviceModel>
  <behaviors>
    <endpointBehaviors>
      <behavior name="httpBehavior">
        <webHttp/>
      </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
      <behavior name="">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  <services>
    <service name="MR_Jukebox_Service.JukeboxService">
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:8732/Design_Time_Addresses/MR_Jukebox_Service/"/>
          <add baseAddress="net.tcp://localhost:8523/Design_Time_Addresses/MR_Jukebox_Service/net/"/>
        </baseAddresses>
      </host>
      <endpoint address=""
                behaviorConfiguration="httpBehavior"
                binding="webHttpBinding"
                contract="MR_Jukebox_Service.IJukeboxService" />
      <endpoint address="mex"
                binding="mexHttpBinding"
                contract="MR_Jukebox_Service.IJukeboxService" />
      <endpoint address="net.tcp://localhost:8523/Design_Time_Addresses/MR_Jukebox_Service/net"
                binding="netTcpBinding"
                bindingConfiguration=""
                contract="MR_Jukebox_Service.IJukeboxService" />
    </service>
  </services>
</system.serviceModel>

In the same solution, I have a test application that I wish to connect to the netTcpBinding, I've right clicked on "Service References" and chosen "Add Service Reference...". When I click on "Discover" it finds the service although says;

There was an error downloading 'http://localhost:8732/Design_Time_Addresses/MR_Jukebox_Service'. The request failed with HTTP status 404: Not Found. Metadata contains a reference that cannot be resolved: 'http://localhost:8732/Design_Time_Addresses/MR_Jukebox_Service'. There was no endpoint listening at http://localhost:8732/Design_Time_Addresses/MR_Jukebox_Service that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. The remote server returned an error: (404) Not Found. If the service is defined in the current solution, try building the solution and adding the service reference again.

But I am also unable to see the netTcpBinding in order for me to create a service reference to it.

I was wondering whether anyone can see what I am doing wrong as its probably something rather simple, but due to my lack of experience with WCF haven't noticed.

Thanks for any help in advance.


Solution

  • Try changing your mex endpoint to this:

    <endpoint address="mex"
              binding="mexHttpBinding"
              contract="IMetadataExchange" />
    

    You were using your service's contract for the mex endpoint, which I don't believe will work.

    You can set up a similar one for the NetTcpBinding:

    <endpoint address="net.tcp://localhost:8523/Design_Time_Addresses/MR_Jukebox_Service/net/mex"
              binding="mexTcpBinding"
              contract="IMetadataExchange" />