/// <summary>
        /// Reads the response.
        /// </summary>
        /// <param name="ewsXmlReader">The XML reader.</param>
        /// <param name="responseHeaders">HTTP response headers</param>
        /// <returns>Service response.</returns>
        protected async Task <object> ReadResponseAsync(EwsServiceXmlReader ewsXmlReader, WebHeaderCollection responseHeaders, CancellationToken token)
        {
            object serviceResponse;

            await this.ReadPreambleAsync(ewsXmlReader, token);

            await ewsXmlReader.ReadStartElementAsync(XmlNamespace.Soap, XmlElementNames.SOAPEnvelopeElementName, token);

            await this.ReadSoapHeaderAsync(ewsXmlReader, token);

            await ewsXmlReader.ReadStartElementAsync(XmlNamespace.Soap, XmlElementNames.SOAPBodyElementName, token);

            await ewsXmlReader.ReadStartElementAsync(XmlNamespace.Messages, this.GetResponseXmlElementName(), token);

            if (responseHeaders != null)
            {
                serviceResponse = this.ParseResponse(ewsXmlReader, responseHeaders);
            }
            else
            {
                serviceResponse = this.ParseResponse(ewsXmlReader);
            }

            ewsXmlReader.ReadEndElementIfNecessary(XmlNamespace.Messages, this.GetResponseXmlElementName());

            await ewsXmlReader.ReadEndElementAsync(XmlNamespace.Soap, XmlElementNames.SOAPBodyElementName, token);

            await ewsXmlReader.ReadEndElementAsync(XmlNamespace.Soap, XmlElementNames.SOAPEnvelopeElementName, token);

            return(serviceResponse);
        }
        /// <summary>
        /// Read SOAP header and extract server version
        /// </summary>
        /// <param name="reader">EwsServiceXmlReader</param>
        private async System.Threading.Tasks.Task ReadSoapHeaderAsync(EwsServiceXmlReader reader, CancellationToken token)
        {
            await reader.ReadStartElementAsync(XmlNamespace.Soap, XmlElementNames.SOAPHeaderElementName, token);

            do
            {
                await reader.ReadAsync(token);

                // Is this the ServerVersionInfo?
                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.ServerVersionInfo))
                {
                    this.Service.ServerInfo = ExchangeServerInfo.Parse(reader);
                }

                // Ignore anything else inside the SOAP header
            }while (!reader.IsEndElement(XmlNamespace.Soap, XmlElementNames.SOAPHeaderElementName));
        }