使用 MessageContract 的 WCF MTOM 消息编码
要求是能够使用 WCF 服务上传大文件(~2GB),我创建了一个 messageContract 类,如下所示
[MessageContract]
public class TestMessageContract
{
[MessageHeader]
public string FileName { get; set; }
[MessageBodyMember]
public byte[] UploadedFileContent { get; set; }
}
,这是我在服务端的 Web 配置
<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服务 http://localhost:909/Service1.svc。客户端和服务绑定可能不匹配。
The requirement is to be able to upload a big file(~2GB) using a WCF service and I have created a messageContract class as follows
[MessageContract]
public class TestMessageContract
{
[MessageHeader]
public string FileName { get; set; }
[MessageBodyMember]
public byte[] UploadedFileContent { get; set; }
}
and here is my web config on the service side
<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>
The same binding configuration is used on the client side as well And here is the exception I am getting for the last 4 hours. I Couldn't figure the problem out..
Exception Content
Type multipart/related; type="application/xop+xml";start="http://tempuri.org/0";boundary="uuid:382b5a40-f4f2-4399-9e63-b3f9e81227a5+id=2";start-info="application/soap+xml" was not supported by service http://localhost:909/Service1.svc. The client and service bindings may be mismatched.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论