Пример #1
0
        public static XmlDocument TestDeserializeAndDecompress(XmlDocument xd)
        {
            GovTalkMessage gtm = XmlSerializationHelpers.DeserializeMessage(xd);

            XmlElement xelement = gtm.Body.Any[0];

            // XmlDocument bodyDoc = xelement.OwnerDocument;
            XmlDocument bodyDoc = new XmlDocument();

            bodyDoc.LoadXml(xelement.OuterXml);

            IRenvelope ire = XmlSerializationHelpers.DeserializeIRenvelope(bodyDoc);

            R68CompressedPart compressedPart = (R68CompressedPart)ire.R68.Items[0];

            string decompressedClaim    = CommonUtilityHelper.DecompressData(compressedPart.Value);
            string decompressedR68Claim = decompressedClaim.Replace("Claim", "R68Claim");

            XmlDocument r68claim = new XmlDocument();

            r68claim.LoadXml(decompressedR68Claim);
            r68claim.DocumentElement.SetAttribute("xmlns", "http://www.govtalk.gov.uk/taxation/charities/r68/2");

            R68Claim uncompressedR68 = XmlSerializationHelpers.Deserialize <R68Claim>(r68claim.OuterXml, "R68Claim");

            // XmlSerializationHelpers.DeserializeR68Claim(r68claim);

            ire.R68.Items[0] = uncompressedR68;

            gtm.Body.Any[0] = XmlSerializationHelpers.SerializeIREnvelope(ire);

            XmlDocument SerializedDecompressedGovTalkMessage = XmlSerializationHelpers.SerializeGovTalkMessage(gtm);

            return(SerializedDecompressedGovTalkMessage);
        }
Пример #2
0
        private R68Claim GetClaim(object[] R68Items)
        {
            if (R68Items[0] is R68CompressedPart)
            {
                R68CompressedPart compressedPart = (R68CompressedPart)_body.R68.Items[0];

                string      decompressedData = CommonUtilityHelper.DecompressData(compressedPart.Value);
                XmlDocument decompressedXml  = new XmlDocument();
                decompressedXml.LoadXml(decompressedData);

                // decompressedXml.DocumentElement.SetAttribute("xmlns", "http://www.govtalk.gov.uk/taxation/charities/r68/2");

                XmlDocument r68ClaimXmlDoc = new XmlDocument();
                XmlElement  r68root        = r68ClaimXmlDoc.CreateElement("R68Claim");
                r68root.SetAttribute("xmlns", "http://www.govtalk.gov.uk/taxation/charities/r68/2");
                r68ClaimXmlDoc.AppendChild(r68root);
                r68root.InnerXml = decompressedXml.DocumentElement.InnerXml;

                return(XmlSerializationHelpers.Deserialize <R68Claim>(r68ClaimXmlDoc.OuterXml, "R68Claim"));
            }
            else
            {
                return((R68Claim)R68Items[0]);
            }
        }
Пример #3
0
        public static void TestDeserializeClaim()
        {
            XmlDocument claimXml = new XmlDocument();

            claimXml.Load(@"C:\Temp\R68Claim.xml");

            // Add namesapce to Xml
            // e.g. claimXml.DocumentElement.SetAttribute("xmlns","http://www.govtalk.gov.uk/taxation/charities/r68/2");

            // R68Claim r68claim = XmlSerializationHelpers.DeserializeR68Claim(claimXml);

            R68Claim otherway = XmlSerializationHelpers.Deserialize <R68Claim>(claimXml.OuterXml, "R68Claim");
        }