0

ASP.NETサーバーは、WPFクライアントによって使用される一連のWCFサービスを提供しています。文字列フィールドの長さが8Kを超えるまで、すべてが正常に機能していました。これにより、ASP.NETサーバーで次の例外が生成されます...

Project.ModelTypeタイプのオブジェクトの逆シリアル化中にエラーが発生しました。XMLデータの読み取り中に、文字列コンテンツの最大長クォータ(8192)を超えました。このクォータは、XMLリーダーの作成時に使用されるXmlDictionaryReaderQuotasオブジェクトのMaxStringContentLengthプロパティを変更することで増やすことができます。

WPF app.configでMaxStringContentLengthの値を64Kに増やしましたが、これで問題が解決しませんでした。したがって、ASP.NET側でもこの値を増やす必要があると思います。しかし、web.configに変更する値はありません!これを表示するための私のweb.configは次のとおりです...

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />

    <authentication mode="Forms">
      <forms name=".ASPXFTOAUTH"
             timeout="10"
             slidingExpiration="true"
             cookieless="UseCookies"/>
    </authentication>

    <membership>
      <providers>
        <clear/>
      </providers>
    </membership>

    <customErrors defaultRedirect="~/Error.htm" mode="RemoteOnly">
      <error statusCode="404" redirect="~/404.aspx" />
    </customErrors>
  </system.web>

  <system.webServer>
     <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
                               multipleSiteBindingsEnabled="true" />
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

では、サーバーを更新して、MaxStringContentLengthの値が高いことを示すにはどうすればよいですか?私のサービスのapp.configは次のようになります...

<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding name="BasicHttpBinding_IAccess" closeTimeout="00:01:00"
               openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
               allowCookies="false" bypassProxyOnLocal="false"
               hostNameComparisonMode="StrongWildcard"
               maxBufferSize="131072" maxBufferPoolSize="524288" maxReceivedMessageSize="131072"
               messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
               useDefaultWebProxy="true">
        <readerQuotas maxDepth="32" maxStringContentLength="65536" maxArrayLength="16384"
                      maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        <security mode="None">
          <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
          <message clientCredentialType="UserName" algorithmSuite="Default" />
        </security>
      </binding>
    </basicHttpBinding>
  </bindings>

  <client>
    <endpoint binding="basicHttpBinding"
              bindingConfiguration="BasicHttpBinding_IAccess" 
              contract="AccessService.IAccess"
              name="BasicHttpBinding_IAccess" />
  </client>
</system.serviceModel>

何か案は?

アップデート:

私のサービスは、クラス「Access.svc」を持つことによって定義されます

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Access : IAccess
{
    // ...IAccess method implementations
}

...次のマークアップがあります...

<%@ ServiceHost Language="C#" Debug="true" 
                Service="Ecotech.AMS.WebServer.Access" 
                CodeBehind="Access.svc.cs" %>

...コメントに記載されているように、web.configのサービスについては特に何もありません。

4

2 に答える 2

0

作業する必要がある場所は Web 構成です。データのサイズを設定できるサービス動作を追加する必要があります。たとえば、このように、

<behaviors>
      <serviceBehaviors>
        <behavior name="SilverlightWCFLargeDataApplication">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>

      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="SilverlightWCFLargeDataApplication">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>

それでもうまくいかない場合は、ここに Web 構成を投稿してください。

于 2013-02-12T03:58:58.187 に答える
0

プロジェクトの右クリック メニューから [サービス参照の追加] をクリックしてみてください。このようにすると、必要な構成情報が web.config ファイルに追加されます。

maxReceivedMessageSizeこれを行うと、バインディングにプロパティを設定できます。このようにすると、WCF サービス側で行っていることが最も正確に反映されます。

于 2013-02-12T01:38:24.670 に答える