diff --git a/src/FasTnT.Host/Features/v1_2/Communication/Formatters/XmlResponseFormatter.cs b/src/FasTnT.Host/Features/v1_2/Communication/Formatters/XmlResponseFormatter.cs index 9249843f..cec235cb 100644 --- a/src/FasTnT.Host/Features/v1_2/Communication/Formatters/XmlResponseFormatter.cs +++ b/src/FasTnT.Host/Features/v1_2/Communication/Formatters/XmlResponseFormatter.cs @@ -36,6 +36,16 @@ public static XElement FormatPoll(PollResult response) new XElement("resultsBody", new XElement(resultName, resultList)) ); + if (response.EventList?.Count > 0) + { + var customNamespaces = response.EventList.SelectMany(x => x.Fields.Select(x => x.Namespace)).Where(IsCustomNamespace).Distinct().ToArray(); + + for (var i = 0; i < customNamespaces.Length; i++) + { + queryResults.Add(new XAttribute(XNamespace.Xmlns + $"ext{i}", customNamespaces[i])); + } + } + return queryResults; } @@ -94,4 +104,9 @@ public static XElement FormatSubscribeResponse() { return new(XName.Get("SubscribeResult", Namespaces.Query)); } + + private static bool IsCustomNamespace(string value) + { + return !string.IsNullOrWhiteSpace(value) && XNamespace.Xmlns != value; + } } diff --git a/src/FasTnT.Host/Subscriptions/Formatters/XmlSubscriptionFormatter.cs b/src/FasTnT.Host/Subscriptions/Formatters/XmlSubscriptionFormatter.cs index 71596e66..4f25477e 100644 --- a/src/FasTnT.Host/Subscriptions/Formatters/XmlSubscriptionFormatter.cs +++ b/src/FasTnT.Host/Subscriptions/Formatters/XmlSubscriptionFormatter.cs @@ -22,7 +22,7 @@ public string FormatResult(string name, QueryResponse response) new XElement("queryName", response.QueryName), new XElement("subscriptionID", name), new XElement("resultsBody", new XElement("EventList", XmlEventFormatter.FormatList(response.EventList)))); - var attributes = new[] { new XAttribute("creationDate", DateTime.UtcNow), new XAttribute("schemaVersion", "1") }; + var attributes = new[] { new XAttribute("creationDate", DateTime.UtcNow), new XAttribute("schemaVersion", "1.2") }; return new XElement(rootName, attributes, new XElement("EPCISBody", content)).ToString(SaveOptions.DisableFormatting); }