Csla 设置WCF Binding修改

Csla.DataPortalClient.WcfProxy.cs文件中. 

/// <summary>
    /// Returns an instance of the channel factory
    /// used by GetProxy() to create the WCF proxy
    /// object.
    /// </summary>
    protected virtual ChannelFactory<IWcfPortal> GetChannelFactory()
    {
      // if dataportal url is specified use this with default wsHttBinding
      if (!string.IsNullOrEmpty(ApplicationContext.DataPortalUrlString))
      {
        // set up WSHttpBinding with
        var binding = new WSHttpBinding()
        {
          //MaxBufferPoolSize = int.MaxValue,       // default is 524288 and kept to default value
          MaxReceivedMessageSize = int.MaxValue,    // default is 65536
          ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas()
          {
            MaxArrayLength = int.MaxValue,          // default is 16384
            //MaxBytesPerRead = 4096,               // default is 4096 (and recommended to keep at default value)
            MaxStringContentLength = int.MaxValue,  // default is 8192
           
          }
        
        };
        #region 
        //安全配置默认为binding.Security.Mode=SecurityMode.Message 无法使用 这里先用None.
        binding.Security.Mode = SecurityMode.None;

        #endregion
        return new ChannelFactory<IWcfPortal>(binding, new EndpointAddress(ApplicationContext.DataPortalUrl));
       
          #region Binding可用配置文件代替 
          /**************
              <system.serviceModel>
                <bindings>
                  <wsHttpBinding>
                    <binding name="WcfDataPortal" closeTimeout="00:01:00" openTimeout="00:01:00"
                      receiveTimeout="00:10:00" sendTimeout="00:01:00" maxReceivedMessageSize="2147483647">
                      <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647" />
                      <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>
                  </wsHttpBinding>
                </bindings>
                <client>
                  <endpoint address="http://192.168.1.200/WcfDemo/EDISService.svc"
                    binding="wsHttpBinding" bindingConfiguration="WcfDataPortal"
                    contract="Csla.Server.Hosts.IWcfPortal" name="WcfDataPortal">
      
                    <identity>
                      <servicePrincipalName value="host/dayisvr-svr" />        
                    </identity>
                  </endpoint>
                </client>
              </system.serviceModel>
           *
           *
           *
           * return new ChannelFactory<IWcfPortal>("WcfDataPortal", new EndpointAddress(ApplicationContext.DataPortalUrl));

           ********************* */
          #endregion

      }

      // else return a channelfactory that uses the endpoint configuration in app.config/web.config
      return new ChannelFactory<IWcfPortal>(_endPoint);
    }

posted @ 2012-03-05 11:32  wccc  阅读(427)  评论(0编辑  收藏  举报