问题
I have a Windows Azure webrole (WCF) webservice. I have a method to upload files to Window Azure blob storage. This works well, but only for small ( < 30 Kb) files.
<OperationContract()>
Function UploadFileV1(ByVal ApplicationSessionGuid As String,
ByVal UserSessionGuid As String,
ByVal FileContent As Byte(),
ByVal FileName As String,
ByVal FileDescription As String,
ByVal FileDisplayName As String,
ByVal IsPublic As Boolean) As DataSet
If this part: ByVal FileContent As Byte()
is bigger than 30 Kb then I get an error when I call the webservice.
The remote server returned an unexpected response: (413) Request Entity Too Large.
If I run this webservice local with debugging and I set a breakpoint on the method it doesn't even get there.
I found some simular topics, but they are not in a Windows Azure context.
The web.config in the WCF project is pretty empty.
回答1:
In the system.serviceModel of the web.config of the (Windows Azure) WCF webrole webservice you can add basicHTTPBinding. The mistake I made was trying to add a name, but without name it appears to be a default. Now it works like a charm. Hope someone else runs into this and find his answer here. It took me four hours.
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed" >
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None">
</security>
</binding>
</basicHttpBinding>
</bindings>
来源:https://stackoverflow.com/questions/14755529/azure-wcf-webrole-error-the-remote-server-returned-an-unexpected-response-413