繁体   English   中英

WCF服务中找不到端点异常

[英]Endpoint not found exception in a WCF Service

我正在从Microsoft提供的教程开始使用WCF服务。 我创建了一个非常简单的WCF服务( CalculatorService ),对此服务的EndpointAddress感到有些怀疑。

创建WCF主机时,应按以下步骤设置端点:

Uri baseAddress = new Uri("http://localhost:8000/GettingStarted/");
// Step 2 Create a ServiceHost instance
ServiceHost selfHost = new ServiceHost(typeof(Service1), baseAddress);
// Step 3 Add a service endpoint.
selfHost.AddServiceEndpoint(typeof(IService1), new WSHttpBinding(), "CalculatorService");

如果调试整个解决方案,一切正常,但是,如果我启动执行其.exe文件的WCFHost,则还启动客户端的应用程序,将出现以下异常:

System.ServiceModel.EndpointNotFoundException: No endpoint listening in http://localhost:8732/Design_Time_Address/WcfServiceLibrary/Service1/.

事实是,如果我尝试打开浏览器并搜索地址http://localhost:8000/GettingStarted/ ,则可以正确获取服务页面。 我想该服务托管在一个地址上,而客户端试图通过另一个地址来访问它。

谁能帮我解决这个问题?

如果您在客户端代码中对此地址进行了硬编码http:// localhost:8732 ,然后在此处进行更改。 但是您的客户可能是自动生成的(不幸的是,您没有将该信息放入问题中)。 在这种情况下,客户端配置位于App.config文件中(如果我们在谈论您的解决方案),而在构建项目时位于.exe文件的配置文件中。 您应该查看[ClientApplicationName] .exe.config文件,并将端点地址更新为端口8000。

暂无
暂无

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

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