internal static ReportServerException FromMoreInformationNode(XmlNode moreInfoNode) { if (moreInfoNode == null) { return(null); } XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(moreInfoNode.OwnerDocument.NameTable); xmlNamespaceManager.AddNamespace("rs", "http://www.microsoft.com/sql/reportingservices"); string text = null; string text2 = null; XmlNode xmlNode = moreInfoNode.SelectSingleNode("rs:Message", xmlNamespaceManager); if (xmlNode != null) { string innerText = xmlNode.InnerText; XmlNode namedItem = xmlNode.Attributes.GetNamedItem("ErrorCode", "http://www.microsoft.com/sql/reportingservices"); if (namedItem != null) { text2 = namedItem.Value; } text = ((!string.IsNullOrEmpty(text2)) ? SoapExceptionStrings.RSSoapMessageFormat(innerText, text2) : innerText); } ReportServerException ex = FromMoreInformationNode(GetNestedMoreInformationNode(moreInfoNode)); if (string.IsNullOrEmpty(text)) { return(ex); } return(new ReportServerException(text, text2, ex)); }
internal static ReportServerException FromException(Exception e) { ReportServerException ex = e as ReportServerException; if (ex != null) { return(ex); } SoapException ex2 = e as SoapException; if (ex2 != null) { ReportServerException ex3 = FromMoreInformationNode(GetNestedMoreInformationNode(ex2.Detail)); if (ex3 != null) { return(ex3); } } else { if (e is RSExecutionConnection.MissingEndpointException) { return(new ReportServerException(e.Message, null, new MissingEndpointException(e.Message, e.InnerException))); } if (e is RSExecutionConnection.SoapVersionMismatchException) { return(new ReportServerException(e.Message, null, new SoapVersionMismatchException(e.Message, e.InnerException))); } } return(new ReportServerException(e.Message, null, e)); }
internal static ReportServerException FromException(Exception e) { ReportServerException ex = e as ReportServerException; if (ex != null) { return(ex); } FaultException ex2 = e as FaultException; if (ex2 != null) { var fault = ex2.CreateMessageFault(); var detail = fault.GetReaderAtDetailContents(); var detailDocument = new XmlDocument(); var detailNode = detailDocument.ReadNode(detail); ReportServerException ex3 = FromMoreInformationNode(GetNestedMoreInformationNode(detailNode)); if (ex3 != null) { return(ex3); } } else { if (e is RSExecutionConnection.MissingEndpointException) { return(new ReportServerException(e.Message, null, new MissingEndpointException(e.Message, e.InnerException))); } if (e is RSExecutionConnection.SoapVersionMismatchException) { return(new ReportServerException(e.Message, null, new SoapVersionMismatchException(e.Message, e.InnerException))); } } return(new ReportServerException(e.Message, null, e)); }
private static Exception ExceptionFromWebResponseUnwrapped(Exception e) { IOException ex = e as IOException; WebException ex2 = e as WebException; if (ex != null) { SocketException ex3 = ex.InnerException as SocketException; if (ex3 != null && ex3.SocketErrorCode == SocketError.Interrupted) { return(new OperationCanceledException()); } } else if (ex2 != null) { if (ex2.Status == WebExceptionStatus.RequestCanceled) { return(new OperationCanceledException()); } if (ex2.Response != null) { Stream responseStream = ex2.Response.GetResponseStream(); try { XmlDocument xmlDocument = new XmlDocument(); XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); xmlReaderSettings.CheckCharacters = false; XmlReader reader = XmlReader.Create(responseStream, xmlReaderSettings); xmlDocument.Load(reader); XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(xmlDocument.NameTable); xmlNamespaceManager.AddNamespace("rs", "http://www.microsoft.com/sql/reportingservices"); if (xmlDocument.DocumentElement != null) { Exception ex4 = ReportServerException.FromMoreInformationNode(xmlDocument.DocumentElement.SelectSingleNode("rs:MoreInformation", xmlNamespaceManager)); if (ex4 != null) { return(ex4); } return(e); } return(e); } catch (Exception) { return(e); } finally { responseStream.Close(); } } } return(e); }
/* * protected override WebRequest GetWebRequest(Uri uri) * { * HttpWebRequest httpWebRequest = (HttpWebRequest)base.GetWebRequest(uri); * if (!string.IsNullOrEmpty(BearerToken)) * { * httpWebRequest.Headers.Add("Authorization", $"Bearer {BearerToken}"); * } * WebRequestHelper.SetRequestHeaders(httpWebRequest, FormsAuthCookie, m_headers, m_cookies); * return httpWebRequest; * } * * protected override WebResponse GetWebResponse(WebRequest request) * { * using (new ServerImpersonationContext(m_impersonationUser)) * { * HttpWebResponse httpWebResponse = (HttpWebResponse)base.GetWebResponse(request); * string text = httpWebResponse.Headers["RSAuthenticationHeader"]; * if (text != null) * { * Cookie cookie = httpWebResponse.Cookies[text]; * if (cookie != null) * { * FormsAuthCookie = cookie; * } * } * return httpWebResponse; * } * } */ protected override void OnSoapException(FaultException e) { SoapVersionMismatchException.ThrowIfVersionMismatch(e, "ReportExecution2005.asmx", CommonStrings.UnsupportedReportServerError, includeInnerException: false); base.OnSoapException(e); throw ReportServerException.FromException(e); }
public static ReportServerException ExceptionFromWebResponse(Exception e) { return(ReportServerException.FromException(ExceptionFromWebResponseUnwrapped(e))); }