对于大于 64K 的消息,我收到 maxreceivedmessagesize 错误。问题是我已经更改了服务器和客户端中的所有内容,但并没有解决问题。
这是我在服务器上的 web.config,然后是 silverlight 客户端配置:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="secureobjectbind" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="GiveWeb.Services.ShopBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="6553600" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="GiveWeb.Services.ShopBehavior"
name="GiveWeb.Services.Shop">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="secureobjectbind"
contract="GiveWeb.Services.IShop">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<clear/>
<add prefix="http://www.ushop2give.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
</system.serviceModel>
银光客户端
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IShop" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://web14.ai-host.com/Services/Shop.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IShop"
contract="ShopSVC.IShop" name="BasicHttpBinding_IShop" />
</client>
</system.serviceModel>
</configuration>
那么为什么我仍然收到错误消息?
好的,这是帖子的更多信息......
我发现了一个错误。我对绑定对象的原始声明是 System.ServiceModel.Channels.Binding 而不是 System.ServiceModel.BasicHttpBinding。这就是为什么我没有在对象上看到 MaxReceivedMessageSize 的属性。
我已经纠正了这个问题并创建了一个函数来创建我的代理,但是当返回消息中的字节数超过 65536 时,我仍然收到一条错误消息。
public static ShopSVC.ShopClient ShopClientProxy()
{
System.ServiceModel.EndpointAddress lxAddress = new System.ServiceModel.EndpointAddress(new Uri(Application.Current.Host.Source, "../Services/Shop.svc"));
System.ServiceModel.BasicHttpBinding lxBinding = new System.ServiceModel.BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode.Transport);
lxBinding.MaxReceivedMessageSize = 2147483647;
lxBinding.MaxBufferSize = 2147483647;
lxBinding.ReceiveTimeout = new TimeSpan(0, 5, 0);
return new GiveSL.ShopSVC.ShopClient(lxBinding, lxAddress);
}