對於大於64K的郵件,我收到了maxreceivedmessagesize錯誤。問題是我已經改變了服務器和客戶端的一切,並沒有解決問題。silverlight 3 wcf服務配置 - 獲取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>
Silverlight客戶端
<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>
所以爲什麼我仍然得到錯誤?
好吧,這裏爲後somemore信息...
我發現了一個錯誤。我的綁定對象的原始聲明是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);
}
你能發佈你收到的確切錯誤信息嗎? – Jacob 2010-01-29 18:22:12
System.ServiceModel.CommunicationException:傳入消息的最大消息大小配額(65536)已被超出。要增加配額,請在適當的綁定元素上使用MaxReceivedMessageSize屬性。 – 2010-01-29 20:13:04
也許你的服務沒有使用你定義的行爲。您可以將服務定義和端點添加到帖子中嗎? – Jacob 2010-01-29 21:42:19