WAS中的主机WCF服务

时间:2011-12-05 17:45:15

标签: wcf wcf-binding was

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

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

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

该服务在默认网站,应用程序mywcfapp

下发布

我创建了一个BAT文件,在默认网站上的端口10000和mywcfapp上启用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

1 个答案:

答案 0 :(得分:3)

这可能会有所帮助:

转到IIS管理器。 右键单击该应用程序。 选择管理应用程序 - &gt;高级设置 在“行为”下,“启用协议”有一个字段。

确保它有net.tcp

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

http,net.tcp