Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net WCF错误MTOM编码+;将大数据从客户端发送到服务_.net_Wcf_Mtom - Fatal编程技术网

.net WCF错误MTOM编码+;将大数据从客户端发送到服务

.net WCF错误MTOM编码+;将大数据从客户端发送到服务,.net,wcf,mtom,.net,Wcf,Mtom,我正在MSDN上试用 我尝试使用FileStream和WCF发送文件 当我发送只有几个字节的小文件时,我得到了输出。但是,当我试图通过一个只有几MB大小的文件进行发送时,我遇到了一个错误: System.ServiceModel.CommunicationException:错误(请求被中止:请求被取消) 我已经更改了绑定中的最大值,并将其设置为更大的值。我还更改了超时时间。我已启用跟踪,但在跟踪中未发现任何错误 我想不出这个问题。有人能帮忙吗 这是服务。。配置文件 <behaviors&

我正在MSDN上试用

我尝试使用FileStream和WCF发送文件

当我发送只有几个字节的小文件时,我得到了输出。但是,当我试图通过一个只有几MB大小的文件进行发送时,我遇到了一个错误:


System.ServiceModel.CommunicationException:错误(请求被中止:请求被取消)

我已经更改了绑定中的最大值,并将其设置为更大的值。我还更改了超时时间。我已启用跟踪,但在跟踪中未发现任何错误

我想不出这个问题。有人能帮忙吗

这是服务。。配置文件

<behaviors>
  <serviceBehaviors>
    <behavior name="wsHttpServiceBehavior">
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <serviceMetadata httpGetEnabled="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

<bindings>
  <wsHttpBinding>
    <binding name="customWsHttpBinding" messageEncoding="Mtom"
             openTimeout="00:10:00"  maxReceivedMessageSize="2147483647"
             closeTimeout="00:10:00"
             receiveTimeout="00:10:00"
             sendTimeout="00:10:00">
      <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxNameTableCharCount="16384"/>
    </binding>       
  </wsHttpBinding>
</bindings>

<services>
  <service name="MTOMUploadService.UploadService" behaviorConfiguration="wsHttpServiceBehavior">
    <endpoint address="mex" contract="IMetadataExchange" binding="wsHttpBinding"/>
    <endpoint contract="MTOMUploadService.IUploadService" binding="wsHttpBinding"  bindingConfiguration="customWsHttpBinding" />
  </service>
</services>


这是客户端配置

<system.serviceModel>

    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IUploadService" closeTimeout="00:10:00"
                openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
                messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="Message">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true"
                        algorithmSuite="Default" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://machinename:4575/MTOMUploadService.svc"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IUploadService"
            contract="IUploadService" name="WSHttpBinding_IUploadService">
            <identity>
                <servicePrincipalName value="machinename" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

只需将其放入您的wcf web.config:

<system.web>
  <httpRuntime maxRequestLength="2097151" />
</system.web>


您是否更改了客户端和服务绑定上的消息大小?这很有帮助。乍一看,我没有发现你的配置有任何问题。您必须对CommunicationException进行更深入的挖掘,并告诉我们堆栈跟踪的相关位等。此外,它还可以帮助启用跟踪,并检查发送的消息是否确实是MTOM编码的。System.ServiceModel.CommunicationException-基础连接已关闭:服务器已关闭预期保持活动状态的连接。-->System.Net.WebException:基础连接已关闭:远程主机关闭了预期保持活动状态的连接。-->System.IO.IOException:无法从传输连接读取数据:远程主机强制关闭了现有连接。-->System.Net.Sockets.SocketException:远程主机强制关闭了现有连接@Jeroen这里有一个例外我还得到了另一个例外-System.SeviceModel.CommunicationException-当我试图发送一个15 MB的文件时,通过HTTP通道发送数据时发生了一个错误。最好在问题中发布相关的例外信息,它可能对任何试图回答它的人都有用。此外,请告诉我们您是如何托管该服务的?这可能有一个限制。此外,您能否具体说明阈值的位置(MB方面)?