2012-05-02 22 views
1

WSHttpBindingを使用してWCFファイルのアップローダを作成しています。私は約10 MBのファイルをアップロードしようとしています(そのゲームでは正確なゲームをしていませんが、ファイルをもっと大きくすることはありません)。すべてが約5MBまでかなりうまく動作します。その後、私はHTTP 500エラーを取得し始めます。WCFのWSHttpBindingによる大量のファイルアップロード

次のように私は、バインディングが設定されています

wsBinding.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max; 
wsBinding.MaxBufferPoolSize = 52428800; 
wsBinding.MaxReceivedMessageSize = 13631488; 
wsBinding.ReceiveTimeout = new TimeSpan(0, 3, 0); 

マイのhttpRuntime maxRequestLength

私の要求は次のようになりweb.configファイルに20480キロバイトです:

POST http://mywebsite/FileUploader.svc HTTP/1.1 
Accept-Encoding: gzip,deflate 
Content-Type: application/soap+xml;charset=UTF-8;action="http://namespace/UploadPhoto" 
Content-Length: 13979476 
Host: mywebsite 
Connection: Keep-Alive 
User-Agent: Apache-HttpClient/4.1.1 (java 1.5) 

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:fil="http://namespace"> 
    <soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"><wsa:Action>http://namespace/IFileUploaderSvc/UploadPhoto</wsa:Action></soap:Header> 
    <soap:Body> 
     <fil:UploadPhoto> 
     <fil:AuthorizationToken>(Password)</fil:AuthorizationToken> 
     <fil:ProgramName>AProgram</fil:ProgramName> 
     <fil:FileName>bigolefile.jpg</fil:FileName> 
     <fil:File>(base 64 file data)</fil:File> 
     </fil:UploadPhoto> 
    </soap:Body> 
</soap:Envelope> 

それが私は非常に重要ですWebHttpBindingではなくWSHttpBindingを使用します。事前に おかげで、 アンドリュー

+0

あなたのWCFサービスのいずれかの設定を持っているか、それが設定され、コードを経由してホストされていますか?また、サービスでトレースを有効にして、大きなファイルでアップロードが失敗する理由を確認してください。http://msdn.microsoft.com/en-us/library/ms733025.aspx – Rajesh

+0

これを確認してください:http://debugmode.net/2011/07/18/upload-large-file-of-size-over-silver-to-server-location-wcf /を使用しています。そこにはBasicHttpBindingが使用されていますが、役立つ情報がいくつか含まれています。 –

答えて

1

はWSHttpBindingでmessageEncodingプロパティが結合のためにTextMessageEncodingBindingElementまたはMtomMessageEncodingBindingElementを使用してみてください。

たとえば、次のスニペットではTextMessageEncodingBindingElementを使用しています。 messageEncoding =「テキスト」http://msdn.microsoft.com/en-us/library/ms733742.aspx

<wsHttpBinding> 
    <binding name="wsHttpWithMessageSecurity" messageEncoding="Text" 
      closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" 
      sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 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" /> 
関連する問題