2014-09-25 64 views
1

我使用WCF在Windows服务(客户端)和Winforms应用程序(服务主机)之间来回发送消息。直到最近这个工作。现在,当客户端尝试通信时,我收到以下错误消息:WCF错误 - 没有端点侦听

“没有端点侦听到http://localhost:8000/ColumbineWCFService可以接受该消息,这通常是由不正确的地址或SOAP操作引起的。

我已经花了整整一天的时间在这个论坛上提到类似的问题,但一直没能解决,希望如果我从我的项目提供的具体细节答案会跳出来的人。

下面的代码片断(客户端)发生错误:

var pingHost = new ColumbineWCFServiceReference.ColumbineWCFServiceClient(); 
pingHost.Open(); 
if (pingHost.AreYouThere() == true) return true; //<-- this is the line where the "no endpoint listening" error occurs 

客户端侧的app.config:

ServiceHost selfHost = null; 
Uri baseAddress = new Uri("http://localhost:8000/ColumbineWCFService"); 
selfHost = new ServiceHost(typeof(ColumbineWCFService), baseAddress); 
selfHost.AddServiceEndpoint(typeof(IColumbineWCFService), new WSHttpBinding(), "ColumbineWCFService"); 

ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); 
smb.HttpGetEnabled = true; 
selfHost.Description.Behaviors.Add(smb); 
selfHost.Open(); 
:在主机侧

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="WSHttpBinding_IColumbineWCFService" /> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:8000/ColumbineWCFService/ColumbineWCFService" 
      binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IColumbineWCFService" 
      contract="IColumbineWCFService" name="WSHttpBinding_IColumbineWCFService"> 
     <identity> 
      <userPrincipalName value="Nathan-PC\Nathan" /> 
     </identity> 
     </endpoint> 
    </client> 
    </system.serviceModel> 

C#代码

请注意,所有的代码编译和服务都会按照“您已经创建了服务”页面证明的那样运行n基地址被输入到网页浏览器中。我忽略了什么?

+0

您可以共享整个columbineWCFServiceClient代码,而不仅仅是那么小的一部分吗?我认为AreYouThere()方法定义有问题。另外,您是否尝试过使用WCF测试客户端来联系该方法? Visual Studio有一个客户端可以用来联系它。 – Nzall 2014-09-25 21:28:33

+0

不知道是否可以解释它,但客户端的app.config中的“http:// localhost:8000/ColumbineWCFService/ColumbineWCFService”与主机中的“http:// localhost:8000/ColumbineWCFService”之间似乎有差异。 – 2014-09-25 21:53:25

回答

0

在客户端的端点配置您的app.config:

  1. 它看起来像你的端点地址没有指定托管端点代码.svc文件。假设你的.svc文件名ColumbineWCFService.svc您的地址值将

    http://localhost:8000/ColumbineWCFService/ColumbineWCFService.svc

  2. 你的合同没有具体的命名空间。假设你的命名空间是“ColumbineWCFService”你的合同将是“ColumbineWCFService.IColumnbineWCFService”

  3. 有一个名为“WSHttpBinding_IColumbineWCFService”,尽管该参数不应该在端点无论是听还是不差没有绑定配置。

这就是说,争取你的app.config如下:

<endpoint address="http://localhost:8000/ColumbineWCFService/ColumbineWCFService.svc" 
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IColumbineWCFService" 
contract="ColumbineWCFService.IColumbineWCFService" name="WSHttpBinding_IColumbineWCFService"> 

如果还是不行,再来让我们知道,如果你有一个web.config的WCF服务和发表它。

相关问题