我在Azure上部署了RESTful WCF服务。其中一个合同操作应该是从客户端上传的图像文件(不大于500kb)。目前,我的解决方案在Azure计算机/存储模拟器中运行时没有任何问题。但是,当我将解决方案部署到Azure时,从客户端上载(图像大小为133kb)失败,413请求实体太大。似乎Azure忽略了我在web.config中设置的配置(在Azure模拟器中正确选取)。
如何解决此问题的任何帮助将受到高度赞赏。以下是我的代码的相关摘要。
接口
namespace HappyBabiesSvc
{
[ServiceContract]
public interface IHappyBabies
[OperationContract]
[WebInvoke(UriTemplate = "/v1.0/locations/{locationID}/images",
Method = "PUT")]
void UploadNewImage(string locationID, Stream imageToUpload);
服务实施
<%@ ServiceHost Language="C#" Debug="true" Service="HappyBabiesSvc.HappyBabiesSvc" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
的Web.config
<system.serviceModel>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint maxReceivedMessageSize="655360"/>
</webHttpEndpoint>
</standardEndpoints>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false"/>
<services>
<service name="HappyBabiesSvc.HappyBabiesSvc" behaviorConfiguration="ServiceConfiguration">
<endpoint address="" binding="webHttpBinding"
name="HappyBabiesService"
contract="HappyBabiesSvc.IHappyBabies" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding maxBufferSize="655360"
maxReceivedMessageSize="655360" transferMode="Streamed">
<readerQuotas maxDepth="655360" maxStringContentLength="655360"
maxArrayLength="655360" maxBytesPerRead="655360" maxNameTableCharCount="655360" />
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
答案 0 :(得分:0)
尝试使用单个参数即Stream的方法。 流参数应该是单独的。
[OperationContract的] [WebInvoke(UriTemplate =“/ v1.0/locations/{locationID}/images",Method =”PUT“)] void UploadNewImage(Stream imageToUpload);