Пример #1
0
        public static XmlDocument Run(string[] processes, string Language)
        {
            StringBuilder retString = new StringBuilder();

            retString.Append(Global.XmlHeader + "<wps:ProcessDescriptions " + Global.WPSServiceVersion + " xml:lang='" + Language + "' " + Global.WPSXmlSchemas + " " + Global.WPSDescribeProcessSchema + ">");

            // On identifier is ALL, catch all the available processes
            if (processes.Length == 1 && Utils.StrICmp(processes[0], "ALL"))
            {
                ProcessDescription[] processDescriptions = GetCapabilities.getAvailableProcesses();
                foreach (ProcessDescription process in processDescriptions)
                {
                    retString.Append(process.GetProcessDescriptionDocument());
                }
            }
            else
            {
                ExceptionReport exception = null;

                // Loop through all the processes and get process description
                foreach (string processId in processes)
                {
                    try
                    {
                        retString.Append(ProcessDescription.GetProcessDescription(processId).GetProcessDescriptionDocument());
                    }
                    catch (ExceptionReport e)
                    {
                        exception = new ExceptionReport(e, exception);
                    }
                }

                if (exception != null)
                {
                    throw exception;
                }
            }

            retString.Append("</wps:ProcessDescriptions>");

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(retString.ToString());
                HttpContext.Current.Response.StatusCode = 200;
                return(doc);
            }
            catch (XmlException ex)
            {
                throw new ExceptionReport("Unable to generate the description document. Contact the administrator." + ex.ToString());
            }
        }
Пример #2
0
        public XmlDocument RunFromHTTPGet()
        {
            string request  = Utils.GetParameter("request");
            string service  = Utils.GetParameter("service");
            string version  = Utils.GetParameter("version");
            string language = Utils.GetParameter("language", Global.DefaultLanguage);

            ExceptionReport exception = null;

            if (service != "WPS")
            {
                exception = new ExceptionReport(exception, "The service requested must be a WPS service.",
                                                ExceptionCode.InvalidParameterValue, "service");
            }

            if (!Global.SupportedLanguages.Contains(language))
            {
                exception = new ExceptionReport(exception, "The language '" + language + "' is not supported by this WPS service. " +
                                                "Use one of the followings: " + string.Join(", ", Global.SupportedLanguages.ToArray()),
                                                ExceptionCode.InvalidParameterValue, "language");
            }

            if (string.IsNullOrEmpty(request))
            {
                exception = new ExceptionReport(exception, ExceptionCode.MissingParameterValue, "request");
            }

            if (exception != null)
            {
                throw exception;
            }

            // Execute an operation depending of the Request
            // version attribute is not present in a GetCApabilities request
            if (Utils.StrICmp(request, "GetCapabilities"))
            {
                return(GetCapabilities.RunFromHTTPGet(language));
            }

            // TODO handle many versions is possible. Do it ?
            if (string.IsNullOrEmpty(version))
            {
                throw new ExceptionReport(ExceptionCode.MissingParameterValue, "version");
            }

            if (version != Global.WPSVersion)
            {
                throw new ExceptionReport("The requested version '" + version + "' is not supported by this WPS server.",
                                          ExceptionCode.VersionNegotiationFailed, "version");
            }

            if (Utils.StrICmp(request, "DescribeProcess"))
            {
                return(DescribeProcess.RunFromHTTPGet(language));
            }

            if (Utils.StrICmp(request, "Execute"))
            {
                return(Execute.RunFromHTTPGet(language));
            }

            throw new ExceptionReport("The requested operation '" + request + "' is unknown.",
                                      ExceptionCode.InvalidParameterValue, "request");
        }
Пример #3
0
        public XmlDocument RunFromHTTPPost()
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                StreamReader MyStreamReader = new StreamReader(this.Context.Request.InputStream);
                doc.LoadXml(MyStreamReader.ReadToEnd());
                MyStreamReader.Close();
            }
            catch (Exception e)
            {
                throw new ExceptionReport("Error when reading posted data. The xml syntax seems incorrect:\n" + e.Message);
            }

            XmlNamespaceManager nsmgr = Utils.CreateWPSNamespaceManager(doc);

            XmlNode requestNode = doc.DocumentElement;

            string service  = Utils.GetXmlAttributesValue(requestNode, "service");
            string version  = Utils.GetXmlAttributesValue(requestNode, "version");
            string language = Utils.GetXmlAttributesValue(requestNode, "language", Global.DefaultLanguage);

            ExceptionReport exception = null;

            if (service != "WPS")
            {
                exception = new ExceptionReport("The service requested must be a WPS service.",
                                                ExceptionCode.InvalidParameterValue, "service");
            }

            if (!Global.SupportedLanguages.Contains(language))
            {
                exception = new ExceptionReport(exception, "The language '" + language + "' is not supported by this WPS service. " +
                                                "Use one of the followings: " + string.Join(", ", Global.SupportedLanguages.ToArray()),
                                                ExceptionCode.InvalidParameterValue, "language");
            }

            if (string.IsNullOrEmpty(requestNode.Name))
            {
                exception = new ExceptionReport(exception, ExceptionCode.MissingParameterValue, "request");
            }

            if (exception != null)
            {
                throw exception;
            }

            if (doc.SelectSingleNode("/wps:GetCapabilities", nsmgr) == requestNode)
            {
                return(GetCapabilities.RunFromHTTPPost(requestNode, language));
            }

            if (string.IsNullOrEmpty(version))
            {
                throw new ExceptionReport(ExceptionCode.MissingParameterValue, "version");
            }
            else if (version != Global.WPSVersion)
            {
                throw new ExceptionReport("The requested version '" + version + "' is not supported by this WPS server.",
                                          ExceptionCode.VersionNegotiationFailed, "version");
            }

            else if (doc.SelectSingleNode("/wps:DescribeProcess", nsmgr) == requestNode)
            {
                return(DescribeProcess.RunFromHTTPPost(requestNode, language));
            }

            else if (doc.SelectSingleNode("/wps:Execute", nsmgr) == requestNode)
            {
                return(Execute.RunFromHTTPPost(requestNode, language));
            }

            throw new ExceptionReport("The requested operation '" + requestNode.Name + "' is unknown.",
                                      ExceptionCode.InvalidParameterValue, "request");
        }