![](/img/trans.png)
[英]No endpoint listening error when trying to connect to a WCF service with named pipe endpoint from Web application hosted in IIS
[英]Can't connect to NetTcpBinding WCF service due to “There was no endpoint listening” error
你们能指出我在这里想念的东西吗?
我有两个示例项目。 两个控制台应用程序(.Net 3.5)。 这是“服务器”端:
class Program
{
static void Main()
{
var baseAddresses = new Uri("net.tcp://localhost:9000/WcfServiceLibrary/svc");
var host = new ServiceHost(typeof(UiWcfSession), baseAddresses);
var reliableSession = new ReliableSessionBindingElement { Ordered = true, InactivityTimeout = TimeSpan.MaxValue };
var binding = new CustomBinding(reliableSession, new TcpTransportBindingElement()) { ReceiveTimeout = TimeSpan.MaxValue };
host.AddServiceEndpoint(typeof(IClientFulfillmentPipeService), binding, k.WinSvcEndpointName);
host.Open();
Thread.CurrentThread.Join();
}
}
不知道这是否重要,但这是IClientFulfillmentPipeService
[ServiceContract(CallbackContract = typeof (IClientFulfillmentPipeServiceCallbacks), SessionMode = SessionMode.Required)]
public interface IClientFulfillmentPipeService
{
[OperationContract(IsOneWay = true)]
void Initialize(int uiProcessId, string key);
}
[ServiceContract]
public interface IClientFulfillmentPipeServiceCallbacks
{
[OperationContract(IsOneWay = true)]
void ShowBalloonTip(int timeout, string tipTitle, string tipText, BalloonTipIcon tipIcon);
}
最后是客户
private void OpenConnection()
{
try
{
var ep = new EndpointAddress("net.tcp://localhost:9000/WcfServiceLibrary/svc");
var reliableSession = new ReliableSessionBindingElement {Ordered = true};
Binding binding = new CustomBinding(reliableSession, new TcpTransportBindingElement());
reliableSession.InactivityTimeout = TimeSpan.MaxValue;
var pipeFactory = new DuplexChannelFactory<IClientFulfillmentPipeService>(this, binding, ep);
commChannel = pipeFactory.CreateChannel();
((IChannel) commChannel).Open(OpenConnectionTimeout);
}
catch (Exception ex)
{
Log.ErrorFormat("The communication channel to the windows service could not be established. {0}", ex.Message);
}
}
客户端失败,并显示System.ServiceModel.EndpointNotFoundException
异常,该异常显示: “ net.tcp:// localhost:9000 / WcfServiceLibrary / svc上没有侦听端点可以接受该消息。这通常是由于地址错误或SOAP操作引起的请参阅InnerException(如果存在)以了解更多详细信息。”
这是使用命名管道的生产代码的修改,我想将其转换为Tcp传输。
谢谢!
我不小心将k.WinSvcEndpointName
留在了服务器的端点定义中。 那就是问题所在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.