/// <summary>
        /// Read the partner token soap header.
        /// </summary>
        /// <param name="reader">EwsXmlReader</param>
        internal override void ReadSoapHeader(EwsXmlReader reader)
        {
            base.ReadSoapHeader(reader);

            if (this.expectPartnerToken)
            {
                if (reader.IsStartElement(XmlNamespace.Autodiscover, XmlElementNames.PartnerToken))
                {
                    this.PartnerToken = reader.ReadInnerXml();
                }

                if (reader.IsStartElement(XmlNamespace.Autodiscover, XmlElementNames.PartnerTokenReference))
                {
                    this.PartnerTokenReference = reader.ReadInnerXml();
                }
            }
        }
        /// <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));
            }
        }
Пример #3
0
    /// <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>
        /// Read the partner token soap header.
        /// </summary>
        /// <param name="reader">EwsXmlReader</param>
        internal override void ReadSoapHeader(EwsXmlReader reader)
        {
            base.ReadSoapHeader(reader);

            if (this.expectPartnerToken)
            {
                if (reader.IsStartElement(XmlNamespace.Autodiscover, XmlElementNames.PartnerToken))
                {
                    this.PartnerToken = reader.ReadInnerXml();
                }

                if (reader.IsStartElement(XmlNamespace.Autodiscover, XmlElementNames.PartnerTokenReference))
                {
                    this.PartnerTokenReference = reader.ReadInnerXml();
                }
            }
        }