简体   繁体   English

WCF错误-没有端点监听

[英]WCF Error - No endpoint listening

I'm using WCF to send messages back and forth between a windows service (client) and a winforms app (service host). 我正在使用WCF在Windows服务(客户端)和Winforms应用程序(服务主机)之间来回发送消息。 Until recently this has worked. 直到最近,它一直有效。 Now, when the client attempts to communicate I receive the following error message: 现在,当客户端尝试进行通信时,我会收到以下错误消息:

"There was no endpoint listening at http://localhost:8000/ColumbineWCFService that could accept the message. This is often caused by an incorrect address or SOAP action." “在http://localhost:8000/ColumbineWCFService上没有侦听终结点的端点可以接受消息。这通常是由于地址或SOAP操作不正确引起的。”

I have spent an entire day on this forum referencing similar issues but have not been able to resolve, hoping if I provide the specifics from my project the answer will jump out at someone. 我在这个论坛上整整一天都在参考类似的问题,但仍无法解决,希望如果我从项目中提供具体信息,答案会跳到某人身上。

Here's the code snippet (client side) where the error occurs: 这是发生错误的代码段(客户端):

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

Client side app.config: 客户端app.config:

<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# code on the host side: 主机端的C#代码:

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();

Please note, all code compiles and the service does run as evidenced by the "You have created a service" page that results when the base address is typed into a web browser. 请注意,所有代码均已编译,并且该服务确实按照“您已经创建了服务”页面所显示的运行,该页面是在将基本地址输入到Web浏览器中时生成的。 What am I overlooking? 我在俯视什么?

In your app.config in the client endpoint configuration: 在您的app.config中的客户端端点配置中:

  1. It looks like your endpoint address does not specify the .svc file that is hosting the code for the endpoint. 看来您的端点地址未指定承载该端点代码的.svc文件。 Assuming your .svc file name is ColumbineWCFService.svc your address value would be 假设您的.svc文件名为ColumbineWCFService.svc,则您的地址值为

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

  2. Your contract does not specify your namespace. 您的合同未指定您的名称空间。 Assuming your namespace is "ColumbineWCFService" your contract would be "ColumbineWCFService.IColumnbineWCFService" 假设您的命名空间是“ ColumbineWCFService”,那么您的合同将是“ ColumbineWCFService.IColumnbineWCFService”

  3. There is no binding configuration named "WSHttpBinding_IColumbineWCFService" though that parameter shouldn't make a difference in whether the endpoint is listening or not. 没有名为“ WSHttpBinding_IColumbineWCFService”的绑定配置,尽管该参数不会影响端点是否在侦听。

That said, try the following for your app.config: 也就是说,为您的app.config尝试以下操作:

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

If that doesn't work, come back let us know if you have a web.config for your WCF service and post it. 如果那不起作用,请回来让我们知道您是否有用于WCF服务的web.config并将其发布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM