要求是能够使用 WCF 服务上传一个大文件(~2GB),我创建了一个 messageContract 类,如下所示
[MessageContract]
public class TestMessageContract
{
[MessageHeader]
public string FileName { get; set; }
[MessageBodyMember]
public byte[] UploadedFileContent { get; set; }
}
这是我在服务端的网络配置
<wsHttpBinding>
<binding name="wsHttpFileSize" closeTimeout="00:10:00" openTimeout="00:10:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="1073741824" maxReceivedMessageSize="1073741824"
messageEncoding="Mtom"
useDefaultWebProxy="true">
<readerQuotas maxDepth="1073741824" maxArrayLength="1073741824" maxBytesPerRead="1073741824"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="WcfService1.IService1">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpNormal" contract="WcfService1.IService1"/>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpFileSize" contract="WcfService1.IFileUploadService"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:909/"/>
</baseAddresses>
</host>
</service>
</services>
客户端也使用相同的绑定配置这是我在过去 4 小时内遇到的异常。我无法弄清楚问题所在..
异常内容
类型多部分/相关;type="application/xop+xml";start=" http://tempuri.org/0 ";boundary="uuid:382b5a40-f4f2-4399-9e63-b3f9e81227a5+id=2";start-info="application /soap+xml" 不受服务http://localhost:909/Service1.svc的支持。客户端和服务绑定可能不匹配。