2013-10-13 74 views
1

我通過IIS 8 託管WCF服務的嘗試,我使用Visual Studio 2010中 我得到以下錯誤 我怎麼能提供將寫在服務器上的文件WCF IIS服務文件流遠程服務器返回了意外響應:(400)錯誤的請求。

遠程服務器返回的流文件上傳意外的迴應:(400)錯誤的請求。

web配置

<?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); 
} 
+0

也許表明您的服務合同?甚至可能開始你的服務? –

+0

看起來像我得到了問題,它在綁定,我會很快發佈答案。 – vivek

回答

0

我有問題它在我的配置文件

我需要改變我的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> 
相關問題