Ejemplo n.º 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);
        }
Ejemplo n.º 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]);
            }
        }
Ejemplo n.º 3
0
        public static void TestDecompressMessage(XmlDocument compressedXmlDocument)
        {
            string contents = CommonUtilityHelper.DecompressData(compressedXmlDocument.XmlToBytes());

            XmlDocument decompressedDocument = new XmlDocument();

            decompressedDocument.LoadXml(contents);

            DefaultMessageReader reader = new DefaultMessageReader(loggingService, configurationRepository, decompressedDocument.ToXDocument());

            string[] results = reader.GetMessageResults <string[]>();

            Console.WriteLine(reader.GetQualifier());
        }
Ejemplo n.º 4
0
        public XmlDocument CompressClaim()
        {
            _loggingService.LogInfo(this, "Compressing Claim.");

            XmlElement  bodyElement  = _govTalkMessageBuilder.GovTalkMessage.Body.Any[0];
            XmlDocument bodyDocument = new XmlDocument();

            bodyDocument.LoadXml(bodyElement.OuterXml);

            //deserialize body
            IRenvelope irEnvelope = XmlSerializationHelpers.DeserializeIRenvelope(bodyDocument);

            R68         uncompressedR68 = irEnvelope.R68;
            XmlDocument r68xmlDoc       = XmlSerializationHelpers.SerializeItem(uncompressedR68);

            System.Xml.XmlDocument claimXmlDoc = GovTalkMessageHelper.GetClaim(r68xmlDoc);

            irEnvelope.R68.Items = null;

            R68CompressedPart compressedPart = new R68CompressedPart();

            compressedPart.Type  = R68CompressedPartType.gzip;
            compressedPart.Value = CommonUtilityHelper.CompressData(claimXmlDoc.OuterXml, _loggingService);

            R68CompressedPart[] compressedParts = new R68CompressedPart[1];
            compressedParts[0] = compressedPart;

            irEnvelope.R68.Items = compressedParts;

            bodyElement = XmlSerializationHelpers.SerializeIREnvelope(irEnvelope);

            _govTalkMessageBuilder.GovTalkMessage.Body.Any[0] = null;
            _govTalkMessageBuilder.GovTalkMessage.Body.Any[0] = bodyElement;

            XmlDocument compressedVersion = SerializeGovTalkMessage();

            return(compressedVersion);
        }
Ejemplo n.º 5
0
        public override void SetItems()
        {
            RepaymentBuilder dtRepaymenBuilder = new RepaymentBuilder(_loggingService);

            R68ClaimCreator r68ClaimCreator = new R68ClaimCreator(dtRepaymenBuilder);

            r68ClaimCreator.CreateR68Claim();

            R68Claim[] r68claim = new R68Claim[1];
            r68claim[0] = r68ClaimCreator.GetR68Claim();

            R68.Items = r68claim;

            // Serialize R68 to get XmlDocument with Claim element

            System.Xml.XmlDocument r68xmlDoc = XmlSerializationHelpers.SerializeItem(R68);

            // Then extract Claim itself

            System.Xml.XmlDocument claimXmlDoc = GovTalkMessageHelper.GetClaim(r68xmlDoc);

            // Reset R68 Items

            R68.Items = null;

            // Gzip compress

            R68CompressedPart compressedPart = new R68CompressedPart();

            compressedPart.Type  = R68CompressedPartType.gzip;
            compressedPart.Value = CommonUtilityHelper.CompressData(claimXmlDoc.OuterXml, _loggingService);

            R68CompressedPart[] compressedParts = new R68CompressedPart[1];
            compressedParts[0] = compressedPart;

            R68.Items = compressedParts;
        }