Dot-Net

WCF 最小客戶端 app.config 設置

  • March 23, 2016

對於 app.config 中的簡化 WCF 配置,我需要做的最小客戶端設置是什麼?

預設是這樣的:

   <bindings>
       <wsHttpBinding>
           <binding name="WSHttpBinding_IService" 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="Message">
                   <transport clientCredentialType="Windows" proxyCredentialType="None"
                       realm="" />
                   <message clientCredentialType="Windows" negotiateServiceCredential="true"
                       algorithmSuite="Default" establishSecurityContext="true" />
               </security>
           </binding>
       </wsHttpBinding>
   </bindings>

我可以排除什麼,我需要多少?


編輯:我應該開始撕掉零件直到它破裂嗎?我希望能找到一些人們很幸運的優化好的 wsHttpBindings。

Jerograv 是對的,因為這些都是預設值,您可以忽略所有這些。為了測試這一點,我創建了一個簡單的服務並創建了所需的最小配置,這幾乎是地址、綁定和契約——

<?xml version="1.0" encoding="utf-8"?>
<configuration>
   <system.serviceModel>
       <client>
           <endpoint address="http://sabra2/TestService/Service1.svc" binding="wsHttpBinding"
               contract="IService1"/>
       </client>
   </system.serviceModel>
</configuration>

請記住 WCF 的 ABC。地址,綁定,契約。這就是你所需要的!

您的客戶端只需要有一個端點即可與 WCF 服務通信。每個端點只需要描述每個 ABC 就完成了。其他的東西可以稍後補上。

這就是我不喜歡在 Visual Studio 中添加服務引用的原因之一。

引用自:https://stackoverflow.com/questions/448949