コード例 #1
0
        /// <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();
        }
コード例 #2
0
ファイル: WmsException.cs プロジェクト: lishxi/_SharpMap
 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();
 }
コード例 #3
0
 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();
 }
コード例 #4
0
ファイル: WmsException.cs プロジェクト: geobabbler/SharpMap
        /// <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();
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
 public WmsFault(WmsExceptionCode code, string message)
 {
     WmsExceptionCode = code;
     _Message         = message;
 }
コード例 #7
0
        public static void ThrowWmsException(WmsExceptionCode code, string message)
        {
            var context = HttpContext.Current;

            ThrowWmsException(code, message, context);
        }
コード例 #8
0
 public WmsInvalidParameterException(string message, WmsExceptionCode code) :
     base(message, code)
 {
 }
コード例 #9
0
ファイル: WmsException.cs プロジェクト: lishxi/_SharpMap
 internal static void ThrowWmsException(WmsExceptionCode code, string Message)
 {
     throw new WmsException(code, Message);
 }
コード例 #10
0
ファイル: WmsException.cs プロジェクト: lishxi/_SharpMap
 public WmsException(WmsExceptionCode code, string message)
     : base(message)
 {
 }
コード例 #11
0
ファイル: WmsException.cs プロジェクト: PedroMaitan/sharpmap
 public static void ThrowWmsException(WmsExceptionCode code, string message)
 {
     var context = HttpContext.Current;
     ThrowWmsException(code, message, context);
 }
コード例 #12
0
ファイル: MapServerBase.cs プロジェクト: gkrsu/maparound.core
        /// <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);
        }
コード例 #13
0
 protected WmsExceptionBase(string message, WmsExceptionCode exceptionCode) :
     base(message)
 {
     ExceptionCode = exceptionCode;
 }
コード例 #14
0
 protected WmsExceptionBase(string message, WmsExceptionCode exceptionCode) :
     base(message)
 {
     ExceptionCode = exceptionCode;
 }
コード例 #15
0
ファイル: WmsException.cs プロジェクト: cugkgq/Project
 internal static void ThrowWmsException(WmsExceptionCode code, string Message)
 {
     throw new WmsException(code, Message);
 }
コード例 #16
0
ファイル: WmsException.cs プロジェクト: cugkgq/Project
 public WmsException(WmsExceptionCode code, string message)
     : base(message)
 {
 }
コード例 #17
0
 public WmsInvalidParameterException(string message, WmsExceptionCode code) :
     base(message, code) { }
コード例 #18
0
 public ServiceException(WmsExceptionCode code, string message)
 {
     _Code    = code;
     _Message = message;
 }