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

时间:2012-02-11 18:57:22

标签: wcf silverlight azure

我从Silverlight应用程序调用Azure(WCF)Web服务。 Silverlight只支持basicHttpBinding,所以我的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>

问题在于,当使用超过16384字节的数据调用Azure Web服务时,Silverlight应用程序会因臭名昭着的“NotFound”错误消息而崩溃,显然会遇到其中一个限制。

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

谷歌搜索让我更加困惑,所以感谢任何帮助...

谢谢你的时间, 保罗

3 个答案:

答案 0 :(得分:1)

在服务器配置上,确保服务元素中端点元素的 bindingConfiguration 属性正确指向绑定的名称。还要验证绑定元素是否指向“basicHttpBinding”。一般情况下,仔细检查所有名称,因为如果其中一个名称拼写错误或丢失,您将最终得到服务器中的默认配置。

有关完整示例,请参阅Retrieving huge amount of data from WCF service in Silverlight application

答案 1 :(得分:0)

答案 2 :(得分:0)

(因为我没有得到答案,所以在MSDN上交叉发布,这很紧急......)

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

•如果服务在本地运行,我可以传递超过16 KB的数据。 •如果服务在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设置。