ReadResponseWithHeaders method

Future<Object> ReadResponseWithHeaders(
  1. EwsServiceXmlReader ewsXmlReader,
  2. WebHeaderCollection? responseHeaders
)
Reads the response. The XML reader. HTTP response headers

Implementation

Future<Object> ReadResponseWithHeaders(EwsServiceXmlReader ewsXmlReader,
    WebHeaderCollection? responseHeaders) async {
  Object serviceResponse;

  await this.ReadPreamble(ewsXmlReader);
  await ewsXmlReader.ReadStartElementWithNamespace(
      XmlNamespace.Soap, XmlElementNames.SOAPEnvelopeElementName);
  await this._ReadSoapHeader(ewsXmlReader);
  await ewsXmlReader.ReadStartElementWithNamespace(
      XmlNamespace.Soap, XmlElementNames.SOAPBodyElementName);

  await ewsXmlReader.ReadStartElementWithNamespace(
      XmlNamespace.Messages, this.GetResponseXmlElementName());

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

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

  await ewsXmlReader.ReadEndElementWithNamespace(
      XmlNamespace.Soap, XmlElementNames.SOAPBodyElementName);
  await ewsXmlReader.ReadEndElementWithNamespace(
      XmlNamespace.Soap, XmlElementNames.SOAPEnvelopeElementName);
  return serviceResponse;
}