2013-01-07 3 views
0

비슷한 문제로 여기에 질문을 올렸지 만 이후 바인딩 및 동작을 올바르게 수행하는 적절한 방법에 대해 더 많은 테스트와 조사를 수행했습니다. 훨씬 더 나은 이해 이제, 나는이 초라한 오류를 아직도 얻고있다. 나는 심지어 클라이언트를 거쳐 프로 그로 메틱 방식으로 바인딩을 만들었으므로 올바른 설정을 사용하고 있는지 확신 할 수 있습니다.WCF 리더 할당량 최대 문자열 내용 길이 할당량 (8192)

클라이언트 측 프로그램 :

public static UserAnalyticsFarEnd.UserAnalyticsMasterServiceClient MakeClient(string endpointUri) 
    { 
     UserAnalyticsFarEnd.UserAnalyticsMasterServiceClient client = null; 

     // replicate all the binding info from app.config 
     BasicHttpBinding binding = new BasicHttpBinding(); 
     binding.Name = "MaxSizeBasicBinding"; 
     // The interval of time for a connection to open, before the transport raises an exception. 
     binding.OpenTimeout = TimeSpan.FromMinutes(1); 
     // The interval of time that a connection can remain active, during which no application 
     // messages are received, before it is dropped. This one is NOT important. 
     binding.ReceiveTimeout = TimeSpan.FromMinutes(10); 
     // The interval of time for an operation to complete before the transport raises an exception. 
     // This one is important. The time here was increased so that a command to the Negotiator 
     // has more than the default of one minute before it times out. Given that the Negotiator 
     // tries 3 times on any database command, a total of 3 minutes, CBH changed this to 5 on 2/3/12. 
     binding.SendTimeout = TimeSpan.FromMinutes(5); // used to be 1 
     binding.CloseTimeout = TimeSpan.FromMinutes(1); 
     binding.AllowCookies = false; 
     binding.BypassProxyOnLocal = false; 
     binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; 
     binding.MessageEncoding = WSMessageEncoding.Text; 
     binding.TextEncoding = System.Text.Encoding.UTF8; 
     binding.TransferMode = TransferMode.Buffered; 
     binding.UseDefaultWebProxy = true; 
     //int maxMessageSize = 1024 * 1024; // reasonable size w/o allocating huge amt of memory 
     // That 1MB was not big enough, so increase it to half the limit, 1,073,741,824 
     int maxMessageSize = 1024 * 1024 * 1024; 
     binding.MaxBufferSize = maxMessageSize; 
     binding.MaxReceivedMessageSize = maxMessageSize; 
     binding.ReaderQuotas.MaxBytesPerRead = maxMessageSize; 
     binding.ReaderQuotas.MaxStringContentLength = maxMessageSize; 
     binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; 
     binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; 
     binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default; 
     binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; 
     binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None; 
     try 
     { 

      System.Net.AuthenticationManager.CredentialPolicy = null; 
      EndpointAddress endpointAddress = new EndpointAddress(endpointUri); 
      client = new UserAnalyticsFarEnd.UserAnalyticsMasterServiceClient(binding, endpointAddress); 
      //client.ClientCredentials.Windows.AllowedImpersonationLevel = 
      // System.Security.Principal.TokenImpersonationLevel.Impersonation; 
     } 
     catch (Exception ex) 
     { 
      throw ex; 
     } 

     return client; 

    } 

서비스 측면 (의 Web.config) 사람이 여기 좀 도와주세요 수 있다면, 내가 일 동안 작업 한 및 수없는 것

<bindings> 
    <basicHttpBinding> 

    <binding name="BasicHttpBinding_Configuration" maxBufferSize="2147483647" 
     maxReceivedMessageSize="2147483647"> 
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
       maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
     <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="None" proxyCredentialType="None" 
      realm="" /> 
     <message clientCredentialType="UserName" algorithmSuite="Default" /> 
     </security> 
    </binding> 

    <binding name="BasicBindingMaxLength" maxBufferSize="1073741824" 
      maxReceivedMessageSize="1073741824"> 
     <readerQuotas maxDepth="1073741824" maxStringContentLength="1073741824" 
       maxArrayLength="1073741824" maxBytesPerRead="1073741824" maxNameTableCharCount="1073741824" /> 
     <security mode="TransportCredentialOnly"> 
     <!--<transport clientCredentialType="Windows" />--> 
     </security> 
    </binding> 

    </basicHttpBinding> 
</bindings> 

    <service behaviorConfiguration="UserAnalyticsSvcBehaviors" name="CISE.ServiceEngine.MasterEngineProxy.Services.UserAnalyticsMasterService"> 

    <endpoint address="" binding="basicHttpBinding" behaviorConfiguration="Behaviors.EndpointBehavior" bindingConfiguration="BasicBindingMaxLength" 
    contract="CISE.ServiceEngine.MasterEngineProxy.Interfaces.IUserAnalyticsMasterService"> 
    </endpoint> 
    <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> 

    </service> 

<behavior name="UserAnalyticsSvcBehaviors"> 
     <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
     <serviceMetadata httpGetEnabled="true"/> 
     <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
    </behavior> 

+1

저에게 잘 보입니다. 위에서 지정한 'maxStringContentLength'를 초과하는 문자열이 데이터에 없습니다. –

+0

예. 나는 꽤 확신한다. 그래도 확인할 수 있습니다 – gcoleman0828

답변

1

이 구성을 서비스 구성에 넣으십시오.

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    <httpRuntime executionTimeout="4800" maxRequestLength="2097150"/> 
    </system.web> 
    <system.serviceModel> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    <!--BINDDING--> 
    <bindings> 
     <basicHttpBinding> 
     </basicHttpBinding> 
     <customBinding> 
     <binding name="LargeSilverlight" closeTimeout="00:21:00" openTimeout="00:20:00" 
      receiveTimeout="00:20:00" sendTimeout="00:50:00"> 
      <textMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
       maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
      </textMessageEncoding> 
      <httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
      maxBufferSize="2147483647" /> 
     </binding> 
     </customBinding> 
    </bindings> 
    <client> 
    </client> 
    <!--SERVICE--> 
    <services> 
     <service name="CISE.ServiceEngine.MasterEngineProxy.Services.UserAnalyticsMasterService" behaviorConfiguration="SilverlightWCFLargeDataApplication" > 
     <endpoint address="" binding="customBinding" bindingConfiguration="LargeSilverlight" behaviorConfiguration="SilverlightWCFLargeDataApplication" contract="CISE.ServiceEngine.MasterEngineProxy.Interfaces.IUserAnalyticsMasterService" > 
     </endpoint> 

     </service> 
    </services> 

    <!--BEHAVIOR--> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="SilverlightWCFLargeDataApplication"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 

     </serviceBehaviors> 
     <endpointBehaviors> 
     <behavior name="SilverlightWCFLargeDataApplication"> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 


    </system.serviceModel> 
    <system.webServer> 

    <security> 
     <requestFiltering> 
     <requestLimits maxAllowedContentLength="500000000"></requestLimits> 
     </requestFiltering> 
    </security> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 
+0

위의 구성에서 무엇이 다른지 설명해 주시겠습니까? 무작위로 변경하기 전에 다른 점이 무엇인지 알고 싶습니다. – gcoleman0828

+1

엄청난 양의 데이터를 처리하는 서비스를 수행하는 경우 많은 양을 처리 할 수있는 서비스 동작을 갖는 것이 좋습니다. Sajeetharan

+0

감사합니다 .. dataContractSerializer가 모두 설정되었습니다. – gcoleman0828

관련 문제