使用MessageContract进行WCF MTOM消息编码

时间:2011-11-11 17:29:58

标签: wcf mtom

要求是能够使用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小时内获得的异常。我无法解决问题..

例外内容

输入multipart / related;类型= “应​​用/ XOP + xml” 的;开始= “http://tempuri.org/0”;边界= “UUID:382b5a40-f4f2-4399-9e63-b3f9e81227a5 + ID = 2”;启动信息=“应用/肥皂+ xml的“服务http://localhost:909/Service1.svc不支持。客户端和服务绑定可能不匹配。

0 个答案:

没有答案