没有端点在net.pipe上监听 [英] No endpoint listening at net.pipe
问题描述
我收到以下错误:
没有端点在监听 net.pipe://localhost/ServiceModelSamples/可以接受以下内容的服务 信息.这通常是由不正确的地址或SOAP操作引起的. 有关更多详细信息,请参见InnerException(如果存在).
There was no endpoint listening at net.pipe://localhost/ServiceModelSamples/service that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
我正在Windows服务中从另一个WCF调用中调用WCF自托管服务,如下所示.
I am calling WCF self hosted service inside windows service from another WCF call as follows.
_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)
:Make sure
IIS
is configured to useWindows Process Activation Service(WAS)
:- 从开始"菜单中,选择控制面板".
- 选择程序",然后选择程序和功能",或者在经典"视图中,
选择
Programs and Features
. - 单击
Turn Windows Features on or off
. - 在功能摘要"下,单击添加功能".
- 展开
Microsoft .NET Framework 3.0(or 3.5)
节点并检查Windows Communication Foundation Non-HTTP Activation feature
.
- From the Start menu, choose Control Panel.
- Select Programs, then Programs and Features, or in Classic view,
select
Programs and Features
. - Click
Turn Windows Features on or off
. - Under Features Summary, click Add Features.
- Expand the
Microsoft .NET Framework 3.0(or 3.5)
node and check theWindows Communication Foundation Non-HTTP Activation feature
.
-
确保 Net.Pipe侦听器适配器服务正在运行:
Make sure Net.Pipe Listener Adapter service is running:
- 转到
run
&打开Services.msc
- 确保
Net.Pipe Listener Adapter
服务正在运行.
- Got to
run
& openServices.msc
- Make sure
Net.Pipe Listener Adapter
service is running.
- 转到
在App.config中,您已将
baseAddress
与http
一起使用,请尝试将其更改为net.pipe
:In your App.config, you have used
baseAddress
withhttp
, try changing that tonet.pipe
:<baseAddresses> <add baseAddress="net.pipe://localhost/ServiceModelSamples/service"/> </baseAddresses>
有关更多信息,请参见 NetNamedPipeBinding 详细信息.
see NetNamedPipeBinding for more details.
更新:
您需要在
endpoint
中添加bindingConfiguration
,例如:You need to add
bindingConfiguration
inendpoint
like :<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>
这篇关于没有端点在net.pipe上监听的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!