我有一个控制台应用程序将文件发送到我的WCF服务,但我的服务正在响应502 http代码(代理错误 - 指定的网络名称不再可用。)当我尝试发送大于4MB的文件时。这段代码对我来说没有意义,因为他接受的文件小于4MB。
WCF服务在Windows 2003 Server,IIS 6和配置文件下运行,如下所示。
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="FileUploadServiceBehavior">
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="False" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<!-- buffer: 64KB; max size: 64MB -->
<binding name="FileUploadServiceBinding"
transferMode="Streamed"
messageEncoding="Mtom"
maxReceivedMessageSize="67108864" maxBufferSize="65536"
closeTimeout="00:05:00" openTimeout="00:05:00"
receiveTimeout="00:10:00" sendTimeout="00:05:00">
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="FileUploadServiceBehavior" name="MyProject.ServiceFileTransfer.FileUploadService">
<endpoint address="" binding="basicHttpBinding" contract="MyProject.ServiceFileTransfer.IFileUploadService"
bindingConfiguration="FileUploadServiceBinding">
</endpoint>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
为什么在发送大于4mb的文件时会返回502 Bad Gateway错误?
答案 0 :(得分:1)
默认限制为4mb。您需要将文件拆分为较小的部分。
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/f6541134-2e08-4eb9-987b-2158fb99b403/
或更改MaxMessageLength