1

私は WSHttpBinding を使用して WCF ファイル アップローダに取り組んでいます。私は約 10 mb のファイルをアップロードしようとしています (そのファイルで正確なゲームをプレイしているわけではありませんが、ファイルをそれほど大きくすることはありません)。約5MBまではすべてがうまく機能します。その後、HTTP 500 エラーが発生し始めます。

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

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

私のhttpRuntime maxRequestLengthはweb.configで20480kbです

私のリクエストは次のようになります。

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 を使用することが非常に重要です。前もってありがとう、アンドリュー

4

1 に答える 1

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" />
于 2012-05-08T08:05:56.923 に答える