我有一個非常奇怪的問題,使用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