【问题标题】:How do I set the Name of Net Named Pipes in WCF when hosted in ASP .NET?在 ASP .NET 中托管时,如何在 WCF 中设置网络命名管道的名称?
【发布时间】:2012-07-18 13:04:05
【问题描述】:

首先介绍一下背景:

我有一个 Web 服务器,它运行相同 ASP .NET 应用程序的 4 个实例,每个实例都在不同的文化中(在 web.config 中设置)。这些文化是英国人 (GBR)、澳大利亚人 (AUS)、爱尔兰人 (IRL) 和新西兰人 (NZL)。他们每个人都有一个网络方法“DoWork”,我想通过一个计划任务调用它。我有一个简单的 exe,它在四种文化中的每一种上调用此方法,简化代码:

Dim AUSclient As New AUSAutomated.AUSAutomatedClient()
AUSclient.DoWork
Dim GBRclient As New GBRAutomated.GBRAutomatedClient()
GBRclient.DoWork
Dim IRLclient As New IRLAutomated.IRLAutomatedClient()
IRLclient.DoWork
Dim NZLclient As New NZLAutomated.NZLAutomatedClient()
NZLclient.DoWork

在使用方法的任务中,app.config 如下所示:

        <endpoint address="net.pipe://localhost/Services/GBR/GBRAutomated.svc"
            binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IGBRAutomated"
            contract="GBRAutomated.IGBRAutomated" name="NetNamedPipeBinding_IGBRAutomated">
                </endpoint>

        <endpoint address="net.pipe://localhost/Services/IRL/IRLAutomated.svc"
 binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IIRLAutomated"
 contract="IRLAutomated.IIRLAutomated" name="NetNamedPipeBinding_IIRLAutomated">
                    </endpoint>

        <endpoint address="net.pipe://localhost/Services/NZL/NZLAutomated.svc"
            binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_INZLAutomated"
            contract="NZLAutomated.INZLAutomated" name="NetNamedPipeBinding_INZLAutomated">
                    </endpoint>

应用程序使用网络命名管道绑定通过 WCF 公开 Web 方法。每种文化在 web.config 中都有一个条目以指向正确的服务。例如爱尔兰是:

<service name="Web.IRLAutomated">
            <endpoint address="net.pipe://localhost/Services/IRL/IRLAutomated.svc" binding="netNamedPipeBinding" contract="Web.IIRLAutomated" />
        </service>

因此,每种文化的公开方法都有不同的合同和地址。

当任务运行时,它会调用澳大利亚方法 4 次。它似乎忽略了 web.configs 中的设置,并在第一个应用程序上使用正确的合同调用该方法。所以我的问题是:

如何为每种文化中的方法设置唯一的管道名称?

我尝试在绑定上设置 hostNameComparisonMode="Exact" 但这似乎没有任何区别。

【问题讨论】:

    标签: asp.net .net wcf iis named-pipes


    【解决方案1】:

    你不能

    经过一番搜索,我在 StackOverflow 上找到了一个类似的问题:

    controlling the name of a named pipe when hosting WCF net.pipe binding in IIS

    由于 2 年内没有人回答上述问题,我假设我想做的事情是不可能的。

    如果其他人正在为这类问题苦苦挣扎,我发现这篇博文对帮助我理解非常有帮助:

    http://blogs.charteris.com/blogs/chrisdi/archive/2008/05/19/exploring-the-wcf-named-pipe-binding-part-1.aspx

    我要将绑定更改为 http,这将解决我的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-21
      相关资源
      最近更新 更多