在wcf跨機器的訪問中遇到了各種無法訪問的問題,本人也是在通過個人解決問題的基礎上發表一下自己的經驗,如果還有其他方面可能影響wcf跨機器的問題,還希望大家多多發言!
好了廢話不多說了,正文如下:
1、設置好wcf的服務端security mode要設置為None,如
<services>
<service behaviorConfiguration="metadataBehavior" name="Services.CalculatorService">
<endpoint address="http://192.168.1.108:9999/calculatorservice" binding="wsHttpBinding"
bindingConfiguration="NoneSecurity" contract="Contracts.ICalculator" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="NoneSecurity">
<!--maxBufferPoolSize="12000000" maxReceivedMessageSize="12000000" useDefaultWebProxy="false">
<readerQuotas maxStringContentLength="12000000" maxArrayLength="12000000"/>-->
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
這裡要注意的是bindingConfiguration="NoneSecurity",<binding name="NoneSecurity">,<security mode="None"/>這三個地方,一定要設好。
然後是客戶端中的security mode的設置,如
<binding name="WSHttpBinding_CalculatorService" 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"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
這裡要注意的是<security mode="None">這裡也要設置為None,這樣在程序運行的時候才不會粗;
最後就是一定要注意把服務端的防火牆關掉,不然也無法卡機器訪問,好了就這些,如果還有新的可能導致該問題的情況,還請大家發言!
查看本欄目