2012-09-06 204 views
2

WCF綁定我正在開發一個使用WCF服務SharePoint工作流 - 事實是,我沒有任何的正確部署app.config文件的方式。這裏就是我所說的:創建從代碼隱藏

<configuration> 
<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="WSHttpBinding_IService1" 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" /> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:55693/Service1.svc" binding="wsHttpBinding" 
      bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1" 
      name="WSHttpBinding_IService1"> 
      <identity> 
       <dns value="localhost" /> 
      </identity> 
     </endpoint> 
    </client> 
</system.serviceModel> 

我無法找到如何動態地設置了從代碼,會有人這麼好心,並指出我在正確的方向?

回答

5

這只是工作一樣了AppConfig:

WSHttpBinding binding = new WSHttpBinding(); 
binding.Name = "WSHttpBinding_IService1"; 
... 
binding.ReaderQuotas.MaxDepth = 32; 
... 
binding.Security.Mode = SecurityMode.Message; 
...