簡體   English   中英

沒有端點在net.pipe上偵聽

[英]No endpoint listening at net.pipe

我收到以下錯誤:

在net.pipe:// localhost / ServiceModelSamples / service上沒有可以接受該消息的端點。 這通常是由錯誤的地址或SOAP操作引起的。 有關更多詳細信息,請參閱InnerException(如果存在)。

我在另一個WCF調用中調用Windows服務中的WCF自托管服務,如下所示。

                   _host = new ServiceHost(typeof(CalculatorService),
            new Uri[] { new Uri("net.pipe://localhost/PINSenderService") });

        _host.AddServiceEndpoint(typeof(ICalculator),
                new NetNamedPipeBinding(),
                "");

        _host.Open();

        ChannelFactory<ICalculator> factory = new ChannelFactory<ICalculator>(
            new NetNamedPipeBinding(NetNamedPipeSecurityMode.None),
            new EndpointAddress("net.pipe://localhost/PINSenderService"));
        ICalculator proxy = factory.CreateChannel();
        proxy.SendPin(pin);
        ((IClientChannel)proxy).Close();
        factory.Close();

自托管WCF服務

 namespace PINSender
 {

    // Define a service contract.    

    public interface ICalculator
    {
        [OperationContract]
        void SendPin(string pin);
    }

    // Implement the ICalculator service contract in a service class.
    public class CalculatorService : ICalculator
    {
        // Implement the ICalculator methods.
        public void  SendPin(string pin)
        {
        }
    }

    public class CalculatorWindowsService : ServiceBase
    {
        public ServiceHost serviceHost = null;
        public CalculatorWindowsService()
        {
            // Name the Windows Service
            ServiceName = "PINSenderService";
        }

        public static void Main()
        {
            ServiceBase.Run(new CalculatorWindowsService());
        }

        // Start the Windows service.
        protected override void OnStart(string[] args)
        {
            if (serviceHost != null)
            {
                serviceHost.Close();
            }

            // Create a ServiceHost for the CalculatorService type and 
            // provide the base address.
            serviceHost = new ServiceHost(typeof(CalculatorService));

            // Open the ServiceHostBase to create listeners and start 
            // listening for messages.
            serviceHost.Open();
        }

        protected override void OnStop()
        {
            if (serviceHost != null)
            {
                serviceHost.Close();
                serviceHost = null;
            }
        }
    }

    // Provide the ProjectInstaller class which allows 
    // the service to be installed by the Installutil.exe tool
    [RunInstaller(true)]
    public class ProjectInstaller : Installer
    {
        private ServiceProcessInstaller process;
        private ServiceInstaller service;

        public ProjectInstaller()
        {
            process = new ServiceProcessInstaller();
            process.Account = ServiceAccount.LocalSystem;
            service = new ServiceInstaller();
            service.ServiceName = "PINSenderService";
            Installers.Add(process);
            Installers.Add(service);
        }
     }

}

App.Config中

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
  <service name="PINSender.CalculatorService"
           behaviorConfiguration="CalculatorServiceBehavior">
    <host>
      <baseAddresses>            
        <add baseAddress="net.pipe://localhost/PINSenderService"/>
      </baseAddresses>
    </host>

    <endpoint address=""
              binding="netNamedPipeBinding"
              contract="PINSender.ICalculator" />        
    <endpoint address="mex"
              binding="mexNamedPipeBinding"
              contract="IMetadataExchange" />                
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="CalculatorServiceBehavior">
      <serviceMetadata httpGetEnabled="False"  />
      <serviceDebug includeExceptionDetailInFaults="False"/>
    </behavior>
  </serviceBehaviors>
  </behaviors>
 </system.serviceModel>
</configuration>
  • 確保IIS配置為使用Windows Process Activation Service(WAS)

    1. 從“開始”菜單中,選擇“控制面板”。
    2. 選擇程序,然后選擇程序和功能,或在經典視圖中,選擇Programs and Features
    3. 單擊“ Turn Windows Features on or off
    4. 在功能摘要下,單擊添加功能。
    5. 展開Microsoft .NET Framework 3.0(or 3.5)節點並檢查Windows Communication Foundation Non-HTTP Activation feature
  • 確保Net.Pipe偵聽器適配器服務正在運行:

    1. 必須run並打開Services.msc
    2. 確保Net.Pipe Listener Adapter服務正在運行。

在App.config中,您已將baseAddresshttp baseAddress使用,請嘗試將其更改為net.pipe

  <baseAddresses>
    <add baseAddress="net.pipe://localhost/ServiceModelSamples/service"/>
  </baseAddresses>

有關詳細信息,請參閱NetNamedPipeBinding

更新

您需要在endpoint添加bindingConfiguration ,如:

<endpoint address=""
              binding="netNamedPipeBinding"
              contract="Microsoft.ServiceModel.Samples.ICalculator" 
              bindingConfiguration="Binding1" /> 

並添加實際的bindingConfiguration如:

    <bindings>
  <!-- 
        Following is the expanded configuration section for a NetNamedPipeBinding.
        Each property is configured with the default value.
     -->
  <netNamedPipeBinding>
    <binding name="Binding1" 
             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">
      <security mode="Transport">
        <transport protectionLevel="EncryptAndSign" />
      </security>
    </binding>
  </netNamedPipeBinding>
</bindings>

我彈出了同樣的錯誤。 我在Windows 8.1上運行Visual Studio 2013。 我的解決方案是以管理員身份運行Visual Studio。

我也在Windows Server 2012上運行Visual Studio 2013,它與8.1基本相同,重新啟動它,因為管理員也修復了我的問題。

希望能幫助到你!

我有這個問題,因為我使用的是較舊的教程 ,並嘗試以編程方式進行配置。

我缺少的部分是提供元數據端點( 謝謝,這篇文章! )。

ServiceMetadataBehavior serviceMetadataBehavior = 
    host.Description.Behaviors.Find<ServiceMetadataBehavior>();

if (serviceMetadataBehavior == null)
{
    serviceMetadataBehavior = new ServiceMetadataBehavior();
    host.Description.Behaviors.Add(serviceMetadataBehavior);
}

host.AddServiceEndpoint(
    typeof(IMetadataExchange), 
    MetadataExchangeBindings.CreateMexNamedPipeBinding(), 
    "net.pipe://localhost/PipeReverse/mex"
);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM