[英]Publishing a Wcf service using BasicHttpBinding for remote clients
[英]How to set up my WCF service to be able to be accessed by remote clients
我有一個WCF服務,該服務托管在Windows服務中,可以在使用同一台計算機時連接到它並使用它的服務,但是當我嘗試在遠程計算機上運行客戶端時,它會超時並且不會連接。 我以為我可以用服務機的IP(而不是localhost)更新客戶端的app.config文件,但這沒有用。 這是客戶端的app.config:
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IWCFService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.1.141:8731/Design_Time_Addresses/WCF/WCFService/"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IWCFService"
contract="WCFService.IWCFService" name="WSDualHttpBinding_IWCFService">
<identity>
<dns value="192.168.1.141" />
</identity>
</endpoint>
</client>
這是服務器的app.config:
<system.serviceModel>
<services>
<service name="WCF.WCFService" behaviorConfiguration="WCFBehavior">
<endpoint address="" binding="wsDualHttpBinding" contract="WCF.IWCFService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
bindingConfiguration=""
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
我需要在服務端做一些事情以允許遠程連接嗎?還是我沒有正確配置客戶端?
這似乎是一個簡單的建議,但是您是否檢查了服務器上的防火牆以確保它不會阻止通信? 我花了三天的時間在牆上敲頭,直到意識到這一點。
這可能是比使用以下方法簡單禁用Windows防火牆為特定端口添加規則更好的選擇:
防火牆->高級設置->入站規則->新規則。
看來您是在家中根據192個地址來執行此操作。
您將需要在路由器和Windows防火牆中打孔才能啟動。 之后,如果您想訪問房屋的外部,則應嘗試使用DynDNS來偽造具有用於托管服務的靜態IP的信息。
您可以通過telnet連接到您的服務嗎? 如果不是防火牆問題,我從服務安全性上懷疑。 由於它配置為通過Windows憑據進行身份驗證,這要求您的服務和客戶端位於同一域中,因此如果我錯了,請更正我。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.