2

在尝试让 Ne​​tNamedPipeBinding 为我的 WCF 服务工作时,我已经完全用尽了资源。我能够在这里找到 NorthwindService 示例。

对于 NorthwindService 示例,我有以下内容:

namespace NorthwindServices
{
   public class Customer : ICustomer
   {
        public string GetCustomerName(int CustomerID)
        {
            return CustomerID.ToString();
        }
   }
}

namespace NorthwindServices
{
    [ServiceContract]
    public interface ICustomer
    {
        [OperationContract]
        string GetCustomerName(int CustomerID);
    }
}

该示例的配置如下:

<system.serviceModel>
<services>
  <service name="NorthwindServices.Customer"
           behaviorConfiguration="ServiceBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="net.pipe://localhost/NorthwindServices/Customer"/>
      </baseAddresses>
    </host>
    <!-- Service Endpoints -->
    <!-- Unless fully qualified, address is relative to base address supplied above -->
    <endpoint address="CustomerService" binding="netNamedPipeBinding" contract="NorthwindServices.ICustomer"/>
    <endpoint address="CustomerService/mex" binding="mexNamedPipeBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <!-- To avoid disclosing metadata information, 
      set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="False" httpsGetEnabled="False"/>
      <!-- To receive exception details in faults for debugging purposes, 
      set the value below to true.  Set to false before deployment 
      to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
  </serviceBehaviors>
</behaviors>

我为此定义了一个 IIS 站点,详细信息如下:

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

因此,当我转到“添加服务参考”时,我可以完美地提取参考。

在此处输入图像描述

然而,当我尝试在我的实际应用程序中做同样的事情时,我似乎仍然无法弄清楚。我无法引用参考。

网站结构如下:

The top level site is an MVC site, and there is an "API" virtual directory below it where the service resides that I am trying to expose over NetNamedPipeBinding.

在此处输入图像描述

该站点的绑定如下: 在此处输入图像描述

我试图通过命名管道公开的服务的配置如下:

<system.serviceModel>
<services>
  <service name="Site.API.Service.WorkItemQueueService"
           behaviorConfiguration="ServiceBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="net.pipe://localhost/WorkItemQueueService"/>
      </baseAddresses>
    </host>
    <endpoint address="QueueService"
              binding="netNamedPipeBinding"
              contract="Site.API.Service.IWorkItemQueueService"/>
    <endpoint address="QueueService/mex"
              binding="mexNamedPipeBinding"
              contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="false"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="True" aspNetCompatibilityEnabled="True"/>

服务实现与上面的客户服务相同,但显然重命名以匹配上面的配置。

当我尝试添加服务引用或为此查找元数据时,它找不到它。

在此处输入图像描述

重要提示- 启动 Net Pipe 侦听器和角色服务等所有预配置项均已完成,因此 NorthwindServices 示例有效。

4

0 回答 0