C#SOAP Web服务无法在响应XML中的复杂对象引用进行挑选

发布于 2025-02-13 15:33:47 字数 6126 浏览 1 评论 0原文

我尝试食用肥皂服务,并且可以很好地适合某些功能。但是,当我在响应xml中获得对象引用的结果更为复杂时,序列化失败了:“ XML文档中的错误在2,991”,内部例外是:文档中未找到带有ID'2'的引用元素。如您在以下XML响应中所见,他发现了一个已准备就绪的一个参考,但是找不到对象的第二个参考。

这是

    <?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:NS1="urn:LagerVerwaltungIntf-ILagerVerwaltung">
      <NS2:TLagerortResult id="1" xmlns:NS2="urn:LagerVerwaltungIntf" xsi:type="NS2:TLagerortResult">
        <Status xsi:type="xsd:int">1</Status>
        <Msg xsi:type="xsd:string">
        </Msg>
        <Lagerort href="#2" />
      </NS2:TLagerortResult>
      <NS2:Lagerort id="2" xsi:type="NS2:TLagerort">
        <LagerCode xsi:type="xsd:string">L1001001</LagerCode>
        <LagerName xsi:type="xsd:string">Lager 1</LagerName>
        <LagerTyp xsi:type="xsd:string">LagerPlatz</LagerTyp>
        <LagerGemeinde xsi:type="xsd:string">Test</LagerGemeinde>
        <LagerBetrieb xsi:type="xsd:string">Gut Test</LagerBetrieb>
      </NS2:Lagerort>
      <return href="#1" />
  </SOAP-ENV:Body>

从Reference.cs

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.3761.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.SoapTypeAttribute(Namespace="urn:LagerVerwaltungIntf")]
    public partial class TLagerort {

        private string lagerCodeField;
        
        private string lagerNameField;
        
        private string lagerTypField;
        
        private string lagerGemeindeField;
        
        private string lagerBetriebField;
        
         /// <remarks/>
        public string LagerCode {
            get {
                return this.lagerCodeField;
            }
            set {
                this.lagerCodeField = value;
            }
        }
        
        /// <remarks/>
        public string LagerName {
            get {
                return this.lagerNameField;
            }
            set {
                this.lagerNameField = value;
            }
        }
        
        /// <remarks/>
        public string LagerTyp {
            get {
                return this.lagerTypField;
            }
            set {
                this.lagerTypField = value;
            }
        }
        
        /// <remarks/>
        public string LagerGemeinde {
            get {
                return this.lagerGemeindeField;
            }
            set {
                this.lagerGemeindeField = value;
            }
        }
        
        /// <remarks/>
        public string LagerBetrieb {
            get {
                return this.lagerBetriebField;
            }
            set {
                this.lagerBetriebField = value;
            }
        }
    }
    
    /// <remarks/>
    [System.Xml.Serialization.SoapIncludeAttribute(typeof(TKisteResult))]
    [System.Xml.Serialization.SoapIncludeAttribute(typeof(TCodesResult))]
    [System.Xml.Serialization.SoapIncludeAttribute(typeof(TLagerortResult))]
    [System.Xml.Serialization.SoapIncludeAttribute(typeof(TPartieResult))]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.3761.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.SoapTypeAttribute(Namespace="urn:LagerVerwaltungIntf")]
    public partial class TResult {
        
        private int statusField;
        
        private string msgField;
        
        /// <remarks/>
        public int Status {
            get {
                return this.statusField;
            }
            set {
                this.statusField = value;
            }
        }
        
        /// <remarks/>
        public string Msg {
            get {
                return this.msgField;
            }
            set {
                this.msgField = value;
            }
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.3761.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.SoapTypeAttribute(Namespace="urn:LagerVerwaltungIntf")]
    public partial class TCodesResult : TResult {
        
        private string[] codesField;
        
        /// <remarks/>
        public string[] Codes {
            get {
                return this.codesField;
            }
            set {
                this.codesField = value;
            }
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.3761.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.SoapTypeAttribute(Namespace="urn:LagerVerwaltungIntf")]
    [System.Runtime.Remoting.Metadata.SoapType(XmlNamespace = "urn:LagerVerwaltungIntf")]
    public partial class TLagerortResult : TResult {

        private TLagerort lagerortField;
        
        /// <remarks/>
        public TLagerort Lagerort {
            get {
                return this.lagerortField;
            }
            set {
                this.lagerortField = value;
            }
        }
    }

链接到wsdl

有任何特定的特定特定的 特定特定的链接,这是来自Reference.cs

I try to consume a SOAP service and it works fine for some functions. But when I get a more complex result with object references in the response xml the serialization fails with the error: "Error in Xml Document at 2,991" and the inner exception is : The referenced element with ID '2' was not found in the document. As you see in the following XML-Response he found allready one reference, but the 2nd one to the object couldn't be found.

This is the incoming XML-Response

    <?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:NS1="urn:LagerVerwaltungIntf-ILagerVerwaltung">
      <NS2:TLagerortResult id="1" xmlns:NS2="urn:LagerVerwaltungIntf" xsi:type="NS2:TLagerortResult">
        <Status xsi:type="xsd:int">1</Status>
        <Msg xsi:type="xsd:string">
        </Msg>
        <Lagerort href="#2" />
      </NS2:TLagerortResult>
      <NS2:Lagerort id="2" xsi:type="NS2:TLagerort">
        <LagerCode xsi:type="xsd:string">L1001001</LagerCode>
        <LagerName xsi:type="xsd:string">Lager 1</LagerName>
        <LagerTyp xsi:type="xsd:string">LagerPlatz</LagerTyp>
        <LagerGemeinde xsi:type="xsd:string">Test</LagerGemeinde>
        <LagerBetrieb xsi:type="xsd:string">Gut Test</LagerBetrieb>
      </NS2:Lagerort>
      <return href="#1" />
  </SOAP-ENV:Body>

Here the specified object from the Reference.cs

    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.3761.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.SoapTypeAttribute(Namespace="urn:LagerVerwaltungIntf")]
    public partial class TLagerort {

        private string lagerCodeField;
        
        private string lagerNameField;
        
        private string lagerTypField;
        
        private string lagerGemeindeField;
        
        private string lagerBetriebField;
        
         /// <remarks/>
        public string LagerCode {
            get {
                return this.lagerCodeField;
            }
            set {
                this.lagerCodeField = value;
            }
        }
        
        /// <remarks/>
        public string LagerName {
            get {
                return this.lagerNameField;
            }
            set {
                this.lagerNameField = value;
            }
        }
        
        /// <remarks/>
        public string LagerTyp {
            get {
                return this.lagerTypField;
            }
            set {
                this.lagerTypField = value;
            }
        }
        
        /// <remarks/>
        public string LagerGemeinde {
            get {
                return this.lagerGemeindeField;
            }
            set {
                this.lagerGemeindeField = value;
            }
        }
        
        /// <remarks/>
        public string LagerBetrieb {
            get {
                return this.lagerBetriebField;
            }
            set {
                this.lagerBetriebField = value;
            }
        }
    }
    
    /// <remarks/>
    [System.Xml.Serialization.SoapIncludeAttribute(typeof(TKisteResult))]
    [System.Xml.Serialization.SoapIncludeAttribute(typeof(TCodesResult))]
    [System.Xml.Serialization.SoapIncludeAttribute(typeof(TLagerortResult))]
    [System.Xml.Serialization.SoapIncludeAttribute(typeof(TPartieResult))]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.3761.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.SoapTypeAttribute(Namespace="urn:LagerVerwaltungIntf")]
    public partial class TResult {
        
        private int statusField;
        
        private string msgField;
        
        /// <remarks/>
        public int Status {
            get {
                return this.statusField;
            }
            set {
                this.statusField = value;
            }
        }
        
        /// <remarks/>
        public string Msg {
            get {
                return this.msgField;
            }
            set {
                this.msgField = value;
            }
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.3761.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.SoapTypeAttribute(Namespace="urn:LagerVerwaltungIntf")]
    public partial class TCodesResult : TResult {
        
        private string[] codesField;
        
        /// <remarks/>
        public string[] Codes {
            get {
                return this.codesField;
            }
            set {
                this.codesField = value;
            }
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.8.3761.0")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.SoapTypeAttribute(Namespace="urn:LagerVerwaltungIntf")]
    [System.Runtime.Remoting.Metadata.SoapType(XmlNamespace = "urn:LagerVerwaltungIntf")]
    public partial class TLagerortResult : TResult {

        private TLagerort lagerortField;
        
        /// <remarks/>
        public TLagerort Lagerort {
            get {
                return this.lagerortField;
            }
            set {
                this.lagerortField = value;
            }
        }
    }

link to the WSDL

Is there any specific setting or something else that the service can deserialize the object?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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