使用超过16 KB的数据从Silverlight调用Azure web服务



我从Silverlight应用程序调用Azure(WCF)web服务。Silverlight仅支持基本HttpBinding,因此我的ServiceReferences.ClientConfig文件如下所示:

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IServices" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://(AzureUri)/Services.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServices"
                contract="WebServices.IServices" name="BasicHttpBinding_IServices" />
        </client>
    </system.serviceModel>
</configuration>

问题是,Silverlight应用程序在调用数据超过16384字节的Azure web服务时,会出现臭名昭著的"NotFound"错误消息,从而崩溃,显然达到了限制之一。

但是basicHttpBinding不支持maxBytesPerRead、maxStringContentLength等属性,所以我不知道如何允许调用数据超过16KB的Azure web服务。

谷歌搜索让我更加困惑,所以任何帮助都很感激。。。

感谢您抽出时间,Paul

在服务器配置中,确保service元素内endpointbindingConfiguration属性正确指向绑定的名称。还要验证binding元素是否指向"basicHttpBinding"。通常,请仔细查看所有名称,因为如果其中一个拼写错误或丢失,则最终会得到服务器中的默认配置。

有关完整的示例,请参阅从Silverlight应用程序中的WCF服务检索大量数据。

这似乎很有希望:http://smehrozalam.wordpress.com/2009/01/29/retrieving-huge-amount-of-data-from-wcf-service-in-silverlight-application/

(Cross在MSDN上发帖,因为我没有得到回复,而且很紧急…)

我认为问题在于web服务正在Azure中运行。

•如果服务在本地运行,我可以向它传递超过16KB的数据。•如果服务在Azure中运行,我会收到消息:"读取XML数据时超过了最大数组长度配额(16384)"。

但我在服务的Web.config中有以下设置:

<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_IAzureServices"
                   maxBufferPoolSize     ="2147483647"
                   maxBufferSize         ="2147483647"
                   maxReceivedMessageSize="2147483647">
    <readerQuotas  maxArrayLength        ="2147483647"
                   maxBytesPerRead       ="2147483647"
                   maxDepth              ="2147483647"
                   maxNameTableCharCount ="2147483647"
                   maxStringContentLength="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>

因此,当服务在Azure中运行时,maxBufferSize设置将被忽略。

最新更新