我需要从我的一个客户端发送大量的短信到我的服务器。要做到这一点,我知道我需要增加服务器上的maxStringContentLength。
我已经对此进行了大量的搜索,并且似乎这个的所有修复都是从步骤3开始的。
我看不出第一步和第二步.
有人能陪我走过这段美好而缓慢的旅程吗。考虑到下面的Web.config,如何设置maxStringContentLength
这是我的Web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
</configuration> 背景资料:
发布于 2012-02-17 19:59:39
您必须通过修改在服务端点上使用的绑定的属性。由于您没有在配置文件中提供任何内容,如果服务托管在IIS中,则WCF4.0是在主机中定义。,那么基本地址是虚拟目录。
默认端点上使用的绑定是在<protocolMapping>元素中定义的。在机器级别,映射是:
<protocolMapping>
<add scheme="http" binding="basicHttpBinding"/>
<add scheme="net.tcp" binding="netTcpBinding"/>
<add scheme="net.pipe" binding="netNamedPipeBinding"/>
<add scheme="net.msmq" binding="netMsmqBinding"/>
</protocolMapping>在您的示例中,除非已覆盖默认映射,否则WCF将使用http://myserver/Orders创建一个基于basicHttpBinding虚拟目录的默认HTTP端点。
您可以通过提供一个maxStringContentLength默认绑定配置(即无名配置)来修改basicHttpBinding的basicHttpBinding属性,该配置将自动应用于使用该绑定的所有端点。
只需将此元素添加到Web.config中的<system.serviceModel>部分:
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="SomeIntegerValue">
<readerQuotas maxStringContentLength="SomeIntegerValue" />
</binding>
</basicHttpBinding>
</bindings>注意,MSDN推荐将maxStringContentLength和maxReceivedMessageSize属性设置为相同的值。
maxStringContentLength属性的值不能大于maxReceivedMessageSize属性的值。我们建议这两个属性的值是相同的。
如果这不起作用,可以通过在<protocolMapping>中添加Web.config元素来显式定义用于默认HTTP端点的绑定,并相应地调整绑定配置:
<protocolMapping>
<add scheme="http" binding="basicHttpBinding"/>
</protocolMapping>发布于 2012-02-17 19:53:18
要举例说明我在评论中所说的话,请在<system.serviceModel>部分的web.config中进行如下操作。
首先,在配置文件中指定绑定配置-例如:
<bindings>
<wsHttpBinding>
<binding name="MyWsHttpBinding" closeTimeout="00:05:00"
openTimeout="00:05:00"
receiveTimeout="00:05:00"
sendTimeout="00:05:00"
transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288"
maxReceivedMessageSize="5242880">
<readerQuotas maxDepth="32"
maxStringContentLength="5242880"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
</binding>
</wsHttpBinding>
</bindings>接下来,您需要将上面的配置分配给您的端点:
<services>
<service behaviorConfiguration="MyServiceBehavior" name="MyService">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="MyWsHttpBinding"
contract="MyCompany.IMyService" />
</service>
</services>重要的是要记住通过bindingConfiguration将绑定配置的名称分配给端点,否则您将获得所选绑定的默认值。
另外,请参阅以下关于WCF4.0- 开发人员介绍Windows通信基金会4的默认端点和绑定的文章
https://stackoverflow.com/questions/9334252
复制相似问题