silverlight 3 wcf 服务配置——获取 maxreceivedmessagesize 错误 [英] silverlight 3 wcf service configuration -- getting maxreceivedmessagesize error

查看:26
本文介绍了silverlight 3 wcf 服务配置——获取 maxreceivedmessagesize 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于大于 64K 的消息,我收到 maxreceivedmessagesize 错误.问题是我已经更改了服务器和客户端的所有内容,但并没有解决问题.

这是我在服务器上的 web.config,然后是 Silverlight 客户端配置:

<绑定><基本HttpBinding><绑定名称="secureobjectbind" maxBufferSize="2147483647"maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"><readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"maxArrayLength="2147483647" maxBytesPerRead="2147483647"maxNameTableCharCount="2147483647"/><安全模式=传输"/></binding></basicHttpBinding></绑定><行为><服务行为><行为名称="GiveWeb.Services.ShopBehavior"><serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/><serviceDebug includeExceptionDetailInFaults="true"/><dataContractSerializer maxItemsInObjectGraph="6553600"/></行为></serviceBehaviors></行为><服务><service behaviorConfiguration="GiveWeb.Services.ShopBehavior"name="GiveWeb.Services.Shop"><端点地址="" binding="basicHttpBinding"bindingConfiguration="安全对象绑定"合同="GiveWeb.Services.IShop"><身份><dns value="localhost"/></身份></端点><端点地址=mex"绑定=mexHttpsBinding"合同=IMetadataExchange"/></服务></服务><serviceHostingEnvironment><baseAddressPrefixFilters><清除/><add prefix="http://www.ushop2give.com"/></baseAddressPrefixFilters></serviceHostingEnvironment></system.serviceModel>

银光客户端

<预><代码><配置><system.serviceModel><绑定><基本HttpBinding><绑定名称="BasicHttpBinding_IShop" maxBufferSize="2147483647"maxReceivedMessageSize="2147483647"><安全模式=传输"/></binding></basicHttpBinding></绑定><客户><端点地址="https://web14.ai-host.com/Services/Shop.svc"绑定=基本HttpBinding"bindingConfiguration="BasicHttpBinding_IShop"contract="ShopSVC.IShop" name="BasicHttpBinding_IShop"/></客户端></system.serviceModel></配置>

那为什么我仍然收到错误消息?

<小时>

好的,这是帖子的更多信息...

我发现了一个错误.我对绑定对象的原始声明是 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);返回新的 GiveSL.ShopSVC.ShopClient(lxBinding, lxAddress);}

解决方案

终于有解决方案了...

有两个潜在的问题:

  1. 客户端的绑定对象被错误地声明为 System.ServiceModel.Channels.Binding,应该被声明为 System.ServiceModel.BasicHttpBinding.因此,上面列出的函数是在 Silverlight 客户端中创建代理对象的正确代码.
  2. 必须是应用程序缓存了对服务客户端的第一次调用.一直以来,我一直在努力寻找解决方案,我只更改了一个绑定调用,它不是我项目中调用的第一个.当我编写用于创建代理对象的中央函数时,它仍然无法工作,直到我在各处更改了所有代码以使用该中央函数.

既然我的所有代码都使用相同的函数来创建服务客户端代理,那么 MaxReceivedMessageSize 的设置得到了尊重,一切都很好.

哇...只是从来没有见过那个人来.

感谢大家(尤其是雅各布)在这件事上和我在一起.

史蒂夫

I'm getting the maxreceivedmessagesize error for messages greater than 64K. The problem is that I've already changed everything in both server and client, and it's not fixing the problem.

here's my web.config on the server and then the silverlight client config:

<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 client

<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>

so why am I still getting the error?


Ok, here's somemore info for the post...

I found one error. My original declaration for my binding object was as System.ServiceModel.Channels.Binding not System.ServiceModel.BasicHttpBinding. That's why I wasn't seeing the properties for MaxReceivedMessageSize on the object.

I have corrected this and created a function to create my proxy, But I'm still getting an error message when more than 65536 bytes are in the return message.

     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);
 }

解决方案

Finally a solution...

There were two underlying problems:

  1. The binding object on the client side was incorrectly declared as System.ServiceModel.Channels.Binding and should have been declared as System.ServiceModel.BasicHttpBinding. So, the function listed above is the correct code for creating the proxy object in the Silverlight client.
  2. It must be that the very first call to the service client is cached by the application. All this time I've been trying to work a solution, I was only changing one of the binding calls, and it wasn't the first one called in my project. When I wrote the central function for creating the proxy object it still didn't work until I changed all my code everywhere to use that central function.

Now that all my code uses the same function for creating the service client proxy, the setting of MaxReceivedMessageSize is respected and all is well.

Wow... just never saw that one coming.

Thanks everyone (especially Jacob) for hanging with me on this one.

Steve

这篇关于silverlight 3 wcf 服务配置——获取 maxreceivedmessagesize 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆