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); }
// read message into datatable of donations ? // what do we want to do when we read in a Submit Request - recreate the input datatables (donations & otherincome) // list of the reference values public void ReadMessage(XDocument inXD) { _message = XmlSerializationHelpers.DeserializeMessage(inXD.ToXmlDocument()); _messageRead = true; _qualifier = _message.Header.MessageDetails.Qualifier.ToString(); _function = _message.Header.MessageDetails.Function.ToString(); XmlElement xmlElement = _message.Body.Any[0]; XmlDocument bodyDoc = new XmlDocument(); bodyDoc.LoadXml(xmlElement.OuterXml); _body = XmlSerializationHelpers.DeserializeIRenvelope(bodyDoc); if (_body.R68.Items[0].GetType() == typeof(R68CompressedPart)) { _hasCompressedPart = true; } else { _hasCompressedPart = false; } _loggingService.LogInfo(this, "Message read. Message is SubmitRequest."); }
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); }