【发布时间】: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);
}
【问题讨论】:
-
可以出示您的服务合同吗?甚至可能是您服务的开始?
-
看来我遇到了问题,正在绑定中,我会尽快发布答案。