我有一个 WCF 服务已经运行了一段时间了,我决定向它添加一些东西。所有旧的东西都可以正常工作,而新的东西适用于从客户端到主机的较小传输。但是,当客户端尝试向主机发送大字符串时,它会出现“(400)错误请求”。无需更改任何内容,主机就可以毫无问题地向客户端发送同样大或更大的项目。
我在这里和其他网站上环顾四周,虽然我发现有人遇到同样的问题,但他们的解决方案(增加 app.config 大小和长度)并没有为我的问题带来任何成功。
网页配置
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
<behavior name="Throttled">
<serviceThrottling
maxConcurrentCalls="1000"
maxConcurrentSessions="1000"
maxConcurrentInstances="1000" />
<serviceMetadata
httpGetEnabled="true"
httpGetUrl="" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
应用程序配置
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647"
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="---HostingSiteURL---/Service.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
contract="SimSyncServiceReference.IService" name="BasicHttpBinding_IService" />
</client>
</system.serviceModel>