/// <summary> /// Load from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.AccountType: this.AccountType = reader.ReadElementValue(); break; case XmlElementNames.Action: string xmlResponseType = reader.ReadElementValue(); switch (xmlResponseType) { case OutlookAccount.Settings: this.ResponseType = AutodiscoverResponseType.Success; break; case OutlookAccount.RedirectUrl: this.ResponseType = AutodiscoverResponseType.RedirectUrl; break; case OutlookAccount.RedirectAddr: this.ResponseType = AutodiscoverResponseType.RedirectAddress; break; default: this.ResponseType = AutodiscoverResponseType.Error; break; } break; case XmlElementNames.Protocol: OutlookProtocol protocol = new OutlookProtocol(); protocol.LoadFromXml(reader); if (this.protocols.ContainsKey(protocol.ProtocolType)) { // There should be strictly one node per protocol type in the autodiscover response. throw new ServiceLocalException(Strings.InvalidAutodiscoverServiceResponse); } this.protocols.Add(protocol.ProtocolType, protocol); break; case XmlElementNames.RedirectAddr: case XmlElementNames.RedirectUrl: this.RedirectTarget = reader.ReadElementValue(); break; case XmlElementNames.AlternateMailboxes: AlternateMailbox alternateMailbox = AlternateMailbox.LoadFromXml(reader); this.alternateMailboxes.Entries.Add(alternateMailbox); break; default: reader.SkipCurrentElement(); break; } } } while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.Account)); }
/// <summary> /// Loads WebClientUrl instance from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>WebClientUrl.</returns> internal static WebClientUrl LoadFromXml(EwsXmlReader reader) { WebClientUrl webClientUrl = new WebClientUrl(); do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.AuthenticationMethods: webClientUrl.AuthenticationMethods = reader.ReadElementValue<string>(); break; case XmlElementNames.Url: webClientUrl.Url = reader.ReadElementValue<string>(); break; } } } while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.WebClientUrl)); return webClientUrl; }
/// <summary> /// Loads from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.ErrorCode: this.errorCode = reader.ReadElementValue <AutodiscoverErrorCode>(); break; case XmlElementNames.ErrorMessage: this.errorMessage = reader.ReadElementValue(); break; case XmlElementNames.SettingName: this.settingName = reader.ReadElementValue(); break; } } }while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.DomainSettingError)); }
/// <summary> /// Loads WebClientUrl instance from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>WebClientUrl.</returns> internal static WebClientUrl LoadFromXml(EwsXmlReader reader) { WebClientUrl webClientUrl = new WebClientUrl(); do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.AuthenticationMethods: webClientUrl.AuthenticationMethods = reader.ReadElementValue<string>(); break; case XmlElementNames.Url: webClientUrl.Url = reader.ReadElementValue<string>(); break; } } } while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.WebClientUrl)); return webClientUrl; }
/// <summary> /// Read user setting with ProtocolConnection value. /// </summary> /// <param name="reader">EwsServiceXmlReader</param> internal static ProtocolConnection LoadFromXml(EwsXmlReader reader) { ProtocolConnection connection = new ProtocolConnection(); do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.EncryptionMethod: connection.EncryptionMethod = reader.ReadElementValue<string>(); break; case XmlElementNames.Hostname: connection.Hostname = reader.ReadElementValue<string>(); break; case XmlElementNames.Port: connection.Port = reader.ReadElementValue<int>(); break; } } } while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.ProtocolConnection)); return connection; }
/// <summary> /// Load from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.DisplayName: this.displayName = reader.ReadElementValue(); break; case XmlElementNames.LegacyDN: this.legacyDN = reader.ReadElementValue(); break; case XmlElementNames.DeploymentId: this.deploymentId = reader.ReadElementValue(); break; case XmlElementNames.AutoDiscoverSMTPAddress: this.autodiscoverAMTPAddress = reader.ReadElementValue(); break; default: reader.SkipCurrentElement(); break; } } }while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.User)); }
/// <summary> /// Reads domain setting from XML. /// </summary> /// <param name="reader">The reader.</param> private void ReadSettingFromXml(EwsXmlReader reader) { DomainSettingName?name = null; object value = null; do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.Name: name = reader.ReadElementValue <DomainSettingName>(); break; case XmlElementNames.Value: value = reader.ReadElementValue(); break; } } }while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.DomainSetting)); EwsUtilities.Assert( name.HasValue, "GetDomainSettingsResponse.ReadSettingFromXml", "Missing name element in domain setting"); this.settings.Add(name.Value, value); }
/// <summary> /// Reads user setting from XML. /// </summary> /// <param name="reader">The reader.</param> private void ReadSettingFromXml(EwsXmlReader reader) { string name = null; object value = null; do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.Name: name = reader.ReadElementValue <string>(); break; case XmlElementNames.Value: value = reader.ReadElementValue(); break; case XmlElementNames.WebClientUrls: value = WebClientUrlCollection.LoadFromXml(reader); break; case XmlElementNames.ProtocolConnections: value = ProtocolConnectionCollection.LoadFromXml(reader); break; case XmlElementNames.AlternateMailboxes: value = AlternateMailboxCollection.LoadFromXml(reader); break; case XmlElementNames.DocumentSharingLocations: value = DocumentSharingLocationCollection.LoadFromXml(reader); break; } } }while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.UserSetting)); // EWS Managed API is broken with AutoDSvc endpoint in RedirectUrl scenario try { UserSettingName userSettingName = EwsUtilities.Parse <UserSettingName>(name); this.Settings.Add(userSettingName, value); } catch (ArgumentException) { // ignore unexpected UserSettingName in the response (due to the server-side bugs). // it'd be better if this is hooked into ITraceListener, but that is unavailable here. // // in case "name" is null, EwsUtilities.Parse throws ArgumentNullException // (which derives from ArgumentException). // EwsUtilities.Assert( false, "GetUserSettingsResponse.ReadSettingFromXml", "Unexpected or empty name element in user setting"); } }
/// <summary> /// Parses the XML through the specified reader and creates an Autodiscover error. /// </summary> /// <param name="reader">The reader.</param> /// <returns>An Autodiscover error.</returns> internal static AutodiscoverError Parse(EwsXmlReader reader) { AutodiscoverError error = new AutodiscoverError(); error.time = reader.ReadAttributeValue(XmlAttributeNames.Time); error.id = reader.ReadAttributeValue(XmlAttributeNames.Id); do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.ErrorCode: error.errorCode = reader.ReadElementValue<int>(); break; case XmlElementNames.Message: error.message = reader.ReadElementValue(); break; case XmlElementNames.DebugData: error.debugData = reader.ReadElementValue(); break; default: reader.SkipCurrentElement(); break; } } } while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.Error)); return error; }
/// <summary> /// Loads response from XML. /// </summary> /// <param name="reader">The reader.</param> /// <param name="endElementName">End element name.</param> internal virtual void LoadFromXml(EwsXmlReader reader, string endElementName) { switch (reader.LocalName) { case XmlElementNames.ErrorCode: this.ErrorCode = reader.ReadElementValue<AutodiscoverErrorCode>(); break; case XmlElementNames.ErrorMessage: this.ErrorMessage = reader.ReadElementValue(); break; default: break; } }
/// <summary> /// Loads response from XML. /// </summary> /// <param name="reader">The reader.</param> /// <param name="endElementName">End element name.</param> internal virtual void LoadFromXml(EwsXmlReader reader, string endElementName) { switch (reader.LocalName) { case XmlElementNames.ErrorCode: this.ErrorCode = reader.ReadElementValue <AutodiscoverErrorCode>(); break; case XmlElementNames.ErrorMessage: this.ErrorMessage = reader.ReadElementValue(); break; default: break; } }
/// <summary> /// Loads response from XML. /// </summary> /// <param name="reader">The reader.</param> /// <param name="endElementName">End element name.</param> internal override void LoadFromXml(EwsXmlReader reader, string endElementName) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.RedirectTarget: this.RedirectTarget = reader.ReadElementValue(); break; case XmlElementNames.UserSettingErrors: this.LoadUserSettingErrorsFromXml(reader); break; case XmlElementNames.UserSettings: this.LoadUserSettingsFromXml(reader); break; default: base.LoadFromXml(reader, endElementName); break; } } }while (!reader.IsEndElement(XmlNamespace.Autodiscover, endElementName)); }
/// <summary> /// Read ServerVersionInfo SOAP header. /// </summary> /// <param name="reader">EwsXmlReader</param> private ExchangeServerInfo ReadServerVersionInfo(EwsXmlReader reader) { ExchangeServerInfo serverInfo = new ExchangeServerInfo(); do { reader.Read(); if (reader.IsStartElement()) { switch (reader.LocalName) { case XmlElementNames.MajorVersion: serverInfo.MajorVersion = reader.ReadElementValue <int>(); break; case XmlElementNames.MinorVersion: serverInfo.MinorVersion = reader.ReadElementValue <int>(); break; case XmlElementNames.MajorBuildNumber: serverInfo.MajorBuildNumber = reader.ReadElementValue <int>(); break; case XmlElementNames.MinorBuildNumber: serverInfo.MinorBuildNumber = reader.ReadElementValue <int>(); break; case XmlElementNames.Version: serverInfo.VersionString = reader.ReadElementValue(); break; default: break; } } }while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.ServerVersionInfo)); return(serverInfo); }
/// <summary> /// Loads from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.ErrorCode: this.errorCode = reader.ReadElementValue<AutodiscoverErrorCode>(); break; case XmlElementNames.ErrorMessage: this.errorMessage = reader.ReadElementValue(); break; case XmlElementNames.SettingName: this.settingName = reader.ReadElementValue(); break; } } } while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.DomainSettingError)); }
/// <summary> /// Parses the XML through the specified reader and creates an Autodiscover error. /// </summary> /// <param name="reader">The reader.</param> /// <returns>An Autodiscover error.</returns> internal static AutodiscoverError Parse(EwsXmlReader reader) { AutodiscoverError error = new AutodiscoverError(); error.time = reader.ReadAttributeValue(XmlAttributeNames.Time); error.id = reader.ReadAttributeValue(XmlAttributeNames.Id); do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.ErrorCode: error.errorCode = reader.ReadElementValue <int>(); break; case XmlElementNames.Message: error.message = reader.ReadElementValue(); break; case XmlElementNames.DebugData: error.debugData = reader.ReadElementValue(); break; default: reader.SkipCurrentElement(); break; } } }while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.Error)); return(error); }
/// <summary> /// Loads AlternateMailbox instance from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>AlternateMailbox.</returns> internal static AlternateMailbox LoadFromXml(EwsXmlReader reader) { AlternateMailbox altMailbox = new AlternateMailbox(); do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.Type: altMailbox.Type = reader.ReadElementValue <string>(); break; case XmlElementNames.DisplayName: altMailbox.DisplayName = reader.ReadElementValue <string>(); break; case XmlElementNames.LegacyDN: altMailbox.LegacyDN = reader.ReadElementValue <string>(); break; case XmlElementNames.Server: altMailbox.Server = reader.ReadElementValue <string>(); break; case XmlElementNames.SmtpAddress: altMailbox.SmtpAddress = reader.ReadElementValue <string>(); break; case XmlElementNames.OwnerSmtpAddress: altMailbox.OwnerSmtpAddress = reader.ReadElementValue <string>(); break; default: break; } } }while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.AlternateMailbox)); return(altMailbox); }
/// <summary> /// Loads web client urls from XML. /// </summary> /// <param name="reader">The reader.</param> /// <param name="webClientUrls">The web client urls.</param> /// <param name="elementName">Name of the element.</param> private static void LoadWebClientUrlsFromXml(EwsXmlReader reader, WebClientUrlCollection webClientUrls, string elementName) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.OWAUrl: string authMethod = reader.ReadAttributeValue(XmlAttributeNames.AuthenticationMethod); string owaUrl = reader.ReadElementValue(); WebClientUrl webClientUrl = new WebClientUrl(authMethod, owaUrl); webClientUrls.Urls.Add(webClientUrl); break; default: reader.SkipCurrentElement(); break; } } }while (!reader.IsEndElement(XmlNamespace.NotSpecified, elementName)); }
/// <summary> /// Loads AlternateMailbox instance from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>AlternateMailbox.</returns> internal static AlternateMailbox LoadFromXml(EwsXmlReader reader) { AlternateMailbox altMailbox = new AlternateMailbox(); do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.Type: altMailbox.Type = reader.ReadElementValue<string>(); break; case XmlElementNames.DisplayName: altMailbox.DisplayName = reader.ReadElementValue<string>(); break; case XmlElementNames.LegacyDN: altMailbox.LegacyDN = reader.ReadElementValue<string>(); break; case XmlElementNames.Server: altMailbox.Server = reader.ReadElementValue<string>(); break; case XmlElementNames.SmtpAddress: altMailbox.SmtpAddress = reader.ReadElementValue<string>(); break; case XmlElementNames.OwnerSmtpAddress: altMailbox.OwnerSmtpAddress = reader.ReadElementValue<string>(); break; default: break; } } } while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.AlternateMailbox)); return altMailbox; }
/// <summary> /// Function that parses the SOAP headers from the response to the RST to Windows Live. /// </summary> /// <param name="rstResponse">The Windows Live response, positioned at the beginning of the SOAP headers.</param> private void ReadWindowsLiveRSTResponseHeaders(EwsXmlReader rstResponse) { // Read the beginning of the SOAP header, then go looking for the Passport SOAP fault section... rstResponse.ReadStartElement( WindowsLiveSoapNamespacePrefix, XmlElementNames.SOAPHeaderElementName); // Attempt to read to the psf:pp element - if at the end of the ReadToDescendant call we're at the // end element for the SOAP headers, we didn't find it. rstResponse.ReadToDescendant(XmlNamespace.PassportSoapFault, PpElementName); if (rstResponse.IsEndElement(WindowsLiveSoapNamespacePrefix, XmlElementNames.SOAPHeaderElementName)) { // We didn't find the psf:pp element - without that, we don't know what happened - // something went wrong. Trace and throw. if (this.TraceEnabled) { this.traceListener.Trace( "WindowsLiveResponse", "Could not find Passport SOAP fault information in Windows Live response"); } throw new ServiceRequestException(string.Format(Strings.ServiceRequestFailed, PpElementName)); } // Now that we've found the psf:pp element, look for the 'reqstatus' element under it. If after // the ReadToDescendant call we're at the end element for the psf:pp element, we didn't find it. rstResponse.ReadToDescendant(XmlNamespace.PassportSoapFault, ReqstatusElementName); if (rstResponse.IsEndElement(XmlNamespace.PassportSoapFault, PpElementName)) { // We didn't find the "reqstatus" element - without that, we don't know what happened - // something went wrong. Trace and throw. if (this.TraceEnabled) { this.traceListener.Trace( "WindowsLiveResponse", "Could not find reqstatus element in Passport SOAP fault information in Windows Live response"); } throw new ServiceRequestException(string.Format(Strings.ServiceRequestFailed, ReqstatusElementName)); } // Now that we've found the reqstatus element, get its value. string reqstatus = rstResponse.ReadElementValue(); // Read to body tag in both success and failure cases, // since we need to trace the fault response in failure cases while (!rstResponse.IsEndElement(WindowsLiveSoapNamespacePrefix, XmlElementNames.SOAPHeaderElementName)) { rstResponse.Read(); } if (!string.Equals(reqstatus, SuccessfulReqstatus)) { // Our request status was non-zero - something went wrong. Trace and throw. if (this.TraceEnabled) { string logMessage = string.Format( "Received status {0} from Windows Live instead of {1}.", reqstatus, SuccessfulReqstatus); this.traceListener.Trace("WindowsLiveResponse", logMessage); rstResponse.ReadStartElement( WindowsLiveSoapNamespacePrefix, XmlElementNames.SOAPBodyElementName); // Trace Fault Information this.traceListener.Trace( "WindowsLiveResponse", string.Format( "Windows Live reported Fault : {0}", rstResponse.ReadInnerXml())); } throw new ServiceRequestException(string.Format(Strings.ServiceRequestFailed, ReqstatusElementName + ": " + reqstatus)); } }
/// <summary> /// Load from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.DisplayName: this.displayName = reader.ReadElementValue(); break; case XmlElementNames.LegacyDN: this.legacyDN = reader.ReadElementValue(); break; case XmlElementNames.DeploymentId: this.deploymentId = reader.ReadElementValue(); break; case XmlElementNames.AutoDiscoverSMTPAddress: this.autodiscoverAMTPAddress = reader.ReadElementValue(); break; default: reader.SkipCurrentElement(); break; } } } while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.User)); }
/// <summary> /// Read ServerVersionInfo SOAP header. /// </summary> /// <param name="reader">EwsXmlReader</param> private ExchangeServerInfo ReadServerVersionInfo(EwsXmlReader reader) { ExchangeServerInfo serverInfo = new ExchangeServerInfo(); do { reader.Read(); if (reader.IsStartElement()) { switch (reader.LocalName) { case XmlElementNames.MajorVersion: serverInfo.MajorVersion = reader.ReadElementValue<int>(); break; case XmlElementNames.MinorVersion: serverInfo.MinorVersion = reader.ReadElementValue<int>(); break; case XmlElementNames.MajorBuildNumber: serverInfo.MajorBuildNumber = reader.ReadElementValue<int>(); break; case XmlElementNames.MinorBuildNumber: serverInfo.MinorBuildNumber = reader.ReadElementValue<int>(); break; case XmlElementNames.Version: serverInfo.VersionString = reader.ReadElementValue(); break; default: break; } } } while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.ServerVersionInfo)); return serverInfo; }
/// <summary> /// Parses the message XML. /// </summary> /// <param name="reader">The reader.</param> private void ParseMessageXml(EwsXmlReader reader) { // E12 and E14 return the MessageXml element in different // namespaces (types namespace for E12, errors namespace in E14). To // avoid this problem, the parser will match the namespace from the // start and end elements. XmlNamespace elementNS = EwsUtilities.GetNamespaceFromUri(reader.NamespaceUri); if (!reader.IsEmptyElement) { do { reader.Read(); if (reader.IsStartElement() && !reader.IsEmptyElement) { switch (reader.LocalName) { case XmlElementNames.Value: this.errorDetails.Add( reader.ReadAttributeValue(XmlAttributeNames.Name), reader.ReadElementValue()); break; default: break; } } } while (!reader.IsEndElement(elementNS, XmlElementNames.MessageXml)); } }
/// <summary> /// Loads response from XML. /// </summary> /// <param name="reader">The reader.</param> /// <param name="endElementName">End element name.</param> internal override void LoadFromXml(EwsXmlReader reader, string endElementName) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.RedirectTarget: this.redirectTarget = reader.ReadElementValue(); break; case XmlElementNames.DomainSettingErrors: this.LoadDomainSettingErrorsFromXml(reader); break; case XmlElementNames.DomainSettings: this.LoadDomainSettingsFromXml(reader); break; default: base.LoadFromXml(reader, endElementName); break; } } } while (!reader.IsEndElement(XmlNamespace.Autodiscover, endElementName)); }
/// <summary> /// Loads web client urls from XML. /// </summary> /// <param name="reader">The reader.</param> /// <param name="webClientUrls">The web client urls.</param> /// <param name="elementName">Name of the element.</param> private static void LoadWebClientUrlsFromXml(EwsXmlReader reader, WebClientUrlCollection webClientUrls, string elementName) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.OWAUrl: string authMethod = reader.ReadAttributeValue(XmlAttributeNames.AuthenticationMethod); string owaUrl = reader.ReadElementValue(); WebClientUrl webClientUrl = new WebClientUrl(authMethod, owaUrl); webClientUrls.Urls.Add(webClientUrl); break; default: reader.SkipCurrentElement(); break; } } } while (!reader.IsEndElement(XmlNamespace.NotSpecified, elementName)); }
/// <summary> /// Function that parses the SOAP headers from the response to the RST to Windows Live. /// </summary> /// <param name="rstResponse">The Windows Live response, positioned at the beginning of the SOAP headers.</param> /* private */ void ReadWindowsLiveRSTResponseHeaders(EwsXmlReader rstResponse) { // Read the beginning of the SOAP header, then go looking for the Passport SOAP fault section... rstResponse.ReadStartElement( WindowsLiveSoapNamespacePrefix, XmlElementNames.SOAPHeaderElementName); // Attempt to read to the psf:pp element - if at the end of the ReadToDescendant call we're at the // end element for the SOAP headers, we didn't find it. rstResponse.ReadToDescendant(XmlNamespace.PassportSoapFault, PpElementName); if (rstResponse.IsEndElement(WindowsLiveSoapNamespacePrefix, XmlElementNames.SOAPHeaderElementName)) { // We didn't find the psf:pp element - without that, we don't know what happened - // something went wrong. Trace and throw. if (this.TraceEnabled) { this.traceListener.Trace( "WindowsLiveResponse", "Could not find Passport SOAP fault information in Windows Live response"); } throw new ServiceRequestException(string.Format(Strings.ServiceRequestFailed, PpElementName)); } // Now that we've found the psf:pp element, look for the 'reqstatus' element under it. If after // the ReadToDescendant call we're at the end element for the psf:pp element, we didn't find it. rstResponse.ReadToDescendant(XmlNamespace.PassportSoapFault, ReqstatusElementName); if (rstResponse.IsEndElement(XmlNamespace.PassportSoapFault, PpElementName)) { // We didn't find the "reqstatus" element - without that, we don't know what happened - // something went wrong. Trace and throw. if (this.TraceEnabled) { this.traceListener.Trace( "WindowsLiveResponse", "Could not find reqstatus element in Passport SOAP fault information in Windows Live response"); } throw new ServiceRequestException(string.Format(Strings.ServiceRequestFailed, ReqstatusElementName)); } // Now that we've found the reqstatus element, get its value. String reqstatus = rstResponse.ReadElementValue(); // Read to body tag in both success and failure cases, // since we need to trace the fault response in failure cases while (!rstResponse.IsEndElement(WindowsLiveSoapNamespacePrefix, XmlElementNames.SOAPHeaderElementName)) { rstResponse.Read(); } if (!string.Equals(reqstatus, SuccessfulReqstatus)) { // Our request status was non-zero - something went wrong. Trace and throw. if (this.TraceEnabled) { String logMessage = string.Format( "Received status {0} from Windows Live instead of {1}.", reqstatus, SuccessfulReqstatus); this.traceListener.Trace("WindowsLiveResponse", logMessage); rstResponse.ReadStartElement( WindowsLiveSoapNamespacePrefix, XmlElementNames.SOAPBodyElementName); // Trace Fault Information this.traceListener.Trace( "WindowsLiveResponse", string.Format( "Windows Live reported Fault : {0}", rstResponse.ReadInnerXml())); } throw new ServiceRequestException(string.Format(Strings.ServiceRequestFailed, ReqstatusElementName + ": " + reqstatus)); } }
/// <summary> /// Loads from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.Type: this.ProtocolType = OutlookProtocol.ProtocolNameToType(reader.ReadElementValue()); break; case XmlElementNames.AuthPackage: this.authPackage = reader.ReadElementValue(); break; case XmlElementNames.Server: this.server = reader.ReadElementValue(); break; case XmlElementNames.ServerDN: this.serverDN = reader.ReadElementValue(); break; case XmlElementNames.ServerVersion: // just read it out reader.ReadElementValue(); break; case XmlElementNames.AD: this.activeDirectoryServer = reader.ReadElementValue(); break; case XmlElementNames.MdbDN: this.mailboxDN = reader.ReadElementValue(); break; case XmlElementNames.EWSUrl: this.exchangeWebServicesUrl = reader.ReadElementValue(); break; case XmlElementNames.EmwsUrl: this.exchangeManagementWebServicesUrl = reader.ReadElementValue(); break; case XmlElementNames.ASUrl: this.availabilityServiceUrl = reader.ReadElementValue(); break; case XmlElementNames.OOFUrl: // just read it out reader.ReadElementValue(); break; case XmlElementNames.UMUrl: this.unifiedMessagingUrl = reader.ReadElementValue(); break; case XmlElementNames.OABUrl: this.offlineAddressBookUrl = reader.ReadElementValue(); break; case XmlElementNames.PublicFolderServer: this.publicFolderServer = reader.ReadElementValue(); break; case XmlElementNames.Internal: OutlookProtocol.LoadWebClientUrlsFromXml(reader, this.internalOutlookWebAccessUrls, reader.LocalName); break; case XmlElementNames.External: OutlookProtocol.LoadWebClientUrlsFromXml(reader, this.externalOutlookWebAccessUrls, reader.LocalName); break; case XmlElementNames.Ssl: string sslStr = reader.ReadElementValue(); this.sslEnabled = sslStr.Equals("On", StringComparison.OrdinalIgnoreCase); break; case XmlElementNames.SharingUrl: this.sharingEnabled = reader.ReadElementValue().Length > 0; break; case XmlElementNames.EcpUrl: this.ecpUrl = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_um: this.ecpUrlUm = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_aggr: this.ecpUrlAggr = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_sms: this.ecpUrlSms = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_mt: this.ecpUrlMt = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_ret: this.ecpUrlRet = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_publish: this.ecpUrlPublish = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_photo: this.ecpUrlPhoto = reader.ReadElementValue(); break; case XmlElementNames.ExchangeRpcUrl: this.exchangeRpcUrl = reader.ReadElementValue(); break; case XmlElementNames.EwsPartnerUrl: this.exchangeWebServicesPartnerUrl = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_connect: this.ecpUrlConnect = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tm: this.ecpUrlTm = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tmCreating: this.ecpUrlTmCreating = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tmEditing: this.ecpUrlTmEditing = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tmHiding: this.ecpUrlTmHiding = reader.ReadElementValue(); break; case XmlElementNames.SiteMailboxCreationURL: this.siteMailboxCreationURL = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_extinstall: this.ecpUrlExtInstall = reader.ReadElementValue(); break; case XmlElementNames.ServerExclusiveConnect: string serverExclusiveConnectStr = reader.ReadElementValue(); this.serverExclusiveConnect = serverExclusiveConnectStr.Equals("On", StringComparison.OrdinalIgnoreCase); break; case XmlElementNames.CertPrincipalName: this.certPrincipalName = reader.ReadElementValue(); break; case XmlElementNames.GroupingInformation: this.groupingInformation = reader.ReadElementValue(); break; default: reader.SkipCurrentElement(); break; } } }while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.Protocol)); }
/// <summary> /// Parses the soap:Fault content. /// </summary> /// <param name="reader">The reader.</param> /// <param name="soapNamespace">The SOAP namespace to use.</param> /// <returns>SOAP fault details.</returns> internal static SoapFaultDetails Parse(EwsXmlReader reader, XmlNamespace soapNamespace) { SoapFaultDetails soapFaultDetails = new SoapFaultDetails(); do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.SOAPFaultCodeElementName: soapFaultDetails.FaultCode = reader.ReadElementValue(); break; case XmlElementNames.SOAPFaultStringElementName: soapFaultDetails.FaultString = reader.ReadElementValue(); break; case XmlElementNames.SOAPFaultActorElementName: soapFaultDetails.FaultActor = reader.ReadElementValue(); break; case XmlElementNames.SOAPDetailElementName: soapFaultDetails.ParseDetailNode(reader); break; default: break; } } } while (!reader.IsEndElement(soapNamespace, XmlElementNames.SOAPFaultElementName)); return soapFaultDetails; }
/// <summary> /// Reads domain setting from XML. /// </summary> /// <param name="reader">The reader.</param> private void ReadSettingFromXml(EwsXmlReader reader) { DomainSettingName? name = null; object value = null; do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.Name: name = reader.ReadElementValue<DomainSettingName>(); break; case XmlElementNames.Value: value = reader.ReadElementValue(); break; } } } while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.DomainSetting)); EwsUtilities.Assert( name.HasValue, "GetDomainSettingsResponse.ReadSettingFromXml", "Missing name element in domain setting"); this.settings.Add(name.Value, value); }
/// <summary> /// Load from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.AccountType: this.AccountType = reader.ReadElementValue(); break; case XmlElementNames.Action: string xmlResponseType = reader.ReadElementValue(); switch (xmlResponseType) { case OutlookAccount.Settings: this.ResponseType = AutodiscoverResponseType.Success; break; case OutlookAccount.RedirectUrl: this.ResponseType = AutodiscoverResponseType.RedirectUrl; break; case OutlookAccount.RedirectAddr: this.ResponseType = AutodiscoverResponseType.RedirectAddress; break; default: this.ResponseType = AutodiscoverResponseType.Error; break; } break; case XmlElementNames.Protocol: OutlookProtocol protocol = new OutlookProtocol(); protocol.LoadFromXml(reader); if (this.protocols.ContainsKey(protocol.ProtocolType)) { // There should be strictly one node per protocol type in the autodiscover response. throw new ServiceLocalException(Strings.InvalidAutodiscoverServiceResponse); } this.protocols.Add(protocol.ProtocolType, protocol); break; case XmlElementNames.RedirectAddr: case XmlElementNames.RedirectUrl: this.RedirectTarget = reader.ReadElementValue(); break; case XmlElementNames.AlternateMailboxes: AlternateMailbox alternateMailbox = AlternateMailbox.LoadFromXml(reader); this.alternateMailboxes.Entries.Add(alternateMailbox); break; default: reader.SkipCurrentElement(); break; } } }while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.Account)); }
/// <summary> /// Loads DocumentSharingLocation instance from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>DocumentSharingLocation.</returns> internal static DocumentSharingLocation LoadFromXml(EwsXmlReader reader) { DocumentSharingLocation location = new DocumentSharingLocation(); do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.ServiceUrl: location.ServiceUrl = reader.ReadElementValue<string>(); break; case XmlElementNames.LocationUrl: location.LocationUrl = reader.ReadElementValue<string>(); break; case XmlElementNames.DisplayName: location.DisplayName = reader.ReadElementValue<string>(); break; case XmlElementNames.SupportedFileExtensions: List<string> fileExtensions = new List<string>(); reader.Read(); while (reader.IsStartElement(XmlNamespace.Autodiscover, XmlElementNames.FileExtension)) { string extension = reader.ReadElementValue<string>(); fileExtensions.Add(extension); reader.Read(); } location.SupportedFileExtensions = fileExtensions; break; case XmlElementNames.ExternalAccessAllowed: location.ExternalAccessAllowed = reader.ReadElementValue<bool>(); break; case XmlElementNames.AnonymousAccessAllowed: location.AnonymousAccessAllowed = reader.ReadElementValue<bool>(); break; case XmlElementNames.CanModifyPermissions: location.CanModifyPermissions = reader.ReadElementValue<bool>(); break; case XmlElementNames.IsDefault: location.IsDefault = reader.ReadElementValue<bool>(); break; default: break; } } } while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.DocumentSharingLocation)); return location; }
/// <summary> /// Loads from XML. /// </summary> /// <param name="reader">The reader.</param> internal void LoadFromXml(EwsXmlReader reader) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.Type: this.ProtocolType = OutlookProtocol.ProtocolNameToType(reader.ReadElementValue()); break; case XmlElementNames.AuthPackage: this.authPackage = reader.ReadElementValue(); break; case XmlElementNames.Server: this.server = reader.ReadElementValue(); break; case XmlElementNames.ServerDN: this.serverDN = reader.ReadElementValue(); break; case XmlElementNames.ServerVersion: // just read it out reader.ReadElementValue(); break; case XmlElementNames.AD: this.activeDirectoryServer = reader.ReadElementValue(); break; case XmlElementNames.MdbDN: this.mailboxDN = reader.ReadElementValue(); break; case XmlElementNames.EWSUrl: this.exchangeWebServicesUrl = reader.ReadElementValue(); break; case XmlElementNames.EmwsUrl: this.exchangeManagementWebServicesUrl = reader.ReadElementValue(); break; case XmlElementNames.ASUrl: this.availabilityServiceUrl = reader.ReadElementValue(); break; case XmlElementNames.OOFUrl: // just read it out reader.ReadElementValue(); break; case XmlElementNames.UMUrl: this.unifiedMessagingUrl = reader.ReadElementValue(); break; case XmlElementNames.OABUrl: this.offlineAddressBookUrl = reader.ReadElementValue(); break; case XmlElementNames.PublicFolderServer: this.publicFolderServer = reader.ReadElementValue(); break; case XmlElementNames.Internal: OutlookProtocol.LoadWebClientUrlsFromXml(reader, this.internalOutlookWebAccessUrls, reader.LocalName); break; case XmlElementNames.External: OutlookProtocol.LoadWebClientUrlsFromXml(reader, this.externalOutlookWebAccessUrls, reader.LocalName); break; case XmlElementNames.Ssl: string sslStr = reader.ReadElementValue(); this.sslEnabled = sslStr.Equals("On", StringComparison.OrdinalIgnoreCase); break; case XmlElementNames.SharingUrl: this.sharingEnabled = reader.ReadElementValue().Length > 0; break; case XmlElementNames.EcpUrl: this.ecpUrl = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_um: this.ecpUrlUm = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_aggr: this.ecpUrlAggr = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_sms: this.ecpUrlSms = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_mt: this.ecpUrlMt = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_ret: this.ecpUrlRet = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_publish: this.ecpUrlPublish = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_photo: this.ecpUrlPhoto = reader.ReadElementValue(); break; case XmlElementNames.ExchangeRpcUrl: this.exchangeRpcUrl = reader.ReadElementValue(); break; case XmlElementNames.EwsPartnerUrl: this.exchangeWebServicesPartnerUrl = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_connect: this.ecpUrlConnect = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tm: this.ecpUrlTm = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tmCreating: this.ecpUrlTmCreating = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tmEditing: this.ecpUrlTmEditing = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_tmHiding: this.ecpUrlTmHiding = reader.ReadElementValue(); break; case XmlElementNames.SiteMailboxCreationURL: this.siteMailboxCreationURL = reader.ReadElementValue(); break; case XmlElementNames.EcpUrl_extinstall: this.ecpUrlExtInstall = reader.ReadElementValue(); break; case XmlElementNames.ServerExclusiveConnect: string serverExclusiveConnectStr = reader.ReadElementValue(); this.serverExclusiveConnect = serverExclusiveConnectStr.Equals("On", StringComparison.OrdinalIgnoreCase); break; case XmlElementNames.CertPrincipalName: this.certPrincipalName = reader.ReadElementValue(); break; case XmlElementNames.GroupingInformation: this.groupingInformation = reader.ReadElementValue(); break; default: reader.SkipCurrentElement(); break; } } } while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.Protocol)); }
/// <summary> /// Loads DocumentSharingLocation instance from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>DocumentSharingLocation.</returns> internal static DocumentSharingLocation LoadFromXml(EwsXmlReader reader) { DocumentSharingLocation location = new DocumentSharingLocation(); do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.ServiceUrl: location.ServiceUrl = reader.ReadElementValue <string>(); break; case XmlElementNames.LocationUrl: location.LocationUrl = reader.ReadElementValue <string>(); break; case XmlElementNames.DisplayName: location.DisplayName = reader.ReadElementValue <string>(); break; case XmlElementNames.SupportedFileExtensions: List <string> fileExtensions = new List <string>(); reader.Read(); while (reader.IsStartElement(XmlNamespace.Autodiscover, XmlElementNames.FileExtension)) { string extension = reader.ReadElementValue <string>(); fileExtensions.Add(extension); reader.Read(); } location.SupportedFileExtensions = fileExtensions; break; case XmlElementNames.ExternalAccessAllowed: location.ExternalAccessAllowed = reader.ReadElementValue <bool>(); break; case XmlElementNames.AnonymousAccessAllowed: location.AnonymousAccessAllowed = reader.ReadElementValue <bool>(); break; case XmlElementNames.CanModifyPermissions: location.CanModifyPermissions = reader.ReadElementValue <bool>(); break; case XmlElementNames.IsDefault: location.IsDefault = reader.ReadElementValue <bool>(); break; default: break; } } }while (!reader.IsEndElement(XmlNamespace.Autodiscover, XmlElementNames.DocumentSharingLocation)); return(location); }
/// <summary> /// Parses the detail node. /// </summary> /// <param name="reader">The reader.</param> private void ParseDetailNode(EwsXmlReader reader) { do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { switch (reader.LocalName) { case XmlElementNames.EwsResponseCodeElementName: try { this.ResponseCode = reader.ReadElementValue<ServiceError>(); } catch (ArgumentException) { // ServiceError couldn't be mapped to enum value, treat as an ISE this.ResponseCode = ServiceError.ErrorInternalServerError; } break; case XmlElementNames.EwsMessageElementName: this.Message = reader.ReadElementValue(); break; case XmlElementNames.EwsLineElementName: this.LineNumber = reader.ReadElementValue<int>(); break; case XmlElementNames.EwsPositionElementName: this.PositionWithinLine = reader.ReadElementValue<int>(); break; case XmlElementNames.EwsErrorCodeElementName: try { this.ErrorCode = reader.ReadElementValue<ServiceError>(); } catch (ArgumentException) { // ServiceError couldn't be mapped to enum value, treat as an ISE this.ErrorCode = ServiceError.ErrorInternalServerError; } break; case XmlElementNames.EwsExceptionTypeElementName: this.ExceptionType = reader.ReadElementValue(); break; case XmlElementNames.MessageXml: this.ParseMessageXml(reader); break; default: // Ignore any other details break; } } } while (!reader.IsEndElement(XmlNamespace.NotSpecified, XmlElementNames.SOAPDetailElementName)); }