/// <summary> /// Validates the WITSML Store API request. /// </summary> /// <param name="providers">The capServer providers.</param> /// <exception cref="WitsmlException"></exception> public static void ValidateRequest(IEnumerable <ICapServerProvider> providers) { var context = WitsmlOperationContext.Current; _log.DebugFormat("Validating WITSML request for {0}", context.Request.ObjectType); ValidateUserAgent(WebOperationContext.Current); context.OptionsIn = OptionsIn.Parse(context.Request.Options); // Document version is derived from the input string so it needs to be decompressed before the below checks. context.RequestCompressed = ValidateCompressedInput(context.Request.Function, context.Request.Xml, context.OptionsIn); var xml = context.RequestCompressed ? CompressionUtil.DecompressRequest(context.Request.Xml) : context.Request.Xml; context.Document = ValidateInputTemplate(xml); var dataSchemaVersion = ObjectTypes.GetVersion(context.Document.Root); ValidateDataSchemaVersion(dataSchemaVersion); var capServerProvider = providers.FirstOrDefault(x => x.DataSchemaVersion == dataSchemaVersion); if (capServerProvider == null) { throw new WitsmlException(ErrorCodes.DataObjectNotSupported, "WITSML object type not supported: " + context.Request.ObjectType + "; Version: " + dataSchemaVersion); } capServerProvider.ValidateRequest(); context.DataSchemaVersion = dataSchemaVersion; }