編集
MVC 3 を使用して、MVC サービスが消費した WCF サービスのメソッドを呼び出そうとしていますが、メソッドを呼び出すと次のエラーが発生します。
メッセージを逆シリアル化しようとしているときにフォーマッタが例外をスローしました: パラメータhttp://tempuri.org/:emailDataを逆シリアル化しようとしているときにエラーが発生しました。InnerException メッセージは、「タイプ EmailPO のオブジェクトのデシリアライズ中にエラーが発生しました。XML データの読み取り中に、文字列コンテンツの最大長クォータ (8192) を超えました。このクォータは、XML リーダーの作成時に使用される XmlDictionaryReaderQuotas オブジェクトの MaxStringContentLength プロパティを変更することで増やすことができます。行 89、位置 1075.'。詳細については、InnerException を参照してください。
これは、私が思っていたように、ASP.NET だけに関連するものではありません。Cassini でローカルに動作するこのサービスも使用する WPF アプリケーションがあります。同一の WPF アプリケーションを使用し、この同じ WCF サービスを公開した後にサービスを使用すると、同じメソッドを実行しても上記のエラーが発生します。
動作しない ASP.NET MVC クライアント Web.config:
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="UserInterface.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<!--<location path="~/Content/images" allowOverride="false">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>-->
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Configuration" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="1073741824" maxBufferPoolSize="1073741824"
maxReceivedMessageSize="1073741824" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="65536" maxArrayLength="102400" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://server1/WebServices/MasterEngine/MasterEngineService.svc?wsdl" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Configuration" contract="MasterEngineFarEnd.IMasterEngineService" name="BasicHttpBinding_IMasterEngineService" />
--- Later on after company specific stuff --
<system.web>
<httpRuntime requestValidationMode="2.0" maxRequestLength="5120" executionTimeout="1200" />
<customErrors mode="Off" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<authentication mode="Windows"></authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<!--<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="404" path="/Error/NotFound" responseMode="ExecuteURL" />
<error statusCode="500" path="/Error/Error" responseMode="ExecuteURL" />
</httpErrors>-->
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true"></modules>
<handlers>
<remove name="UrlRoutingHandler"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Routing" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
WCF サービス (MasterEngine) Web.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Configuration" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="1073741824" maxBufferPoolSize="1073741824" maxReceivedMessageSize="1073741824"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="1073741824" maxArrayLength="102400"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<!-- OLD CONFIG
<binding name="BasicHttpBinding_Configuration" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" 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 address="http://server2/WebServices/InternalService/InternalService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Configuration"
contract="InternalFarEnd.IInternalService" name="BasicHttpBinding_IInternalHubService" />
</client>
</system.serviceModel>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
動作しない WPF アプリケーション
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<diagnostics>
<endToEndTracing propagateActivity="true" activityTracing="true"
messageFlowTracing="true" />
</diagnostics>
<behaviors>
<endpointBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 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>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Configuration" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" maxBufferPoolSize="1073741824"
maxReceivedMessageSize="1073741824" useDefaultWebProxy="true">
<readerQuotas maxDepth="1073741824" maxStringContentLength="1073741824"
maxArrayLength="1073741824" maxBytesPerRead="1073741824" maxNameTableCharCount="1073741824" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://server01-dev/WebServices/MasterEngine/MasterEngineService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Configuration"
contract="MasterEngineFarEnd.IMasterEngineService" name="BasicHttpBinding_IMasterEngineService" />
</client>
</system.serviceModel>
</configuration>
動作する WPF アプリケーション
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<diagnostics>
<endToEndTracing propagateActivity="true" activityTracing="true"
messageFlowTracing="true" />
</diagnostics>
<behaviors>
<endpointBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 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>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Configuration" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" maxBufferPoolSize="1073741824"
maxReceivedMessageSize="1073741824" useDefaultWebProxy="true">
<readerQuotas maxDepth="1073741824" maxStringContentLength="1073741824"
maxArrayLength="1073741824" maxBytesPerRead="1073741824" maxNameTableCharCount="1073741824" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://server01-dev/WebServices/MasterEngine/MasterEngineService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Configuration"
contract="MasterEngineFarEnd.IMasterEngineService" name="BasicHttpBinding_IMasterEngineService" />
</client>
</system.serviceModel>
</configuration>
他のスレッドがエラーの実際の状態と一緒に言ったように、max-everything を追加しましたが、この時点で 8192 が適用される場所や、それが何を参照しているのかわかりません。誰かが私を正しい方向に向けることができれば、本当に感謝しています。必要に応じて、参照しているクラスは次のようになります.. DataMembers / DataContracts が設定されている
電子メール PO クラス
[DataContract]
public class EmailPO
{
[DataMember]
public string FromEmail { get; set; }
[DataMember]
public List<String> ToEmail { get; set; }
[DataMember]
public List<String> CcEmail { get; set; }
[DataMember]
public string FullHTML { get; set; }
[DataMember]
public string Subject { get; set; }
[DataMember]
public List<EmailClassLibrary.AttachmentItem> Attachments { get; set; }
[DataMember]
public string TableHeader { get; set; }
}
編集 - 更新
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors>
<endpoint address="http://server1/WebServices/MasterEngine/MasterEngineService.svc?wsdl"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_Configuration"
contract="MasterEngineFarEnd.IMasterEngineService"
name="BasicHttpBinding_IMasterEngineService"/>
また、名前を付けてエンドポイントを更新して、behaviorConfigurationに同じ名前を使用してみました