仅当从 Windows 服务运行的服务时,客户端才能连接主机 WCF 服务
本文关键字:服务 客户端 连接 WCF 主机 Windows 运行 | 更新日期: 2023-09-27 18:32:55
继续这篇文章我在本教程WCF
计算机上创建了项目主机服务:http://www.aspdotnet-suresh.com/2011/06/introduction-to-wcf-wcf-tutorial-wcf.html在我的计算机上运行WCF
服务后,我无法与客户端连接到我的服务并收到EndPointNotFoundException
(这发生在本地和远程计算机),如果我的服务通过 Visual Studio 运行,则情况并非如此。什么可能导致此错误?
应用配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="WCFService.Service1">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8733/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="basicHttpBinding" contract="WCFService.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="False"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
您应该在管理员权限下运行服务。Windows服务已经具有,这就是为什么您可以毫无问题地运行它的原因。