在IIS中托管WCF net.pipe绑定时控制命名管道的名称 [英] controlling the name of a named pipe when hosting WCF net.pipe binding in IIS

查看:101
本文介绍了在IIS中托管WCF net.pipe绑定时控制命名管道的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过http和net.pipe访问服务。它托管在IIS 7(Server 2008)中。我可能正在为同一台机器上的几个客户托管此服务的不同实例,因此HTTP设置为虚拟主机名等。这一切都正常。

I have a service accessible via http and net.pipe. It is being hosted in IIS 7 (Server 2008). I may be hosting different instances of this service for several customers on the same machine and hence the HTTP is setup with virtual hostnames etc. This is all working fine.

我想我会做类似的网名命名管道绑定 - 在命名管道基地址中使用某种形式的
客户'virtualhostname',因此允许我
访问具有不同net.pipe骨灰盒的不同客户实例(我意识到
net.pipe名称是URN不是URL,所以它们基本上是任意的但是
我以为我会遵循类似于HTTP地址的模式)。

I thought I would do similar for the net named pipe binding - using some form of the customers 'virtualhostname' in the named pipe base address, therefore allowing me to access the different customer instances with different net.pipe urns (I realize the net.pipe names are URN's not URL's so they can be essentially arbitrary but I thought I would follow a similar pattern to the HTTP addresses).

这是我的web.config

Here is my web.config

<service name="Administration" behaviorConfiguration="AdministrationBehavior">
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="normalWsBinding" contract="IAdministration" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <endpoint address="" binding="netNamedPipeBinding" bindingConfiguration="normalNetNamedPipeBinding" contract="IAdministration" />
    <endpoint address="mex" binding="mexNamedPipeBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://virtualhostname.com/service" />
        <add baseAddress="net.pipe://virtualhostname.com/administration/service" />
      </baseAddresses>
    </host>
</service>

但是,当访问服务的WSDL时,
- 网络的基地址。管道好像被IIS忽略了
。相反,我得到了机器的真实主机名,以及
net.pipe地址URN,它似乎完全由IIS格式化。

However, when accessing the WSDL for the service - the base address for the net.pipe seems to be ignored by IIS. Instead I get the real hostname of the machine, and a net.pipe address URN that seems to have been formatted entirely by IIS.

<wsdl:port name="NetNamedPipeBinding_IAdministration" binding="tns:NetNamedPipeBinding_IAdministration">
   <soap12:address location="net.pipe://realhostname/service/Administration.svc"/>
   <wsa10:EndpointReference>
       <wsa10:Address>net.pipe://realhostname.com/service/Administration.svc</wsa10:Address>
       <Identity>
          <Spn>host/realhostname.com</Spn>
       </Identity>
   </wsa10:EndpointReference>
</wsdl:port>

由于无法控制net.pipe名称的形成方式,我将无法区分
在机器上的多个客户服务实例之间。有没有人知道如何在IIS环境中控制网络命名管道绑定URN

With no control over the way net.pipe names are formed, I will not be able to discriminate between the multiple customer service instances on the machine. Does anyone have any clue as to how the net named pipe binding URN can be controlled within the IIS environment?

(我做了很多独立网络。在测试期间管道托管(即新的ServiceHost())
所以我知道我的net.pipe绑定在IIS之外工作,并允许控制
超过使用的确切命名管道URN)

(I do a lot of standalone net.pipe hosting during testing (i.e. new ServiceHost()) so I know that my net.pipe bindings do work outside of IIS, and do allow control over the exact named pipe URN used)

如果无法在IIS中控制名称 - 是否有人有
托管和访问同一
机器上的多个单独的net.pipe服务实例的任何经验?

If the names can't be controlled within IIS - does anyone have any experience with hosting and accessing multiple separate net.pipe service instances on the same machine?

推荐答案

这是一个老问题,但我想我会添加我的答案,因为我也需要一个答案(也许还有其他人也需要它。)

This is an old question, but I figured I'd add my answer since I also needed an answer for this (and maybe there are others out there who need it too).

IIS托管的WCF服务的基地址由IIS控制,无法在web.config中覆盖。相反,您可以通过更新您托管服务的站点的IIS站点绑定信息来控制基址。

The base address of an IIS-hosted WCF service is controlled by IIS and cannot be overridden in web.config. Instead, you can control the base addresses by updating the IIS site binding information for the site you're hosting your service in.

我在网上找到的大多数文档建议使用*作为net.pipe的绑定配置。但是,如果您使用virtualsite.com作为绑定配置值,则net.pipe端点的基址将是virtualsite.com而不是计算机名称。

Most of the documentation I found online suggests using * as the binding configuration for net.pipe. But if you instead use "virtualsite.com" as the binding configuration value, the base address of your net.pipe endpoint will be "virtualsite.com" rather than the machine name.

以下是使用appcmd在IIS中使用正确的net.pipe绑定配置网站的示例:

Here is an example using appcmd to configure a site in IIS with the correct net.pipe binding:

%windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.pipe',bindingInformation='virtualhostname.com']

关于 HostnameComparisonMode 的一个注释,根据 MSDN

One note about HostnameComparisonMode, it has no effect in IIS according to MSDN:

在Internet信息服务(IIS)或Windows进程激活服务(WAS)托管环境中使用时,这些值无效。在这些情况下,WCF使用托管WCF服务的IIS网站提供的任何主机名比较模式。

These values have no effect when used inside of the Internet Information Services (IIS) or Windows Process Activation Service (WAS) hosting environment. In those cases, WCF uses whatever hostname comparison mode is provided by the IIS Web Site hosting the WCF services.

相反,您必须使用我上面描述的机制。我通过调查主机名绑定如何在HTTP中用于IIS来解决这个问题。不幸的是,我无法为其他WCF传输找到基于IIS的场景的任何官方文档。

Instead, you have to use the mechanism I described above. I figured this out by investigating how hostname binding works in HTTP for IIS. Unfortunately, I've not been able to find any official documentation for this IIS-based scenario for other WCF transports.

这篇关于在IIS中托管WCF net.pipe绑定时控制命名管道的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆