我有两个网站——一个带有 aspx 文件,一个带有带有两个端点的 wcf 服务,一个 http 和一个命名管道。它们都在同一台机器上运行,因此它们似乎是使用 net.pipe 绑定的候选者。
aspx 文件创建一个服务客户端并尝试调用 net.pipe。我明白了:
“'/dev' 应用程序中的服务器错误。无法发送消息,因为端点地址 'net.pipe://localhost/netNamedPipeBinding' 的服务对于该地址的协议不可用。”
谷歌搜索表明这可能是一个安全问题(没有权限错误与没有侦听器错误相同),但我已经授予 [NETWORK] 用户组的 NTFS 权限,以访问具有服务的网站文件,并且没有任何更改。
带有 aspx 的站点使用 Forms 身份验证(即不是 Windows 身份验证),服务网站是匿名身份验证。web.config 的 net.pipe 安全设置为 =“None”
在本地,这很好用——尽管我必须在控制台应用程序中运行命名管道主机,因为 Visual Studio Dev Server 不能执行命名管道。此外,Http 端点在 IIS 上也能正常工作。
它运行 .NET 4.0、IIS 7.5、Win2008。
IIS 配置 据我所知,
- net.pipe 已为服务网站启用,配置信息为 *
- WAS 已安装并启用,(通过 Windows 功能)
- net.pipe 侦听器 Windows 服务已启用。
- 每个网站都是匿名访问(身份验证由服务器上的第 3 方单点登录完成)
- 每个网站都有自己的应用程序池(可能不相关)
- 服务站点处于网络花园模式(可能不相关)
服务配置(在同一台机器上的 IIS 上运行,不同的 VDIR)
<system.serviceModel>
<bindings>
<netNamedPipeBinding>
<binding name="netNamedPipeBindingConfig" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport protectionLevel="EncryptAndSign" />
</security>
</binding>
</netNamedPipeBinding>
</bindings>
<services>
<service name="MyService">
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/" />
</baseAddresses>
</host>
<endpoint
address="netNamedPipeBinding"
bindingConfiguration="netNamedPipeBindingConfig"
binding="netNamedPipeBinding"
contract="IMyService" >
</endpoint>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
客户端配置(ASP.NET 网站,同一台机器,与服务不同的 VDIR)
<system.serviceModel>
<bindings>
<netNamedPipeBinding>
<binding name="NetNamedPipeBinding_IMyService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport protectionLevel="EncryptAndSign" />
</security>
</binding>
</netNamedPipeBinding>
</bindings>
<client>
<endpoint
address="net.pipe://localhost/netNamedPipeBinding"
binding="netNamedPipeBinding"
bindingConfiguration="NetNamedPipeBinding_IMyService"
contract="MyService.IMyService"
name="NetNamedPipeBinding_IMyService">
</endpoint>
</client>
</system.serviceModel>
(更改服务和合同名称以保护无辜者)
C# 没什么特别的,只是 Add-Service-Reference 生成的代理。(所有这些代码都可以在 wsHttp 绑定中正常工作