Beispiel #1
0
        /// <summary>
        /// Evaluates the received xml to see if the server has thrown an exception.
        /// </summary>
        /// <param name="xml">XML received from server.</param>
        /// <returns>True is an exception has been thrown.</returns>
        public static ServiceExceptionReport CheckException(string xml)
        {
            if (TypeUtils.CheckObjectType(xml, "ServiceExceptionReport"))
            {
                ServiceExceptionReport result = new ServiceExceptionReport();

                XDocument doc;
                var settings = new XmlReaderSettings();
                settings.DtdProcessing = DtdProcessing.Ignore;

                using (XmlReader reader = XmlReader.Create(new StringReader(xml), settings))
                {
                    doc = XDocument.Load(reader);
                }

                var docRoot = doc.Element("ServiceExceptionReport");
                if (docRoot == null) return null;

                var se = docRoot.Element("ServiceException");
                if (se == null) return null;
                result.Code = se.Attribute("code") != null ? se.Attribute("code").Value : "";

                result.ServiceException = se.Value.Trim();

                return result;
            }
            return null;
        }
 /// <summary>
 /// Creates a new instance of the <see cref="StringEventArgs"/>
 /// </summary>
 /// <param name="value">Value.</param>
 public ServiceExceptionReportEventArgs(ServiceExceptionReport value)
     : base()
 {
     _value = value;
 }