-1

WCFサービスのメソッドを呼び出して、ファイルの内容を含むbyte[]タイプのプロパティを持つDTOを渡します。これは、ファイルが最大約3 MBになるまで正常に機能し、最大で失敗します。私が見つけたすべての情報は、構成属性をより大きな値に設定することについて話しますが、私はすでにすべてを最大限に活用しています。これは私のwebste設定ファイルからのものです:

<bindings>
  <wsHttpBinding>
    <binding name="dxWsBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="None"  >
        <transport clientCredentialType="None" />
        <message establishSecurityContext="false" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

<behaviors>
  <endpointBehaviors>
    <behavior name="UserContextClientBehavior">
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
      <UserContextBehaviorExtension />
    </behavior>
  </endpointBehaviors>
</behaviors>

これは私のWebサービス構成ファイルからのものです:

<behaviors>
  <serviceBehaviors>
    <behavior name="DefaultBehavior">
      <serviceMetadata httpGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="True"/>
    </behavior>
    <behavior name="ErrorLoggerBehavior">
      <serviceMetadata httpGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="True"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
      <ErrorLogger logName="DXWcfErrorLog" />
    </behavior>
  </serviceBehaviors>
</behaviors>

<bindings>
  <wsHttpBinding>
    <binding name="dxWsBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="None"  >
        <transport clientCredentialType="None" />
        <message establishSecurityContext="false" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

これらの最大値を本番環境で使用することは私の意図ではありませんが、これを機能させるためにあらゆることを試みていたことに注意してください。

リクエストが失敗すると、Webサービスに何も表示されません。私は両方の設定ファイルでこれを試しました:

<system.diagnostics>
  <trace autoflush="true">
    <listeners>
    </listeners>
  </trace>
  <sources>
    <source name="System.ServiceModel"
            switchValue="Information, ActivityTracing"
            propagateActivity="true">
      <listeners>
        <add name="sdt"
             type="System.Diagnostics.XmlWriterTraceListener"
             initializeData= "WcfDetailTrace.svclog" />
      </listeners>
    </source>
  </sources>
</system.diagnostics>

しかし、Webサービスのログファイルを開いたとき、失敗した要求の兆候はまったくありませんでした。Webサイトのログファイルには、私がすでに知っていることが示されていました。クライアント側、つまりWebサイトで取得する情報は次のとおりです。

2012-09-25 12:26:46,273エラー予期しない例外が発生しました
System.ServiceModel.CommunicationException:http:// localhost:52114/DocumentService.svcへのHTTP応答の受信中にエラーが発生しました。これは、HTTPプロトコルを使用していないサービスエンドポイントバインディングが原因である可能性があります。これは、サーバーによってHTTP要求コンテキストが中止されたことが原因である可能性もあります(おそらくサービスのシャットダウンが原因です)。詳細については、サーバーログを参照してください。---> System.Net.WebException:基になる接続が閉じられました:受信時に予期しないエラーが発生しました。---> System.IO.IOException:トランスポート接続からデータを読み取れません:既存の接続がリモートホストによって強制的に閉じられました。---> System.Net.Sockets.SocketException:既存の接続がリモートホストによって強制的に閉じられました
System.Net.Sockets.Socket.Receive(Byte []バッファー、Int32オフセット、Int32サイズ、SocketFlagsでsocketFlags)
System.Net.Sockets.NetworkStream.Read(Byte []バッファー、Int32オフセット、Int32サイズ)
---内部例外スタックトレースの終わり---
System.Net.Sockets.NetworkStream.Read(Byte []バッファー、Int32オフセット、Int32サイズ)
System.Net.PooledStream.Read(Byte []バッファー、Int32オフセット、Int32サイズ)
System.Net.Connection.SyncRead(HttpWebRequest request、Boolean userRetrievedStream、Boolean probeRead)で
---内部例外スタックトレースの終わり---
System.Net.HttpWebRequest.GetResponse()で
System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpanタイムアウト)で
---内部例外スタックトレースの終わり---

サーバースタックトレース:
System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException、HttpWebRequest request、HttpAbortReason abortReason)で
System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpanタイムアウト)で
System.ServiceModel.Channels.RequestChannel.Request(メッセージメッセージ、TimeSpanタイムアウト)で
System.ServiceModel.Dispatcher.RequestChannelBinder.Request(メッセージメッセージ、TimeSpanタイムアウト)で
System.ServiceModel.Channels.ServiceChannel.Call(String action、Boolean oneway、ProxyOperationRuntime operation、Object [] ins、Object [] outs、TimeSpan timeout)で
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall、ProxyOperationRuntime操作)で
System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessageメッセージ)で

[0]で再スローされた例外:
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg、IMessage retMsg)で
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&msgData、Int32 type)で
SI.Doh.Aon.Service.Interface.IServiceBase`1.AddEntity(TDto dto)で
SI.Doh.Aon.Web.Controllers.DocumentUploaderController.Upload(DocumentEditModel model、HttpPostedFileBase FileName)のC:\ SVN Source \ Department_Of_Health \ Area_Of_Need \ src \ SI.Doh.Aon.Web \ Controllers \ DocumentUploaderController.cs:line 142
lambda_method(Closure、ControllerBase、Object [])で
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller、Object [] parameters)で
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext、IDictionary`2パラメータ)で
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext、ActionDescriptor actionDescriptor、IDictionary`2パラメータ)で
System.Web.Mvc.ControllerActionInvoker.c__DisplayClass15で。
  b__12()
  System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter、ActionExecutingContext preContext、Func`1 continuation)で
  System.Web.Mvc.ControllerActionInvoker.c__DisplayClass15.c__DisplayClass17で。
    b__14()
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext、IList`1フィルター、ActionDescriptor actionDescriptor、IDictionary`2パラメーター)
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext、String actionName)で
    System.Web.Mvc.Controller.ExecuteCore()で
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)で
    System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)で
    System.Web.Mvc.MvcHandler.c__DisplayClass6.c__DisplayClassbで。
      b__5()
      System.Web.Mvc.Async.AsyncResultWrapper.c__DisplayClass1で。
        b__0()
        System.Web.Mvc.Async.AsyncResultWrapper.c__DisplayClass8`1で。
          b__7(IAsyncResult _)
          System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()で
          System.Web.Mvc.MvcHandler.c__DisplayClasseで。
            b__d()
            System.Web.Mvc.SecurityUtil.b__0(アクションf)で
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(アクションアクション)で
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)で
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)で
   System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()で
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step、Boolean&completedSynchronously)で
4

1 に答える 1

5

httpRuntime 属性内に maxRequestLength もあります。

<system.web>
    <httpRuntime maxRequestLength="2097151" />
</system.web>
于 2012-09-25T08:38:25.987 に答える