2012-03-14 17 views
3

WCFサービスに13 Mbを超える送信はできません。私は最大要求の長さが例外ここWCFサービスに最大13 Mbを送信できません(最大要求長を超えました)

あるCreateServiceHost実装

protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) 
{ 

IssuedSecurityTokenParameters itp = new IssuedSecurityTokenParameters(
        "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1"); 

      itp.IssuerAddress = new EndpointAddress(ConfigManager.ActAsSTS); 
      itp.IssuerMetadataAddress = new EndpointAddress(ConfigManager.ActAsSTS + "/mex"); 

      // Create the security binding element 
      SecurityBindingElement sbe = SecurityBindingElement.CreateIssuedTokenForCertificateBindingElement(itp); 
      sbe.MessageSecurityVersion = 
       MessageSecurityVersion.WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10; 


      // Create the HTTP transport binding element 
      HttpTransportBindingElement httpBe = new HttpTransportBindingElement(); 
      httpBe.MaxReceivedMessageSize = httpBe.MaxBufferPoolSize = Constants.MaxFileSize; 


      TextMessageEncodingBindingElement encodingElement = new TextMessageEncodingBindingElement(); 
      XmlDictionaryReaderQuotas quotas = encodingElement.ReaderQuotas; 
      quotas.MaxArrayLength = quotas.MaxBytesPerRead = quotas.MaxStringContentLength = quotas.MaxNameTableCharCount = quotas.MaxDepth = (int)Constants.MaxFileSize; 

      // Create the custom binding using the prepared binding elements 
      CustomBinding binding = new CustomBinding(sbe, encodingElement, httpBe); 


      EndpointAddress endpointAddress = new EndpointAddress(new Uri(ConfigManager.BaseAddress)); 
      ServiceEndpoint endpoint = new ServiceEndpoint(contractDescription, binding, endpointAddress); 
      host.Description.Endpoints.Add(endpoint); 


      host.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, 
       X509FindType.FindByThumbprint, ConfigManager.ServiceCertificateThumbprint); 
} 

Constants.MaxFileSize = 20971520(20 Mbが= 20 * 1024 * 1024)

すべての必要な設定MaxReceivedMessageSizeを超えて取得します、MaxBytesPerRead ...が設定されています。私はあなたが達成したいものを正しく理解していれば

はまた、web.configファイル

+1

私はずっとWCFで働いていない、それはしばらくだったので、これは暗闇の中でだけでショットです以前は、トランスポートとしてHTTPを使用しているため、実際には13 MBの実際のデータが20 MBにエンコードされるように、メッセージはベース64エンコードされている可能性がありますか? [ドキュメント](http://msdn.microsoft.com/library/e1f13641.aspx)にはこのようなことは言及されていませんが、Base64は通常30%のサイズ増加を引き起こすと思います。 – BACON

答えて

0

<httpRuntime maxRequestLength="20480"/>設定があります - あなたは大きなファイルのアップロードを受けたWCFサービスを作成します。

もしそうなら、おそらくWCF with streamingバインディングを使用すると、目標を達成するのに役立ちます。

しばらく前に、私はこれと同様の構成を使用して、大容量ファイルのアップロードを受け入れたサービスを書いた:

<netTcpBinding> 
<binding name="netTcpStreaming" sendTimeout="00:15:00" transferMode="Streamed" maxReceivedMessageSize="2147483648"> 
      <security mode="None" /> 
    </binding> 
</netTcpBinding> 
関連する問題