2011-06-17 95 views
1

每当我连我的客户端将数据发送到我的WCF Azure的服务,我得到这个错误:maxReceivedMessageSize在Azure WCF服务太小

“的最大邮件大小配额传入消息(65536)已超出。要增加配额 ,请在适当的绑定 元素上使用MaxReceivedMessageSize属性。“

我读过无处不在关于在客户端和服务器配置文件上设置MaxReceivedMessageSize属性。我已经做到了。

但是,每当我更新客户端服务引用,它拉的设置恢复到65536默认(通过调查.svcinfo文件中)

这使我得出结论的问题,必须在服务方面。

我放在这在我的web.config文件:

<bindings> 
    <basicHttpBinding> 
    <!--The basicHttpBinding is used for clients which use the generated code to transmit data; the following settings make it possible to send larger amounts to the service--> 
    <binding maxReceivedMessageSize="10000000" receiveTimeout="01:00:00"> 
     <readerQuotas maxStringContentLength="10000000" /> 
    </binding> 
    </basicHttpBinding> 
</bindings> 

现在,很多帖子谈论命名绑定并在服务器端设置它在服务端点为好。这样的事情:

<services> 
    <service name="YourNamespace.YourServiceClass"> 
     <endpoint name="endpoint1" 
      address="http://server:8888/YourService.svc" 
      binding="basicHttpBinding" 
      bindingConfiguration="lageMessageTransfer" 
      contract="IYourServiceContract" /> 
    </service> 
</services> 

但是,我没有这些服务端点,我的服务很适合小尺寸。

这需要设置在哪里?

编辑:

更多信息,蒂姆似乎是在正确的轨道与默认端点上。我正在使用默认端点。看起来你不能明确地为该默认端点定义一个服务。或者如果可以的话,我必须做的不正确。

但是,您似乎可以按照Richard的说法修改默认端点上的绑定。这是通过简单地不指定绑定的名称来完成的。我尝试将服务中的值设置为更低的值,以查看是否有其他值正在降低它们,但它们完全被忽略。它就好像默认端点简单地忽略了我创建的绑定。

在我的整个配置文件:为什么没有被拾起新的绑定设置

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
<system.diagnostics> 
<trace autoflush="true" /> 
<sources> 
    <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true"> 
    <listeners> 
     <add name="sdt" type="System.Diagnostics.XmlWriterTraceListener" initializeData="logging.e2e" /> 
    </listeners> 
    </source> 
</sources> 
</system.diagnostics> 
<system.web> 
<compilation debug="true" targetFramework="4.0"> 
    <assemblies> 
    <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
    </assemblies> 
</compilation> 
</system.web> 
<system.serviceModel> 
<bindings> 
    <basicHttpBinding> 
    <binding maxReceivedMessageSize="100" maxBufferSize="100" receiveTimeout="00:11:00"> 
     <readerQuotas maxStringContentLength="100" /> 
    </binding> 
    </basicHttpBinding> 
</bindings> 

<protocolMapping> 
    <add scheme="http" binding="basicHttpBinding" /> 
</protocolMapping> 

<behaviors> 
    <serviceBehaviors> 
    <behavior> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false" /> 
</system.serviceModel> 
<system.webServer> 
<modules runAllManagedModulesForAllRequests="true" /> 
</system.webServer> 
<connectionStrings><EDITEDOUT></connectionStrings> 
</configuration> 

的思考?

+0

不幸的是,据我所知,如果你不能修改服务的配置,就会陷入困境。如果您绝对无法修改服务的配置,则需要采取措施确保您的有效负载小于65536字节的最大值。 – GunnerL3510 2011-06-17 01:54:04

+0

我可以修改服务器的配置,但是它不会选择新的设置。 – Jared 2011-06-17 22:50:54

回答

0

您的服务端没有Web.config中的部分?如果您使用的是WCF 4.0,那么您可能使用的是默认端点?

我不知道您是否可以为默认端点指定绑定,但您可能需要尝试通过Web.config部分指定端点并将bindingConfiguration设置为您的部分中指定的绑定。

+0

我试图明确地定义一个新的服务端点,没有地址: <服务名称= “TimesheetService.TimesheetSvc”> <端点合同= “为MyService” 结合= “basicHttpBinding的” bindingConfiguration = “MyBinding”/> 没有运气,虽然这看起来像它的正确道路。无论如何要追踪并查看配置中是否有错误输入? – Jared 2011-06-17 18:14:24

+0

你可以发布整个配置文件吗?机会是配置文件中不匹配的东西。 – Tim 2011-06-17 19:03:54

+0

与原始问题内嵌。 – Jared 2011-06-17 22:19:39

1

属性名称maxReceivedMessageSize非常明确 - 这一切都取决于谁在接收消息 - 如果您发送大量数据,那么它就是服务,如果您从服务中获取大量数据那么它就是客户。服务和客户端对于此设置不需要相同的值(与许多其他绑定设置不同)

设置未命名的绑定部分应该与.NET 4一般工作,因为它将配置绑定给任何不使用bindingConfiguration显式指定一个配置。但是,在上面的示例中,除了缓冲而不是流式传输消息之外,还需要除maxReceivedMessageSize外还设置maxBufferSize。 maxBufferSize和maxReceivedMessageSize必须相同

+0

我也设置了maxBufferSize。同样的问题。如果我查看每次更新服务引用时都会更新的configuration.svcinfo文件,则可以看到它仍在为所有各种属性拉取默认值。 – Jared 2011-06-17 18:02:09

+0

客户端将看到默认值,因为这些值在客户端和服务上通常是不同的。正如我上面所说的,他们指的是数据的接收者。你可以试试这个:减少maxReceivedMessageSize和maxBufferSize,使它们低于默认值,并发送一条仍然可以工作的消息。但是,从服务中返回绑定实际的maxReceivedMessageSize只是为了确保它没有被拾取,而其他东西不是;不妨碍 – 2011-06-17 18:21:43

+0

((BasicHttpBinding)OperationContext.Current.Host.Description.Endpoints [0] .Binding)。 MaxReceivedMessageSize应该为您提供您需要的内容 – 2011-06-17 18:23:44