首页 新闻 搜索 专区 学院

关于WCF 文件上传问题 。

0
[待解决问题]

最近在做WCF文件上传,一开始能否上传下于64K的文件,后来我修改了配置文件,结果报错为

“远程服务器返回了意外响应: (400) Bad Request” 和 “套接字连接已中止。这可能是由于处理消息时出错或远程主机超过接收超时或者潜在的网络资源问题导致的” 两个错误。

下面我为这两个问题贴出具体配置代码,求大神指点。感激不尽。

/******************只能上传小于64KB文件***********************/

<!--客户端配置-->

      <basicHttpBinding>
        <binding name="FileOperateUtilBinding" closeTimeout="00:10:00"
               openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:20:00"
               allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
               maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
               messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
               useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
              maxBytesPerRead="4096" maxNameTableCharCount="2147483647"/>
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>   

        <behavior name="FileOperateBehavior">
          <clientCredentials>
            <serviceCertificate>
              <authentication certificateValidationMode="None"/>
            </serviceCertificate>
          </clientCredentials>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>

        <!--附件上传下载服务-->
        <endpoint address="http://localhost:6080/Affix/FileOperateUtil.svc" binding="basicHttpBinding" bindingConfiguration="FileOperateUtilBinding"
contract="SklEIP.Facade.IFileOperateUtil" name="BasicHttpBinding_IFileOperateUtil">
                <identity>
              <dns value="localhost" />
            </identity>
        </endpoint>

    <!--EndPointConfig-->
        public const string FileOperateUtil = "BasicHttpBinding_IFileOperateUtil"; 


<!--服务端配置-->

       <basicHttpBinding>
        <binding name="FileOperateUtilBinding"  closeTimeout="00:10:00" receiveTimeout="00:20:00" sendTimeout="00:20:00"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
        </binding>
       </basicHttpBinding>

       <behavior name="FileOperateBehavior">
          <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
       </behavior>

      <!--附件上传下载服务-->
      <service behaviorConfiguration="FileOperateBehavior"   name="SklEIP.WCFLibrary.FileOperateUtil">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="FileOperateUtilBinding" contract="SklEIP.Facade.IFileOperateUtil">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>

/******************只能上传小于64KB文件***********************/
/*************************目前配置*************************************/
<!--客户端配置-->
      <basicHttpBinding>
        <binding name="FileOperateUtilBinding" closeTimeout="00:01:00"
             openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
             allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
             maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="9223372036854775807"
             messageEncoding="Mtom" textEncoding="utf-8" transferMode="Streamed"
             useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
           maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
             realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>

        <behavior name="FileOperateBehavior">
          <clientCredentials>
            <serviceCertificate>
              <authentication certificateValidationMode="None"/>
            </serviceCertificate>
          </clientCredentials>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>

      <endpoint address="http://localhost:6080/Affix/FileOperateUtilService.svc" binding="basicHttpBinding" bindingConfiguration="CustomWsHttpBinding"
contract="SklEIP.Facade.IFileOperateUtil" name="BasicHttpBinding_IFileOperateUtilService">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>

<!--服务端配置-->
      <basicHttpBinding>
          <binding name="FileOperateUtilBinding" maxReceivedMessageSize="2147483647" messageEncoding="Mtom" transferMode="Streamed" sendTimeout="00:10:00">         
          </binding>
        </basicHttpBinding>

      <behavior name="FileOperateBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>

      <!--附件上传下载服务-->
      <service behaviorConfiguration="FileOperateBehavior"   name="SklEIP.WCFLibrary.FileOperateUtilService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="FileOperateUtilBinding" contract="SklEIP.Facade.IFileOperateUtil">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
/*************************目前配置*************************************/

 

xuliyuan173的主页 xuliyuan173 | 菜鸟二级 | 园豆:249
提问于:2015-10-28 15:27
< >
分享
所有回答(1)
0

修改了什么?

Firen | 园豆:5483 (大侠五级) | 2015-10-29 16:48

messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"

messageEncoding="Mtom" textEncoding="utf-8" transferMode="Streamed"

 

支持(0) 反对(0) xuliyuan173 | 园豆:249 (菜鸟二级) | 2015-10-29 16:49
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册