簡體   English   中英

WCF IIS服務文件流式傳輸遠程服務器返回意外響應:(400)錯誤的請求。

[英]WCF IIS service file streaming The remote server returned an unexpected response: (400) Bad Request.

我正在嘗試通過iis 8中托管的wcf服務上傳文件,而我正在使用Visual Studio2010。我在以下錯誤提示下如何提供將在服務器上寫入文件的流

遠程服務器返回了意外的響應:(400)錯誤的請求。

網絡配置

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="false" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
  <basicHttpBinding>
    <binding  name="BasicHttpBinding_IService"
              transferMode="Streamed"
              messageEncoding="Mtom"
              maxReceivedMessageSize="10067108864"
             />
    </basicHttpBinding>
    </bindings>
    <behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

應用配置

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IService"
                     maxReceivedMessageSize="10067108864"
                     transferMode="Streamed"/>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost/FileService/Service.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
            contract="ServiceReference1.IService" name="BasicHttpBinding_IService" />
    </client>
</system.serviceModel>
</configuration>

[ServiceContract]
public interface IService
{
[OperationContract]
void UploadFile(System.IO.Stream fstream);
}

我在配置文件中遇到了問題

我需要如下更改我的Web配置

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding maxReceivedMessageSize="999999999" transferMode="Streamed" messageEncoding="Mtom"/>
  </basicHttpBinding>  
</bindings>

和應用程序配置如下

 <system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IFileService" maxReceivedMessageSize="10485760"  transferMode="Streamed" messageEncoding="Mtom"/>
        </basicHttpBinding>
    </bindings>
    <client>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM