使用 MessageContract 的 WCF MTOM 消息编码

发布于 2024-12-15 10:36:53 字数 2004 浏览 1 评论 0原文

要求是能够使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文