我想要发送到我的WCF WebRole的大量数据存在问题。 我得到(413)太大的数据错误。我是Azure和WCF的新手。我创建了一个新服务,用于将图像发送到WCF(LargeObject.svc)并尝试为其配置绑定和端点。
这是ServerSideCode:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IImage" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
<binding name="BasicHttpBinding_IRouteService"/>
</basicHttpBinding>
<customBinding>
<binding name="CustomBinding_IRouteService">
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRouteService"
contract="Route.IRouteService" name="BasicHttpBinding_IRouteService" />
<endpoint address="http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc/binaryHttp"
binding="customBinding" bindingConfiguration="CustomBinding_IRouteService"
contract="Route.IRouteService" name="CustomBinding_IRouteService" />
<endpoint address="http://127.0.0.1:81/Implementation/LargeObject.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IImage"
contract="ILargeObject" name="BasicHttpBinding_IImageSvc"/>
</client>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
<dataContractSerializer maxItemsInObjectGraph="1048576" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
我在Windows Phone中也有一个客户端应用程序,代码:
string endPointAddress = (Application.Current as TravelerMobile.App).ServerUriString("LargeObject.svc");
LargeObjectClient client = new LargeObjectClient(new BasicHttpBinding(),
new EndpointAddress(endPointAddress));
MemoryStream stream = new MemoryStream();
WriteableBitmap wb = new WriteableBitmap(image);
wb.SaveJpeg(stream, image.PixelWidth, image.PixelHeight, 0, 100);
byte[] byteImage = stream.ToArray();
client.AddImageAsync(new LargeObject.AddImageRequest
{
Image = byteImage,
Latitude = latitude,
Longitude = longitude,
UserId = Helpers.GetUserId()
});
我还尝试通过设置maxRevieved和maxBuffered属性在客户端配置BasicHttpBinding,但它仍然不起作用。
有什么想法吗?
p.s那是一个Windows Azure WCF项目,所以我有一个默认端点 - 但我不知道如何设置为maxReceivedMessageSize。
答案 0 :(得分:0)
我发现stackoverflow上的以下链接有同样的问题,希望它也适合你,Azure WCF Webrole error: The remote server returned an unexpected response: (413) Request Entity Too Large
当您在MaxReceivedMessageSize中传输最大字节数时,我认为您应该在ReaderQuotas标记中执行此操作。
另外一件事,你必须考虑,我不知道你正在使用什么类型的存储,但有一些存储不允许你上传超过4MB的文件。例如,对于每个blockblob,块的最大大小为4 MB,而对于pageblob,最大大小为4 MB。
您也可以在msdn上查看此链接,他们遇到了同样的问题:http://social.msdn.microsoft.com/Forums/en-US/windowsazuredata/thread/39bfad06-97c0-4a98-b9fb-87879bab9414