我有一个非常奇怪的问题,使用WCF的3层客户端/服务器应用程序。无法访问托管在Windows服务中的WCF
首先,我有一个服务窗口,它承载了basicHttpBinding中的WCF服务。这是服务器的app.config:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service name="Business.BSServiceManagement" behaviorConfiguration="myServiceBehave">
<host>
<baseAddresses>
<add baseAddress="http://localhost:35001"/>
</baseAddresses>
</host>
<endpoint address="/Clients" binding="basicHttpBinding" name="Clients" contract="Contracts.BusinessFacade.IBFClientManagement"/>
<endpoint address="/Users" binding="basicHttpBinding" name="Users" contract="Contracts.BusinessFacade.IBFUserManagement"/>
<endpoint address="/Licences" binding="basicHttpBinding" name="Licences" contract="Contracts.BusinessFacade.IBFLicenceManagement"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="myServiceBehave">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
此服务被部署在DMZ中的服务器上,我从我的电脑访问(在Firefox中,如果我把与端口号服务地址)
其次,我有一个winform客户端应用程序,它使用ChannelFactory来使用服务。
这是客户端的app.config:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<client>
<endpoint address="http://192.168.128.1:35001/Clients" binding="basicHttpBinding" name="Clients" contract="Contracts.BusinessFacade.IBFClientManagement"/>
<endpoint address="http://192.168.128.1:35001/Users" binding="basicHttpBinding" name="Users" contract="Contracts.BusinessFacade.IBFUserManagement"/>
<endpoint address="http://192.168.128.1:35001/Licences" binding="basicHttpBinding" name="Licences" contract="Contracts.BusinessFacade.IBFLicenceManagement"/>
</client>
</system.serviceModel>
</configuration>
当调试客户端应用程序,一切完美的作品。所以我做了一个安装项目部署多台计算机上的应用程序,但是当我执行应用程序的EXE(安装或直接在斌/释放),我有一个这样的错误消息:
There was no endpoint listening at http://192.168.128.1:35001/Users...
内部异常说:
无法连接到远程服务器
我尝试添加MEX终结,改变端口号,检查服务器和客户端计算机的防火墙,我不明白问题出在哪里。
感谢您的帮助。
编辑1:
经过多次试验我在发布的EXE在调试EXE同样的问题,但没有。
如果我执行调试exe文件一切正常,但释放exe文件返回错误信息。
试图了解你的调试配置。你的baseAddress节点是'localhost'是你的开发机器上本地运行的服务吗? – leetibbett
不,我将服务安装在DMZ中的另一台计算机上,并且我只在我的机器上执行了调试客户端,并且完美地工作。但是当我在我的机器上安装客户端时,它不起作用 – user1069516
VS通常以管理员身份运行,如果以管理员身份执行客户端,该怎么办?你添加了客户端exe的防火墙设置吗? – leetibbett