2012-03-21 55 views
2

是否可以在服務的Web.config文件中定義默認的客戶端綁定配置?WCF:是否可以在服務的Web.config中指定默認的客戶端配置設置?

我想,這樣的客戶並不需要經常更改默認設置

沿着這個東西線(不工作)指定默認maxReceivedMessageSize和maxBufferPoolSize值:

<bindings> 
     <wsHttpBinding > 
     <binding name="Standard" maxReceivedMessageSize="6000000" maxBufferPoolSize="200000000" > 
      <readerQuotas maxDepth="32" maxBytesPerRead="200000000" 
       maxArrayLength="200000000" 
       maxStringContentLength="200000000"/> 
      <security mode="TransportWithMessageCredential" /> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint binding="wsHttpBinding" 
     bindingConfiguration="Standard" 
     contract="SomeContract" /> 
    </client> 

回答

3

在WCF 4(.NET 4) - 是:剛離開name=屬性留空(或省略name=屬性都在一起) - 因此使用

<bindings> 
    <wsHttpBinding > 
     <binding 
      maxReceivedMessageSize="6000000" maxBufferPoolSize="200000000" > 
     <readerQuotas maxDepth="32" maxBytesPerRead="200000000" 
       maxArrayLength="200000000" maxStringContentLength="200000000"/> 
     <security mode="TransportWithMessageCredential" /> 
     </binding> 
    </wsHttpBinding> 
</bindings> 

,然後這些設置適用於該配置文件中由端點使用的所有wsHttpBinding

瞭解更多關於WCF 4新功能的信息:A Developer's Introduction to WCF 4 - 默認的綁定和行爲配置也列在那裏(距離頂端不太遠)。

+0

這似乎設置服務端點上綁定的默認值。是否有類似的技術可以用來指定所有客戶端配置的默認值? – cordialgerm 2012-03-21 19:01:28

+0

@pickles:只需在客戶端的配置中使用相同的方法...這些默認值總是適用於您定義它們的配置。 – 2012-03-21 19:06:42

+0

好了,因此無法爲服務配置中的所有客戶端指定默認值。謝謝 – cordialgerm 2012-03-21 19:26:12

相關問題