【发布时间】:2010-11-02 04:28:13
【问题描述】:
我有一个名为“Palladium”的 WCF Web 服务,它是在 VS2008 解决方案中作为项目创建的。
我有一个 ASP.Net Web 应用程序,它在名为“Palladium.svc”的页面上托管此服务。
当我将表单数据发布到 Web 服务时,我的服务会接收到该数据并可以对其进行处理。
现在我将图像发布到服务并且帖子大小超过了 WCF 的默认 maxReceivedMessageSize 属性。为了解决这个问题,我在 ASP.Net Web 应用程序的 web.config 文件的端点上添加了一个绑定配置。
我的问题是绑定配置似乎没有应用。
服务是从 iPhone 应用程序发布的,当帖子大小低于 65k 时,服务可以正常工作。一旦帖子大小超过此值,我就会收到 400(错误请求)错误。
出于测试目的,我在 ASP.Net Web 应用程序中创建了一个 test.aspx 文件,该文件将一些表单值和图像发布到 Web 服务。同样,当帖子大小低于默认的 65k 大小时,服务可以正常工作。超过 65k,我收到 400 错误。
测试页面发布到与以下 URITemplate /job-photo/{photoId}/{palladiumId}/{jobId} 匹配的 URL
如果有人能帮我调试这个问题,将不胜感激。
测试页的标记:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" action="http://localhost/cds/resources/services/palladium.svc/job-photo/1/235DE168-5D1C-46A4-89F2-FD17C6B9F415/567" method="post" enctype="multipart/form-data">
<div>
<input type="text" name="user" value="joe bloggs" />
<input type="file" name="photo" />
<input type="submit" name="btnsubmit" value="submit" />
</div>
</form>
</body>
</html>
来自 web.config 的服务信息:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="large_message_binding" maxBufferPoolSize="5242880" maxReceivedMessageSize="5242880">
<readerQuotas maxStringContentLength="5242880" maxArrayLength="5242880" maxBytesPerRead="5242880" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="CDS.UI.Resources.Services.PalladiumBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="CDS.UI.Resources.Services.PalladiumBehavior"
name="CDS.UI.Resources.Services.Palladium">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="large_message_binding" contract="CDS.PalladiumService.IPalladium">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
来自 Palladium.svc
的标记 <%@ ServiceHost Language="C#" Debug="true" Service="CDS.PalladiumService.Palladium" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
【问题讨论】:
标签: wcf asp.net-3.5 wcf-binding