1

我正在使用 CSLA.NET。它与 wsHttpBinding 配合得非常好。现在,我有自己的 Windows 服务并搜索解决方案,我可以将此 Windows 服务用作 CSLA 服务器并使用 nettcpbinding。有人可以给我一个提示如何进行吗?也许有人有一个样本我怎么能做到这一点。

谢谢!

最好的问候,托马斯

4

1 回答 1

1

基本上,你需要做两件事:

  • 更改您的服务器端配置以包含一个带有 netTcpBinding 的端点(这可以是现有 wsHttpBinding 端点的补充 - 没问题)

  • 将 netTcpBinding 添加到客户端的配置文件中,并在连接时选择该端点

您的服务器端配置中应该有这样的内容:

<services> 
   <service name="YourService">
      <endpoint name="something"
                address=""
                binding="wsHttpBinding"
                contract="IYourService" />
   </service>
</services>

只需为 netTcpBinding 添加一个端点:

<services> 
   <service name="YourService">
      <endpoint name="something"
                address=""
                binding="wsHttpBinding"
                contract="IYourService" />
      <endpoint name="something"
                address="net.tcp://YourServer:7171/YourService"
                binding="netTcpBinding"
                contract="IYourService" />
   </service>
</services>

现在,如果您在 IIS 中托管,您可能会遇到一些问题 - 您需要配置 IIS7(Win2008 或 Win2008R2 服务器),而在 IIS6 中,您将无法在 IIS6 中托管您的 netTcp 服务 :-(

客户端也一样 - 为 netTcp 添加第二个端点:

<client>
    <endpoint name="something"
              address="http://YourServer/SomeVirtDir/YourServiceFile.svc"
              binding="wsHttpBinding"
              contract="IYourService" />
    <endpoint name="netTcpEndpoint"
              address="net.tcp://YourServer:7171/YourService"
              binding="netTcpBinding"
              contract="IYourService" />
</client>

现在,当您在代码中创建端点时,请使用命名端点:

YourServiceClient client = new YourServiceClient("netTcpEndpoint");

这应该就是全部了(除非 CSLA 需要一些我不知道的额外内容……我知道“普通的”WCF)

于 2010-04-16T18:40:22.547 回答