C# 无法分析MTOM响应

C# 无法分析MTOM响应,c#,wcf,mtom,C#,Wcf,Mtom,我正在使用一个第三方web服务,该服务返回一个使用MTOM编码附加PDF的对象 对象的结构为Data[],每个数组元素都有字段ContentType和Include 当我运行web服务方法时,它很好地完成了请求,但是它没有正确地解析响应,因为Include字段被解析为null 当我运行Fiddler时,我实际上可以看到远程web服务返回一个包含所有可用字段的响应 这是SOAP中发送的内容: 我看到Include具有名为href的属性,其中包含对二进制PDF文档的引用 我正在尝试根据WSDL解

我正在使用一个第三方web服务,该服务返回一个使用MTOM编码附加PDF的对象

对象的结构为
Data[]
,每个数组元素都有字段
ContentType
Include

当我运行web服务方法时,它很好地完成了请求,但是它没有正确地解析响应,因为Include字段被解析为
null

当我运行Fiddler时,我实际上可以看到远程web服务返回一个包含所有可用字段的响应

这是SOAP中发送的内容:


我看到
Include
具有名为
href
的属性,其中包含对二进制PDF文档的引用

我正在尝试根据WSDL解析对象:

Data[] retObject = null;
using (blahWS ws = new blahWS())
{
 try{
retObject = ws.GetDoc(parameters); //request completes with no errors, but `Include` is parse as null
[...]
   }
catch
{..}
 }
web服务引用与一个简单的
basicHttpBinding


我应该以不同的方式解析响应吗?为什么不解析字段

编辑:

完整SOAP响应:

HTTP/1.1200正常
服务器:gSOAP/2.7
内容类型:多部分/相关;字符集=utf-8;boundary=“==nGpzR/KspN6ry7jG8CU4bonN2aujzfJamyN3xYjaldFXYpeUryNGb0UROC0B==”;type=“应用程序/xop+xml”;start=“”;start info=“text/xml”
内容长度:180557
连接:关闭
--==nGpzR/KSPN6RY7JG8CU4BON2AUJZFJAMYN3XYPEURYNGB0UROC0B==
内容类型:应用程序/xop+xml;字符集=utf-8;type=“text/xml”
内容传输编码:二进制
内容ID:

-->=nGpzR/kspn6ry7jg8cu4bonn2aujzfjamy3xyjaldfxypeuryngb0uroc0b==
内容类型:*/*
内容传输编码:二进制
内容ID:
…二进制。。。
使用提供的WSDL构建的数据定义:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.233")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.mcleodsoftware.com/schemas/ws4v.xsd")]
public partial class Data : object, System.ComponentModel.INotifyPropertyChanged {

    private Include includeField;

    private string contentTypeField;

    /// <remarks/>
    [System.Xml.Serialization.XmlElementAttribute(Namespace="http://www.w3.org/2004/08/xop/include", Order=0)]
    public Include Include {
        get {
            return this.includeField;
        }
        set {
            this.includeField = value;
            this.RaisePropertyChanged("Include");
        }
    }
[System.CodeDom.Compiler.GeneratedCodeAttribute(“System.Xml”,“4.0.30319.233”)]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute(“代码”)]
[System.Xml.Serialization.XmlTypeAttribute(命名空间=”http://www.mcleodsoftware.com/schemas/ws4v.xsd")]
公共部分类数据:对象,System.ComponentModel.INotifyPropertyChanged{
私人包括includeField;
私有字符串contentTypeField;
/// 
[System.Xml.Serialization.XmlElementAttribute(命名空间=”http://www.w3.org/2004/08/xop/include“,顺序=0)]
公众包括{
得到{
返回此。includeField;
}
设置{
此.includeField=值;
本.增加财产变更(“包括”);
}
}

您的WSDL似乎明确地为元素提供了模式。我很确定这是错误的,并且不符合标准。元素应该声明为xsd:base64Binary类型(例如,请参见),并且您的WSDL中还有其他符合标准的方式来表示您正在使用MTOM(例如,请参见)


如果您将WSDL修改为符合标准(或者至少符合WCF期望的“MTOM WSDL”外观),我认为一切都应该正常工作看起来,只要先在WCF中创建一个简单的MTOM服务代码-例如-并查看它生成的WSDL和XSD。

如果使用标准MTOM,那么只要您将消息编码设置为MTOM,您就不需要解析,附件将在响应对象中可用。您可以提供整个SOAP消息吗(或者更好的是,除了编码附件之外的整个MIME消息?)此外,请提供相关的ServiceContract/DataContract定义。您需要确保要进行MTOM解码的DataMember的类型为byte[]@EugeneOsovetsky我添加了SOAP响应和对象定义。我没有自己的数据联系人,我使用的是WSDL构建的联系人。