2010-02-05 8 views
0

내가 자바 스크립트 MaxStringContentLength 문제

<system.serviceModel> 
    <diagnostics> 
     <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" /> 
    </diagnostics> 
    <serviceHostingEnvironment /> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="WSHttpBinding_ITranscriptService" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> 
      <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> 
    <client> 
     <endpoint address="http://localhost:10780/TranscriptService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITranscriptService" contract="TVServiceReference.ITranscriptService" name="WSHttpBinding_ITranscriptService"> 
     <identity> 
      <dns value="localhost"/> 
     </identity> 
     </endpoint> 
    </client> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="WebTV.ForumServiceAspNetAjaxBehavior"> 
      <enableWebScript /> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name="WebTV.TranscriptServiceBehavior" > 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service behaviorConfiguration="WebTV.TranscriptServiceBehavior" 
     name="WebTV.TranscriptService"> 
     <endpoint address="" binding="wsHttpBinding" contract="WebTV.ITranscriptService"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
     <service behaviorConfiguration="WebTV.TranscriptServiceBehavior" name="WebTV.ForumService"> 
     <endpoint address="" behaviorConfiguration="WebTV.ForumServiceAspNetAjaxBehavior" 
      binding="webHttpBinding" contract="WebTV.ForumService" /> 
     </service> 
    </services> 
    </system.serviceModel> 

내가 문자열 값의 큰 덩어리를 통과 할 때 지금 문제가 Web.config의

에 자바 스크립트 코드

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"> 
    <Services> 
     <asp:ServiceReference Path="ForumService.svc" /> 
    </Services> 
</asp:ScriptManager> 

를 사용하여 WCF 서비스에 액세스하고 WFC +, 예외가 발생했습니다

InnerException 메시지가 'System.String 형식의 개체를 역 직렬화하는 동안 오류가 발생했습니다. XML 데이터를 읽는 동안 최대 문자열 내용 길이 할당량 (8192)이 초과되었습니다.

JavaScript를 사용하여 MaxStringContentLength 값을 어떻게 설정합니까?

어떤 조언이 필요합니까?

덕분에 내가이 작업을 수행하는 방법을 발견 인터넷 검색의 몇 시간 후 -Aruna

답변

0

의 SVC 파일을 초기화하는 시점에서 설정을 결합하는

필요.

사용자 정의 클래스를 만들고,

public class DerivedFactory : ServiceHostFactory 
    { 
     protected override ServiceHost CreateServiceHost 
            (Type t, Uri[] baseAddresses) 
     { 
     ServiceHost host = base.CreateServiceHost(t, baseAddresses); 
     WebHttpBinding binding = new WebHttpBinding(); 
     binding.Security.Mode = WebHttpSecurityMode.None; 
     binding.Security.Transport.ClientCredentialType 
            = HttpClientCredentialType.None; 
     binding.MaxReceivedMessageSize = Int32.MaxValue; 
     binding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; 
     binding.ReaderQuotas.MaxArrayLength = Int32.MaxValue; 
     host.Description.Endpoints[0].Binding = binding; 
     return host; 
     } 
    } 

APPEND SVC는 파일 헤더 = "true"를 서비스 = "WebTV.ForumService" = "C#을"디버그 언어

<%@ ServiceHost Factory="WebTV.DerivedFactory" 

에 CodeBehind = "ForumService.svc.cs"%

. 아마도 VS 편집기가 codebehind 파일로 곧바로 이동하기 때문에 메모 패드를 사용하여이 파일을 열려고합니다.

중요한 부분은 여기 = "WebTV.DerivedFactory"

행운 공장입니다!