【发布时间】:2020-03-18 05:31:11
【问题描述】:
让我从头开始解释。我的解决方案资源管理器窗口中有 3 个项目,位于 Visual Studio。让我一一解释。第一个是 Web 项目(基于 ASP.NET 表单)。我需要从 2 个不同的来源获取一些数据。因此,我在Visual Studio 的解决方案资源管理器窗口中添加了两个不同的 WCF 项目。
让我告诉你这两个 WCF 项目。第一个 WCF 连接到 SOAP Web 服务。此 SOAP 服务的消息编码类型应为 Mtom。顺便说一下,这个 SOAP Web 服务返回字节数据(如图片)。这就是为什么我右键单击然后添加>服务引用选项来完成此操作。 如您所知,此操作会自动更新 Web.config 文件。这就是为什么您会在 Web.config 文件中看到 'binding="wsHttpBinding" '。
除此之外,还有一个我上面提到的 WCF 项目。但这很好用。我没有任何问题。
我已通过右键单击添加>服务引用选项将这两个 WCF 项目添加到我的 Web 项目中。实际上它工作正常,直到我尝试使用大字节数据(图片)让我解释一下数据大小:第一个 WCF 项目能够为我带来一个小尺寸 1.84 KB(1,890 字节)的数据(图片)。但是同一个 WCF 项目无法为我带来更大尺寸 164 KB(168,423 字节)的数据(图片)。这就是问题。这就是为什么我共享了 web 项目的 web.config 文件和第一个 WCF 项目的 web.config 文件。
我正在共享显示大照片时出现错误的 web.config 文件。 (下面可以看到web项目的web.config文件和第一个WCF项目的web.config文件)
我已经创建并尝试了很多解决方案。但我仍然遇到同样的错误。
这是错误:
The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element
Web 服务器的 IIS 版本为:Windows Server 2012 R2,IIS:版本 8.5.9600.16384。我对这个问题进行了研究。我已经找到并尝试了很多解决方案。但它没有用。
这是 WCF 项目的 web.config 文件
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.6.1"/>
<pages controlRenderingCompatibilityVersion="4.0"/>
</system.web>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="abcdPortBinding">
<mtomMessageEncoding messageVersion="Soap11" />
<httpsTransport />
</binding>
</customBinding>
<wsHttpBinding>
<binding name="SecureHttpBinding"
closeTimeout="00:10:00"
openTimeout="00:10:00"
sendTimeout="00:10:00"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
messageEncoding="Mtom">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
<security mode="None">
<transport clientCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://abc.abc.com:443/abc-srv/abcPort"
binding="customBinding" bindingConfiguration="abcdPortBinding"
contract="mobilSignatureServiceReference.abcdsrv" name="abcdPort" />
</client>
<behaviors>
<serviceBehaviors>
<behavior name="Servicebehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<services>
<service behaviorConfiguration="Servicebehavior" name="abcdWcfServisi.abcdServisim">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="SecureHttpBinding" name="SecureHttp" contract="abcdWcfServisi.IabcdServisim"/>
<host>
<timeouts closeTimeout="00:10:00" openTimeout="00:10:00"/>
</host>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
这里是web项目(asp.net form based project)的Web.config文件
<?xml version="1.0"?>
<configuration>
<appSettings>
</appSettings>
<system.web>
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
<machineKey validation="3DES"/>
<pages viewStateEncryptionMode="Always" enableViewStateMac="true" controlRenderingCompatibilityVersion="4.0"/>
<trace enabled="false" localOnly="true"/>
<httpCookies httpOnlyCookies="true"/>
<sessionState cookieless="UseCookies"/>
<httpModules>
<add name="myHttpModule" type="myHttpModule"/>
</httpModules>
<compilation debug="true" targetFramework="4.6.1">
<assemblies>
<add assembly="System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<authentication mode="Forms">
<forms name="abc" loginUrl="login.aspx" defaultUrl="abc.aspx" timeout="50000"/>
</authentication>
<customErrors mode="RemoteOnly" defaultRedirect="https://abctest.com">
</customErrors>
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
<validation validateIntegratedModeConfiguration="false"/>
<defaultDocument>
<files>
<clear/>
<add value="abc.aspx"/>
<add value="abcSecureSrv.svc"/>
</files>
</defaultDocument>
<httpErrors>
<remove statusCode="502" subStatusCode="-1"/>
<remove statusCode="501" subStatusCode="-1"/>
<remove statusCode="500" subStatusCode="-1"/>
<remove statusCode="412" subStatusCode="-1"/>
<remove statusCode="406" subStatusCode="-1"/>
<remove statusCode="405" subStatusCode="-1"/>
<remove statusCode="403" subStatusCode="-1"/>
<remove statusCode="401" subStatusCode="-1"/>
<remove statusCode="404" subStatusCode="-1"/>
<error statusCode="404" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="401" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="403" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="405" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="406" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="412" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="500" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="501" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
<error statusCode="502" prefixLanguageFilePath="" path="https://abctest.com/abc.aspx" responseMode="Redirect"/>
</httpErrors>
</system.webServer>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="HttpBinding_abcd"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
textEncoding="utf-8"
transferMode="Streamed"
messageEncoding="Text" />
</basicHttpBinding>
<wsHttpBinding>
<binding name="SecureHttp" messageEncoding="Mtom">
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://abctest.com/abcdesube.svc?wsdl"
behaviorConfiguration="SertifikaDavranisi" binding="basicHttpBinding"
bindingConfiguration="HttpBinding_abcd" contract="abcdesube"
name="HttpBinding_abcd" />
<endpoint address="http://localhost:37377/abcdServisim.svc" binding="wsHttpBinding"
bindingConfiguration="SecureHttp" contract="abcdSignature.IabcdServisim"
name="SecureHttp" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="SertifikaDavranisi">
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="SertifikaDavranisi">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
我该如何解决这个问题?
【问题讨论】:
标签: asp.net wcf web-config