/// <summary> /// Throws a <paramref name="code"/> WMS excption. The <paramref name="context"/> is used to write the response stream. /// </summary> /// <param name="code">The WMS exception code</param> /// <param name="message">An additional message text</param> /// <param name="context">The <see cref="HttpContext"/></param> /// <exception cref="InvalidOperationException">Thrown if this function is used outside a valid valid <see cref="HttpContext"/></exception> public static void ThrowWmsException(WmsExceptionCode code, string message, HttpContext context) { if (context == null) { throw new InvalidOperationException("WmsException class cannot be used outside a valid HttpContext"); } var response = context.Response; response.Clear(); response.ContentType = "text/xml"; response.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); response.Write( "<ServiceExceptionReport version=\"1.3.0\" xmlns=\"http://www.opengis.net/ogc\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.opengis.net/ogc http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd\">\n"); response.Write("<ServiceException"); if (code != WmsExceptionCode.NotApplicable) { response.Write(" code=\"" + code + "\""); } response.Write(">" + message + "</ServiceException>\n"); response.Write("</ServiceExceptionReport>"); response.Flush(); response.SuppressContent = true; context.ApplicationInstance.CompleteRequest(); }
internal static void ThrowWmsException(WmsExceptionCode code, string Message) { HttpResponse Response = HttpContext.Current.Response; Response.Clear(); Response.ContentType = "text/xml"; Response.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); Response.Write( "<ServiceExceptionReport version=\"1.3.0\" xmlns=\"http://www.opengis.net/ogc\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.opengis.net/ogc http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd\">\n"); Response.Write("<ServiceException"); if (code != WmsExceptionCode.NotApplicable) Response.Write(" code=\"" + code + "\""); Response.Write(">" + Message + "</ServiceException>\n"); Response.Write("</ServiceExceptionReport>"); Response.End(); }
internal static void ThrowWmsException(WmsExceptionCode code, string Message) { System.Web.HttpResponse Response = System.Web.HttpContext.Current.Response; Response.Clear(); Response.ContentType = "text/xml"; Response.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); Response.Write("<ServiceExceptionReport version=\"1.3.0\" xmlns=\"http://www.opengis.net/ogc\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.opengis.net/ogc http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd\">\n"); Response.Write("<ServiceException"); if (code != WmsExceptionCode.NotApplicable) { Response.Write(" code=\"" + code.ToString() + "\""); } Response.Write(">" + Message + "</ServiceException>\n"); Response.Write("</ServiceExceptionReport>"); Response.End(); }
/// <summary> /// Throws a <paramref name="code"/> WMS excption. The <paramref name="context"/> is used to write the response stream. /// </summary> /// <param name="code">The WMS exception code</param> /// <param name="message">An additional message text</param> /// <param name="context">The <see cref="HttpContext"/></param> /// <exception cref="InvalidOperationException">Thrown if this function is used outside a valid valid <see cref="HttpContext"/></exception> public static void ThrowWmsException(WmsExceptionCode code, string message, HttpContext context) { if (context == null) throw new InvalidOperationException("WmsException class cannot be used outside a valid HttpContext"); var response = context.Response; response.Clear(); response.ContentType = "text/xml"; response.Write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); response.Write( "<ServiceExceptionReport version=\"1.3.0\" xmlns=\"http://www.opengis.net/ogc\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.opengis.net/ogc http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd\">\n"); response.Write("<ServiceException"); if (code != WmsExceptionCode.NotApplicable) response.Write(" code=\"" + code + "\""); response.Write(">" + message + "</ServiceException>\n"); response.Write("</ServiceExceptionReport>"); response.End(); }
/// <summary> /// Populate the HttpResponse with a ServiceExceptionReport /// </summary> /// <param name="response"></param> /// <param name="code"></param> /// <param name="message"></param> private void SetResponseToServiceException(HttpResponse response, WmsExceptionCode code, string message) { ServiceExceptionReport serviceExceptionReport = new ServiceExceptionReport(); serviceExceptionReport.ServiceExceptionList.Add(new ServiceException(code, message)); response.Clear(); response.ContentType = "text/xml"; // Namespaces XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(); namespaces.Add(Declarations.WmsPrefix, Declarations.WmsNameSpace); namespaces.Add(Declarations.OgcPrefix, Declarations.OgcNameSpace); namespaces.Add(Declarations.XlinkPrefix, Declarations.XlinkNameSpace); // Serialize XmlSerializer serializer = new XmlSerializer(typeof(ServiceExceptionReport)); serializer.Serialize(response.OutputStream, serviceExceptionReport, namespaces); }
public WmsFault(WmsExceptionCode code, string message) { WmsExceptionCode = code; _Message = message; }
public static void ThrowWmsException(WmsExceptionCode code, string message) { var context = HttpContext.Current; ThrowWmsException(code, message, context); }
public WmsInvalidParameterException(string message, WmsExceptionCode code) : base(message, code) { }
internal static void ThrowWmsException(WmsExceptionCode code, string Message) { throw new WmsException(code, Message); }
public WmsException(WmsExceptionCode code, string message) : base(message) { }
/// <summary> /// Writes an error message into specified stream in compliance to WMS standard. /// </summary> /// <param name="code">The WMS error code</param> /// <param name="Message">The error message</param> /// <param name="responseOutputStream">The System.IO.Stream to write the error message</param> /// <param name="responseContentType">String for mime-type of response</param> public static void WmsException(WmsExceptionCode code, string Message, Stream responseOutputStream, ref string responseContentType) { responseContentType = "text/xml"; StringBuilder sb = new StringBuilder(); sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); sb.Append("<ServiceExceptionReport version=\"1.1.1\" xmlns=\"http://www.opengis.net/ogc\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"); sb.Append("<ServiceException"); if (code != WmsExceptionCode.NotApplicable) sb.Append(" code=\"" + code + "\""); sb.Append(">" + Message + "</ServiceException>\n"); sb.Append("</ServiceExceptionReport>"); byte[] bytes = Encoding.UTF8.GetBytes(sb.ToString().ToCharArray()); responseOutputStream.Write(bytes, 0, bytes.Length); }
protected WmsExceptionBase(string message, WmsExceptionCode exceptionCode) : base(message) { ExceptionCode = exceptionCode; }
public ServiceException(WmsExceptionCode code, string message) { _Code = code; _Message = message; }