3

私が現在働いているプロジェクトでは、ビジネスエンティティの配列を返すWCFサービスが公開されています。これを請求書と呼びましょう。

Invoice[] GetInvoicesByTypeAndTime(InvoiceType invoiceType, byte startHour, byte? endHour);

使用される認証メカニズムはWindows認証であり、WCFサービスはIIS6でホストされるWebアプリケーションでホストされます。

最初に64kBを超えるデータを取得していたときに、「着信メッセージの最大メッセージサイズクォータ(65536)を超えました。クォータを増やすには、適切なバインディング要素のMaxReceivedMessageSizeプロパティを使用してください」というCommunicationExceptionがスローされました。

いいでしょう、App.configでmaxReceivedMessageSizeとmaxBufferSizeの両方の値を65536000に増やしました(後者は、ArgumentExceptionで「TransferMode.Bufferedの場合、MaxReceivedMessageSizeとMaxBufferSizeは同じ値。パラメータ名:bindingElement ")。

今、私はより大きな応答を受け取ることができました...

624要素(約2.2 MB)の後に、別の制限(I THINK)に達するまで、奇妙な例外がスローされます。

System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
   at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   --- End of inner exception stack trace ---

サーバースタックトレース:

   at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory factory)
   at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

[0]で再スローされた例外:

   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Test2.DBS.IDbService.GetInvoicesByTypeAndTime(InvoiceType invoiceType, Byte startHour, Nullable`1 endHour)
   at Test2.DBS.DbServiceClient.GetInvoicesByTypeAndTime(InvoiceType invoiceType, Byte startHour, Nullable`1 endHour) in D:\TEMP\Test2\Test2\Service References\DBS\Reference.cs:line 1445
   at Test2.Program.Main(String[] args) in D:\TEMP\Test2\Test2\Program.cs:line 19

認証された応答に制限はありますか?ASP.NET設定に制限はありますか?

4

2 に答える 2

3

私はあなたがWindows認証を使用していると推測しているので、メッセージの制限をどのように超えたかを説明するメッセージではなく、401です。Windows Authenticated要求を介して送信する場合、WCFはSOAP要求を2回送信します。1回目は失敗してacceptsヘッダーを返し、2回目はWindowsAuthenticationヘッダーを使用して送信します。

ただし、私のテストから、メッセージが通過した場合にメッセージが実際に失敗した場合でも、401を取得しているように見えます。

これをトラブルシューティングするには、サーバートレースログインを挿入する必要がありました。

<system.diagnostics>
    <trace autoflush="true" />
    <sources>
      <source name="System.ServiceModel" switchValue="Critical, Error, Warning">
        <listeners>
          <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\Logs\ServiceTrace.svclog"/>
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

次に、上記のように、より大きなリーダー割り当てを設定する必要がありました(ただし、より小さな値を使用しました)。

次に、通常、オブジェクトグラフのアイテムの最大数を増やすために、カスタム動作を設定する必要があります。

<behaviors>
  <serviceBehaviors>
    <behavior name="MaximumItemsBehaviour">
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" />
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

<system.serviceModel><services><service>値「MaximumItemsBehaviour」を使用して「behaviourConfiguration」属性を「」要素に追加する必要があります。

私が読んだが、自分自身を必要としなかった他のアドバイスは、追加することでした:

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime maxRequestLength="2097151" />
  </system.web>

と:

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="209715200"/>
      </requestFiltering>
    </security>
  </system.webServer>
于 2011-12-19T18:49:40.990 に答える
1

クライアント側のreaderQuotasを見てください。TLDRバージョンが必要な場合は、これが本当に問題であるかどうかを確認するために、以下に示すように最大値(Int32.MaxValue)を設定できます

<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
于 2010-01-13T18:02:06.083 に答える