【问题标题】:WCF IIS service file streaming The remote server returned an unexpected response: (400) Bad Request.WCF IIS 服务文件流式传输远程服务器返回意外响应:(400) 错误请求。
【发布时间】:2013-10-13 04:39:24
【问题描述】:

我正在尝试通过 iis 8 中托管的 wcf 服务上传文件 我正在使用视觉工作室 2010。 我得到以下错误 我如何提供将在服务器上写入文件的流

远程服务器返回了意外响应:(400) Bad Request。

网络配置

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

【问题讨论】:

  • 可以出示您的服务合同吗?甚至可能是您服务的开始?
  • 看来我遇到了问题,正在绑定中,我会尽快发布答案。

标签: .net wcf iis


【解决方案1】:

问题出在我的配置文件中

我需要如下更改我的网络配置

<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>

【讨论】:

    猜你喜欢
    • 2013-01-13
    • 1970-01-01
    • 2019-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-27
    • 1970-01-01
    相关资源
    最近更新 更多