private void ParseXRoadHeader(XRoadMessage target, XmlReader reader, IServiceManager serviceManager)
        {
            if (!messageFormatter.TryMoveToHeader(reader))
            {
                return;
            }

            var header      = serviceManager?.CreateHeader();
            var xRoadHeader = header as IXRoadHeader;

            var unresolved = new List <XElement>();

            while (reader.MoveToElement(2))
            {
                if (serviceManager == null)
                {
                    serviceManager = serviceManagers.SingleOrDefault(p => p.IsHeaderNamespace(reader.NamespaceURI));
                    header         = serviceManager?.CreateHeader();
                    xRoadHeader    = header as IXRoadHeader;
                }

                if (serviceManager == null || xRoadHeader == null || !serviceManager.IsHeaderNamespace(reader.NamespaceURI))
                {
                    unresolved.Add((XElement)XNode.ReadFrom(reader));
                    continue;
                }

                xRoadHeader.ReadHeaderValue(reader);
            }

            xRoadHeader?.Validate();

            target.Header            = header;
            target.UnresolvedHeaders = unresolved;
            target.ServiceManager    = serviceManager;
        }