I'm struggling to get a basic WCF service working over net.tcp protocol. I've created a new WCF project with VS2017 and have not changed the template code at all. Having set the bindings in the web.config
to use netTcpBinding
and mexTcpBinding
respectively, I'm getting the following error:
Error: Cannot obtain Metadata from net.tcp://localhost/WcfSecurityTest/Service1.svc 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. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: net.tcp://localhost/WcfSecurityTest/Service1.svc Metadata contains a reference that cannot be resolved: 'net.tcp://localhost/WcfSecurityTest/Service1.svc'. The message could not be dispatched because the service at the endpoint address 'net.tcp://localhost/WcfSecurityTest/Service1.svc' is unavailable for the protocol of the address.
Boilerplate service code:
namespace WcfSecurityTest.Service
{
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);
}
public class Service1 : IService1
{
public string GetData(int value) {...}
public CompositeType GetDataUsingDataContract(CompositeType composite) {...}
}
}
Service1.svc:
<%@ ServiceHost Language="C#"
Debug="true"
Service="WcfSecurityTest.Service.Service1"
CodeBehind="Service1.svc.cs" %>
web.config:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="behaviourConfig">
<serviceMetadata />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="netTcpBindingConfig">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="WcfSecurityTest.Service.Service1"
behaviorConfiguration="behaviourConfig">
<endpoint address=""
contract="WcfSecurityTest.Service.IService1"
binding="netTcpBinding"
bindingConfiguration="netTcpBindingConfig" />
<endpoint address="mex"
contract="IMetadataExchange"
binding="mexTcpBinding" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:808/WcfSecurityTest/Service1.svc" />
</baseAddresses>
</host>
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
I'm testing using WCF Test Client, which gives the error when I try to add the endpoint: net.tcp://localhost:808/WcfSecurityTest/Service1.svc
.
net.tcp is enabled within IIS on port 808 and non-HTTP activation is installed.
Obviously I'm doing something wrong here, but every related question on SO and web article I can find suggests this should work.
TCP 0.0.0.0:808 0.0.0.0:0 LISTENING
- definitely listening on port 808 – Chris Pickford