WriteToXml method
Writes XML.
The writer.
Implementation
void WriteToXml(EwsServiceXmlWriter writer) {
writer.WriteStartElement(
XmlNamespace.Soap,
XmlElementNames.SOAPEnvelopeElementName,
);
writer.WriteAttributeValueWithPrefix(
"xmlns",
EwsUtilities.EwsXmlSchemaInstanceNamespacePrefix,
EwsUtilities.EwsXmlSchemaInstanceNamespace,
);
writer.WriteAttributeValueWithPrefix(
"xmlns",
EwsUtilities.EwsMessagesNamespacePrefix,
EwsUtilities.EwsMessagesNamespace,
);
writer.WriteAttributeValueWithPrefix(
"xmlns",
EwsUtilities.EwsTypesNamespacePrefix,
EwsUtilities.EwsTypesNamespace,
);
if (writer.RequireWSSecurityUtilityNamespace) {
writer.WriteAttributeValueWithPrefix(
"xmlns",
EwsUtilities.WSSecurityUtilityNamespacePrefix,
EwsUtilities.WSSecurityUtilityNamespace,
);
}
writer.WriteStartElement(
XmlNamespace.Soap,
XmlElementNames.SOAPHeaderElementName,
);
if (Service.Credentials != null) {
Service.Credentials!.EmitExtraSoapHeaderNamespaceAliases(
writer.InternalWriter,
);
}
// Emit the RequestServerVersion header
if (!Service.SuppressXmlVersionHeader) {
writer.WriteStartElement(
XmlNamespace.Types,
XmlElementNames.RequestServerVersion,
);
writer.WriteAttributeValue(
XmlAttributeNames.Version,
_GetRequestedServiceVersionString(),
);
writer.WriteEndElement(); // RequestServerVersion
}
// Against Exchange 2007 SP1, we always emit the simplified time zone header. It adds very little to
// the request, so bandwidth consumption is not an issue. Against Exchange 2010 and above, we emit
// the full time zone header but only when the request actually needs it.
//
// The exception to this is if we are in Exchange2007 Compat Mode, in which case we should never emit
// the header. (Note: Exchange2007 Compat Mode is enabled for testability purposes only.)
//
if ((Service.RequestedServerVersion == ExchangeVersion.Exchange2007_SP1 ||
EmitTimeZoneHeader) &&
(!Service.Exchange2007CompatibilityMode)) {
// writer.WriteStartElement(XmlNamespace.Types, XmlElementNames.TimeZoneContext);
// todo("implement time zone definitions")
// this.Service.TimeZoneDefinition.WriteToXml(writer);
// writer.WriteEndElement(); // TimeZoneContext
writer.IsTimeZoneHeaderEmitted = true;
}
// Emit the MailboxCulture header
// todo("restore this features")
// if (this.Service.PreferredCulture != null)
// {
// writer.WriteElementValueWithNamespace(
// XmlNamespace.Types,
// XmlElementNames.MailboxCulture,
// this.Service.PreferredCulture.Name);
// }
// Emit the DateTimePrecision header
// todo("restore this features")
// if (this.Service.DateTimePrecision != DateTimePrecision.Default)
// {
// writer.WriteElementValueWithNamespace(
// XmlNamespace.Types,
// XmlElementNames.DateTimePrecision,
// this.Service.DateTimePrecision.ToString());
// }
// Emit the ExchangeImpersonation header
// todo("restore this features")
// if (this.Service.ImpersonatedUserId != null)
// {
// this.Service.ImpersonatedUserId.WriteToXml(writer);
// }
// else if (this.Service.PrivilegedUserId != null)
// {
// this.Service.PrivilegedUserId.WriteToXml(writer, this.Service.RequestedServerVersion);
// }
// else if (this.Service.ManagementRoles != null)
// {
// this.Service.ManagementRoles.WriteToXml(writer);
// }
if (Service.Credentials != null) {
Service.Credentials!.SerializeExtraSoapHeaders(
writer.InternalWriter,
GetXmlElementName(),
);
}
Service.DoOnSerializeCustomSoapHeaders(writer.InternalWriter);
writer.WriteEndElement(); // soap:Header
writer.WriteStartElement(
XmlNamespace.Soap,
XmlElementNames.SOAPBodyElementName,
);
WriteBodyToXml(writer);
writer.WriteEndElement(); // soap:Body
writer.WriteEndElement(); // soap:Envelope
}