1

我在 Azure 上部署了一个 RESTful WCF 服务。其中一项合约操作应该是获取从客户端上传的图像文件(不大于 500kb)。目前,我的解决方案在 Azure 计算机/存储模拟器中运行没有任何问题。但是,当我将解决方案部署到 Azure 时,从客户端上传(图像大小为 133kb)失败并显示 413 Request Entity Too Large。似乎 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" %>

网页配置

<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>
4

1 回答 1

0

仅尝试具有单个参数的方法,即 Stream 。流参数应该是单独的。

[OperationContract] [WebInvoke(UriTemplate = "/v1.0/locations/{locationID}/images",Method = "PUT")] void UploadNewImage(Stream imageToUpload);

于 2013-08-08T08:38:02.587 回答