Example #1
0
        public static XmlDocument RunFromHTTPPost(XmlNode requestNode, string language)
        {
            XmlNamespaceManager nsmgr       = Utils.CreateWPSNamespaceManager(requestNode.OwnerDocument);
            XmlNode             processNode = requestNode.SelectSingleNode("ows:Identifier", nsmgr);

            if (processNode == null || string.IsNullOrEmpty(processNode.InnerText))
            {
                throw new ExceptionReport(ExceptionCode.MissingParameterValue, "ows:Identifier");
            }

            string processId = processNode.InnerText;

            //List<InputData> processInputParams = null;
            //List<OutputData> processOutputParams = null;
            ProcessDescription processDescription = null;

            processDescription = ProcessDescription.GetProcessDescription(processId);
            //processInputParams = processDescription.GetProcessInputParameters();
            //processOutputParams = processDescription.GetProcessOutputParameters();

            List <InputData> inputParams = new List <InputData>();

            ExceptionReport exception = null;

            XmlNodeList inputs = requestNode.SelectNodes("wps:DataInputs/wps:Input", nsmgr);

            foreach (XmlNode node in inputs)
            {
                XmlNode nodeid = node.SelectSingleNode("ows:Identifier", nsmgr);
                if (nodeid == null)
                {
                    exception = new ExceptionReport(exception, "The parameter <ows:Identifier> is missing!",
                                                    ExceptionCode.MissingParameterValue, "ows:Identifier");
                    continue;
                }

                InputData input = processDescription.GetProcessInputParameter(nodeid.InnerText);
                if (input == null)
                {
                    exception = new ExceptionReport(exception, "The parameter " + nodeid.InnerText +
                                                    " is not a valid parameter for this execute request!",
                                                    ExceptionCode.InvalidParameterValue, nodeid.InnerText);
                    continue;
                }
                InputData myinput = input.Clone();
                try
                {
                    myinput.ParseValue(node);
                    inputParams.Add(myinput);
                }
                catch (ExceptionReport e)
                {
                    exception = new ExceptionReport(e, exception);
                }
            }

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

            ResponseFormType responseForm = new ResponseFormType("wps:ResponseForm");

            XmlNode responseFormNode = requestNode.SelectSingleNode("wps:ResponseForm", nsmgr);

            responseForm.Parse(responseFormNode, processDescription);

            return(Execute.Run(processDescription, inputParams, responseForm));
        }
Example #2
0
        public static XmlDocument RunFromHTTPGet(string language)
        {
            ResponseFormType responseForm = new ResponseFormType("wps:ResponseForm");
            string           processId    = Utils.GetParameter("Identifier");

            if (string.IsNullOrEmpty(processId))
            {
                throw new ExceptionReport(ExceptionCode.MissingParameterValue, "Identifier");
            }

            List <InputData>   processInputParams  = null;
            List <OutputData>  processOutputParams = null;
            ProcessDescription processDescription  = null;

            processDescription  = ProcessDescription.GetProcessDescription(processId);
            processInputParams  = processDescription.GetProcessInputParameters();
            processOutputParams = processDescription.GetProcessOutputParameters();

            List <InputData> inputParams = new List <InputData>();
            //string p = Utils.DecodeURI(Utils.GetParameter("DataInputs"));
            string p = Utils.GetParameter("DataInputs");

            ExceptionReport exception = null;

            if (!String.IsNullOrEmpty(p))
            {
                string[] tokens = p.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string param in tokens)
                {
                    string[] kv = param.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries);
                    if (kv.Length == 2)
                    {
                        InputData input = processDescription.GetProcessInputParameter(kv[0]);
                        if (input != null)
                        {
                            InputData myinput = input.Clone();
                            try
                            {
                                myinput.ParseValue(kv[1]);
                            }
                            catch (ExceptionReport e)
                            {
                                exception = new ExceptionReport(e, exception);
                            }
                            inputParams.Add(myinput);
                        }
                        else
                        {
                            exception = new ExceptionReport(exception, "The parameter " + kv[0] +
                                                            " is not a valid parameter for this execute request!", ExceptionCode.InvalidParameterValue, kv[0]);
                        }
                    }
                }
            }

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

            //List<string> outputIds = new List<string>();

            responseForm.Parse(processDescription);

            return(Run(processDescription, inputParams, responseForm));
        }