1

我需要一些关于在 WAS 中托管 WCF 服务的帮助。我在 IIS 中托管了该服务,并通过 basicHttp 和 wsHttp 绑定进行访问。但是,当我尝试在 WAS 中托管它并通过 tcp/ip 访问时,我似乎错过了一些东西。

我需要将其配置为通过端口 10000 上的 tcp 访问。

我在 Windows 功能中为非 HTTP 启用了 WCF 激活

该服务在默认网站应用程序 mywcfapp 下发布

我创建了一个 BAT 文件以在默认网站和 mywcfapp 的端口 10000 上启用 net.tcp 绑定,如下所示:

%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

web.config 是

<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>

但是,我似乎无法访问该服务。

当我尝试使用带有 uri 的 WcfTestClient 访问服务时

net.tcp://localhost:10000/mywcfapp/mywcfapp.svc/mex

我收到以下错误

<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>

如果我尝试使用 url 连接(不指定端口)

net.tcp://localhost/OneTest.Service/OneTest.Service.svc/mex

我收到错误(仅保留重要部分)

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
4

1 回答 1

3

这可能会有所帮助:

转到 IIS 管理器。右键单击应用程序。选择 Manage Applications -> Advanced settings 在 Behavior 下,有一个 Enabled Protocols 字段。

确保它有net.tcp

如果只是有http,请将其更改为

http,net.tcp
于 2011-12-05T19:16:02.893 回答