WCFでファイルをアップロードするRESTサービスをIISでホストする形で公開しています。
C#
1WCFプロジェクト 2ITestService.cs 3[ServiceContract] 4public interface ITestService 5{ 6 [OperationContract] 7 [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "api/v1/uploadtest", ResponseFormat = WebMessageFormat.Json)] 8 TestList UploadTest(string test); 9} 10 11Webサービスプロジェクト 12Global.asax.cs 13public class Global : System.Web.HttpApplication 14{ 15 protected void Application_Start(object sender, EventArgs e) 16 { 17 System.Web.Routing.RouteTable.Routes.Add(new ServiceRoute("TestService", new WebServiceHostFactory(), typeof(TestServiceLib.TestService))); 18 } 19
UploadTestメソッドのパラメタtestは、Base64でエンコードされた文字列を想定しています。
数キロバイトのファイルであれば、正常にUploadTestメソッドが完了するのですが
100キロバイトくらいのサイズになると、次のエラーで例外が発生します。
'System.ServiceModel.ProtocolException' のハンドルされていない例外が mscorlib.dll で発生しました。
追加情報: リモート サーバーから予期しない応答が返されました: (413) Request Entity Too Large。
検索して、WCFプロジェクトの App.config にmaxReceivedMessageSize、maxBufferSize、maxArrayLength、maxStringContentLengthなどを調整してみたのですが、改善されません。
あなたの回答
tips
プレビュー