Example #1
0
        //public SoapHeader(XmlReader reader)
        //{
        //    ReadXml(reader);
        //}

        public static SoapHeader Deserialize(XmlReader reader)
        {
            //StringReader stringReader = new StringReader(xml);
            //XmlReader reader = XmlReader.Create(stringReader);
            SoapHeader instance = new SoapHeader();

            instance.ReadXml(reader);
            return(instance);
        }
Example #2
0
        protected virtual void ReadXml(XmlReader reader)
        {
            reader.EnsureIsStartElement();
            m_envelopeNS = reader.NamespaceURI;
            if (reader.LocalName != SoapConstant.EnvelopeLocalName)
            {
                throw new ArgumentException("Soap message should start with " + SoapConstant.EnvelopeLocalName + "!");
            }
            //read to Header or body
            reader.ReadStartElement();
            if (reader.LocalName == SoapConstant.SoapHeaderLocalName && reader.NamespaceURI == m_envelopeNS)
            {
                //header
                XmlReader headerReader = reader.ReadSubtree();
                headerReader.ReadStartElement();

                while (headerReader.IsStartElement())
                {
                    XmlReader hdrReader = headerReader.ReadSubtree();
                    //string headerXml = reader.readsReadOuterXml();
                    SoapHeader header = SoapHeader.Deserialize(hdrReader);
                    m_headers.Add(header);
                    headerReader.ReadEndElement();
                    //hdrReader = reader.ReadSubtree();
                }
                //end header and move to body
                //if header is empty
                if (reader.IsStartElement())
                {
                    reader.ReadStartElement();
                }
                else
                {
                    reader.ReadEndElement();
                }
            }
            if (reader.LocalName != SoapConstant.SoapBodyLocalName || reader.NamespaceURI != m_envelopeNS)
            {
                throw new ArgumentException("Miss body element!", "reader");
            }
            reader.ReadStartElement();
        }
Example #3
0
 public void AddHeader(SoapHeader header)
 {
     m_headers.Add(header);
 }