Пример #1
0
        public IActionResult OwsPost([FromBody] XElement requestXml)
        {
            if (requestXml == null)
            {
                return(BadRequest("XML request is not valid."));
            }

            var requestedService = requestXml.Attributes().FirstOrDefault(a => string.Compare(a.Name.LocalName, "service", StringComparison.OrdinalIgnoreCase) == 0)?.Value;

            RequestValidation.ValidateKnownService(requestedService);

            var       service = RequestValidation.ValidateSupportedService(requestedService);
            XDocument resultXml;

            switch (service)
            {
            case SupportedOcgServiceEnum.Wfs:
                resultXml = resolveManager.Resolve <WfsHandler>().Handle(requestXml);
                break;

            case SupportedOcgServiceEnum.Wms:
                resultXml = resolveManager.Resolve <WmsHandler>().Handle(requestXml);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(Content(resultXml.ToString(), "text/xml", Encoding.UTF8));
        }
Пример #2
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
//            if (Service == null)
//            {
//                throw new OwsException(
//                    OwsExceptionCodeEnum.MissingParameterValue,
//                    "service",
//                    CoreMessages.NoServiceWasSpecified);
//            }

            RequestValidation.ValidateKnownService(Service);

            if (Request == null)
            {
                throw new OwsException(
                          OwsExceptionCodeEnum.MissingParameterValue,
                          "request",
                          CoreMessages.RequestParameterMustBeSet);
            }

//            KnownOcgServiceEnum knownOcgService;
//            if (!Enum.TryParse(Service, true, out knownOcgService))
//            {
//                throw new OwsException(
//                    OwsExceptionCodeEnum.InvalidParameterValue,
//                    "service",
//                    string.Format(CoreMessages.SpecifiedServiceIsNotKnownOcgService, Service));
//            }

//            SupportedOcgServiceEnum supportedService;
//            if (!Enum.TryParse(Service, true, out supportedService))
//            {
//                throw new OwsException(
//                    OwsExceptionCodeEnum.NoApplicableCode,
//                    "service",
//                    new[]
//                    {
//                        $"Specified service '{Service}' is not a supported.",
//                        $"Supported services: '{string.Join(", ", Enum.GetNames(typeof (SupportedOcgServiceEnum))).ToUpper()}'"
//                    });
//            }

            SupportedService = RequestValidation.ValidateSupportedService(Service);
            return(Enumerable.Empty <ValidationResult>());
        }