WCF服务返回502 Http代码(指定的网络名称不再可用)
本文关键字:网络 不再 返回 服务 Http 代码 WCF | 更新日期: 2023-09-27 18:19:03
我有一个控制台应用程序发送文件到我的WCF服务,但是当我试图发送大于4MB的文件时,我的服务响应502 http代码(代理错误-指定的网络名称不再可用)。这段代码对我来说没有意义,因为他接受小于4MB的文件。
WCF服务运行在Windows 2003服务器,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错误?
默认限制为4mb。您要么需要将文件分割成更小的部分。
http://social.msdn.microsoft.com/forums/en us/wcf/thread/f6541134 - 2 - e08 4 eb9 - 987 b - 2158 fb99b403/
或者改变MaxMessageLength
Large Binary (byte[])通过WCF传输文件