3

我有许多 WCF 服务,我需要从另一个服务调用一个服务。我决定netNamedPipeBinding为此目的使用。

我的 web.config 文件看起来像这样。(我没有在这里复制无关的东西。)

 <services>
          <service             name="Services.AuthorizationService"    >
            <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" >
            <endpoint
              name="AuthorizationService"
              address=""
              binding="basicHttpBinding"               contract="ServiceContracts.IAuthorizationService" />
            <endpoint address="net.pipe://localhost/TestSite/AuthorizationService.svc"
                   binding="netNamedPipeBinding"                   contract="ServiceContracts.IAuthorizationService"
                   name="AuthorizationNamedPipeEndpoint"/>           
          </service>
</Services>

web.config 文件中的客户端部分如下所示:

<client>
      <endpoint address="net.pipe://localhost/TestSite/AuthorizationService.svc"
       binding="netNamedPipeBinding"            contract="ServiceContracts.IAuthorizationService" name="AuthorizationServiceNamedPipe" />
    </client>

我正在尝试OperationContract像这样调用其中一个(GetDetails):

  using (ChannelFactory<IAuthorizationService> authorizationChannel = new ChannelFactory<IAuthorizationService>("AuthorizationServiceNamedPipe"))
                        {
                            IAuthorizationService authorizationService = authorizationChannel.CreateChannel();
                            var response = authorizationService.GetDetails(new GetDetailsRequestMessage());
                        }

当我执行这段代码时,我在调用 OperationContract GetDetails 的那一行得到了异常:

在 net.pipe://localhost/TestSite/AuthorizationService.svc 上没有可以接受消息的端点侦听。这通常是由不正确的地址或 SOAP 操作引起的。有关更多详细信息,请参阅 InnerException(如果存在)。

我无法找出确切的问题。也没有 InnerException。我使用的是Windows7机器,IIS版本是IIS7.5。请注意,我可以毫无问题地从我的 Winform 应用程序调用此服务。net.pipe 绑定被添加到 IIS 中的网站绑定中。

如何使用 net.pipe 传输确保服务正常工作?如果是 HTTP,我们可以在 IE 中浏览并确保它。

4

2 回答 2

9

Windows Communication Foundation Non-HTTP Activation激活组件后,此问题已解决Control Panel —&gt; Programs and Features, and then click "Turn Windows Components On or Off" in the left pane. Expand the Microsoft .NET Framework 3.5

当它被激活并且您使用非 HTTP 绑定时,会自动使用 WAS。

我犯了一个非常基本和愚蠢的错误,但它帮助我学习了很多东西。以下文章对我帮助很大:

使用 WAS 将 WCF 服务扩展到 HTTP 之外

在 Windows 激活服务中托管 WCF 服务

当消费者尝试调用托管在虚拟机上的 WCF 服务调用时,WCF 被拒绝访问

最后一个链接给了我一个指针,表明服务器证书相关的配置可能会造成麻烦。我正在为服务添加一个行为(问题中没有看到)。该行为是使用服务器证书。

于 2011-08-08T12:49:50.927 回答
0

我们在 SharePoint 2013 中遇到了同样的问题。安装过程中发生了一些事情,并且没有打开激活设置。我不确定这是应用程序服务器功能的问题还是其他问题。

所以谢谢你的帖子!我们也能够纠正 SP 2013 问题。这是我们为可能遇到的人看到的例外情况:

System.ServiceModel.EndpointNotFoundException:在 net.pipe://localhost/SecurityTokenServiceApplication/appsts.svc上没有可以接受消息的端点侦听。这通常是由不正确的地址或 SOAP 操作引起的。有关更多详细信息,请参阅 InnerException(如果存在)。--->

System.IO.PipeException:在本地计算机上找不到管道端点“net.pipe://localhost/SecurityTokenServiceApplication/appsts.svc”。

于 2013-12-17T17:11:28.680 回答