7

私の WCF サービスには、オブジェクトの配列をパラメーターとして受け入れる OperationContract があります。これは潜在的に非常に大きくなる可能性があります。Bad Request: 400 の修正を探したところ、本当の理由がわかりました。メッセージの最大サイズです。

この質問は、多くの場所で以前に尋ねられたことを知っています。「クライアントとサーバーの構成ファイルのサイズを大きくしてください」という誰もが言うことを試してみました。私は持っている。それでもうまくいきません。

私のサービスの web.config:

<system.serviceModel>
    <services>
      <service name="myService">
        <endpoint name="myEndpoint" address=""
                  binding="basicHttpBinding"
                  bindingConfiguration="myBinding"
                  contract="Meisel.WCF.PDFDocs.IPDFDocsService" />
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="myBinding"
                 closeTimeout="00:11:00"
                 openTimeout="00:11:00"
                 receiveTimeout="00:15:00"
                 sendTimeout="00:15:00"
                 maxBufferSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 transferMode="Buffered"
                 allowCookies="false"
                 bypassProxyOnLocal="false"
                 hostNameComparisonMode="StrongWildcard"
                 messageEncoding="Text"
                 textEncoding="utf-8"
                 useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

私のクライアントの app.config:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IPDFDocsService"
                 closeTimeout="00:11:00"
                 openTimeout="00:11:00"
                 receiveTimeout="00:10:00"
                 sendTimeout="00:11:00"
                 allowCookies="false"
                 bypassProxyOnLocal="false"
                 hostNameComparisonMode="StrongWildcard"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 messageEncoding="Text"
                 textEncoding="utf-8"
                 transferMode="Buffered"
                 useDefaultWebProxy="true">
          <readerQuotas maxDepth="32"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None"
                       proxyCredentialType="None"
                       realm="" />
            <message clientCredentialType="UserName"
                     algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8451/PDFDocsService.svc"
                behaviorConfiguration="MoreItemsInObjectGraph"
                binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IPDFDocsService"
                contract="PDFDocsService.IPDFDocsService"
                name="BasicHttpBinding_IPDFDocsService" />
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="MoreItemsInObjectGraph">
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

何が欠けているか、間違っている可能性がありますか? maxReceivedBufferSize に入力した内容をサービスが無視しているようです。

前もってありがとう、カイル

アップデート

以下に、回答を受け取っていない他の 2 つの StackOverflow の質問を示します。

https://stackoverflow.com/questions/2880623/maxreceivedmessagesize-adjusted-but-still-getting-the-quotaexceedexception-with

WCF MaxReceivedMessageSize プロパティが取得されない

4

2 に答える 2

7

サービス構成ファイルで、要素に「name」属性がありません

<behaviors>
  <serviceBehaviors>
    <behavior name="StackOverflow">

また、サービス要素にこの名前への参照が必要です。

<system.serviceModel>
    <services>
        <service behaviorConfiguration="StackOverflow" name="myService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBinding"

一般に、Visual Studio の [ツール] メニュー項目から起動される [WCF サービス構成エディター] を使用して、WCF 構成ファイルを常に編集するわけではないにしても、検証することをお勧めします。

また、サービスに対して定義されたエンドポイントの動作はありません。これが重要かどうかはわかりません。

于 2010-05-26T01:01:55.920 に答える
0

私はWCF Testで同じ問題を抱えていて、設定ファイルを正しく設定していました。構成ファイルに問題がない場合は、別のプログラムでサービスをテストすることをお勧めします。たとえば、SOAP UI です。このエラーはサービスからではなく、WCF テストからのものだと思います。

于 2014-09-25T08:26:35.857 に答える