Host WCF service in WAS
-
28-10-2019 - |
Question
I need some help with hosting a WCF service in WAS. I hosted the service ok in IIS and accessed over basicHttp and wsHttp binding. But it seems I miss something when trying to host it in WAS and access over tcp/ip.
I need to configure it for access over tcp on port 10000.
I enabled WCF activation for Non-HTTP in Windows Features
The service is published under default web site, application mywcfapp
I created a BAT file to enable net.tcp binding on port 10000 on default web site and mywcfapp as below:
%windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.tcp',bindingInformation='10000:*']
%windir%\system32\inetsrv\appcmd.exe set app "Default Web Site/mywcfapp" /enabledProtocols:http,net.tcp
The web.config is
<services>
<service name="MyWcfService">
<clear />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"
listenUriMode="Explicit" />
<endpoint address="net.tcp://localhost:10000/mywcfapp/mywcfapp.svc"
binding="netTcpBinding" bindingConfiguration="PortSharingBinding" contract="MyApp.IService" />
<endpoint address="net.tcp://localhost:10000/mywcfapp/mywcfapp.svc"
binding="netTcpBinding" bindingConfiguration="PortSharingBinding" contract="MyApp.IService" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="PortSharingBinding" portSharingEnabled="true">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
However, it seems I cannot access the service.
When I try to access the service with WcfTestClient with the uri
net.tcp://localhost:10000/mywcfapp/mywcfapp.svc/mex
I get the following error
<Fault xmlns="http://www.w3.org/2003/05/soap-envelope">
<Code>
<Value>Sender</Value>
<Subcode><Value xmlns:a="http://www.w3.org/2005/08/addressing">a:DestinationUnreachable</Value>
</Subcode>
</Code>
<Reason><Text xml:lang="ro-RO">
The message with To 'net.tcp://localhost:10000/mywcfapp/mywcfapp.svc/mex'
cannot be processed at the receiver, due to an AddressFilter mismatch
at the EndpointDispatcher.
Check that the sender and receiver's EndpointAddresses agree.
</Text></Reason>
</Fault>
If I try to connect with url (w/o specifying port)
net.tcp://localhost/OneTest.Service/OneTest.Service.svc/mex
I get the error (kept only significant part)
Could not connect to net.tcp://localhost/mywcfapp/mywcfapp.svc/mex.
The connection attempt lasted for a time span of 00:00:02.0041146.
TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:808.
No connection could be made because the target machine actively refused it 127.0.0.1:808
Solution
This might help:
Go to IIS Manager. Right click on the app. Choose Manage Applications -> Advanced settings Under Behavior, there is a field for Enabled Protocols.
Make sure it has net.tcp
If it just has http
, change it to
http,net.tcp