private Ows100.Operation CreateOperation(string operationName, IEnumerable <OwsEndPoint> endPoints) { Ows100.Operation ret = null; var getMethods = new List <Ows100.RequestMethodType>(); var postMethods = new List <Ows100.RequestMethodType>(); foreach (OwsEndPoint ep in GetEndPoints()) { UriBuilder ub = new UriBuilder(ep.BaseUri); if (ep.AddOperationName) { ub.Path += operationName; } if (ep.Method == OwsMethod.Get) { getMethods.Add( new Ows100.RequestMethodType() { href = ub.Uri } ); } else { postMethods.Add( new Ows100.RequestMethodType() { href = ub.Uri, Constraint = new Ows100.DomainType[] { new Ows100.DomainType() { name = "PostEncoding", Value = new string[] { (ep.Method == OwsMethod.Soap ? "SOAP" : "XML") } } } } ); } } if ((getMethods.Count > 0) || (postMethods.Count > 0)) { ret = new Ows100.Operation() { name = operationName, DCP = new Ows100.DCP[] { new Ows100.DCP() { HTTP = new Ows100.HTTP() } } }; if (getMethods.Count > 0) { ret.DCP[0].HTTP.Get = getMethods; } if (postMethods.Count > 0) { ret.DCP[0].HTTP.Post = postMethods; } } return(ret); }
/// <summary>Creates an OperationsMetadata section for the current request.</summary> /// <returns>The OperationsMetadata section for the current request.</returns> protected virtual Ows100.OperationsMetadata CreateOperationsMetadataSection() { var operations = new List <Ows100.Operation>(); Ows100.Operation getCapabilities = CreateOperation("GetCapabilities", GetEndPoints()); if (getCapabilities != null) { getCapabilities.Parameter = new Ows100.DomainType[] { new Ows100.DomainType() { name = SectionsParameter, Value = new string[] { "ServiceIdentification", "ServiceProvider", "OperationsMetadata", "Filter_Capabilities" } } }; operations.Add(getCapabilities); } Ows100.Operation describeRecord = CreateOperation("DescribeRecord", GetEndPoints()); if (describeRecord != null) { IEnumerable <IXMetaData> supportedTypes = ((Discovery)Service).SupportedRecordTypes; // Creates prefixes for supported records namespaces foreach (IXMetaData st in supportedTypes) { string p = describeRecord.Untyped.GetPrefixOfNamespace(st.SchemaName.Namespace); if (string.IsNullOrEmpty(p)) { describeRecord.Untyped.Add( new XAttribute(XNamespace.Xmlns + CreateUniquePrefix(st.SchemaName.Namespace, describeRecord.Untyped, null), st.SchemaName.Namespace) ); } } describeRecord.Parameter = new Ows100.DomainType[] { new Ows100.DomainType() { name = Discovery.OutputFormatParameter, Value = OgcService.XmlMimeTypes }, new Ows100.DomainType() { name = TypeNameParameter, Value = supportedTypes .Select <IXMetaData, string>( m => string.Concat(describeRecord.Untyped.GetPrefixOfNamespace(m.SchemaName.Namespace), ":", m.GetType().Name) ).ToArray <string>() } }; operations.Add(describeRecord); } Ows100.Operation getRecords = CreateOperation("GetRecords", GetEndPoints()); if (getRecords != null) { IEnumerable <IXMetaData> supportedTypes = ((Discovery)Service).SupportedRecordTypes; // Creates prefixes for supported records namespaces foreach (IXMetaData st in supportedTypes) { string p = getRecords.Untyped.GetPrefixOfNamespace(st.SchemaName.Namespace); if (string.IsNullOrEmpty(p)) { getRecords.Untyped.Add( new XAttribute(XNamespace.Xmlns + CreateUniquePrefix(st.SchemaName.Namespace, getRecords.Untyped, null), st.SchemaName.Namespace) ); } } getRecords.Parameter = new Ows100.DomainType[] { new Ows100.DomainType() { name = OutputFormatParameter, Value = OgcService.XmlMimeTypes }, new Ows100.DomainType() { name = OutputSchemaParameter, Value = supportedTypes.Select <IXMetaData, string>(m => m.SchemaName.NamespaceName).ToArray <string>() }, new Ows100.DomainType() { name = TypeNameParameter, Value = supportedTypes .Select <IXMetaData, string>( m => string.Concat(getRecords.Untyped.GetPrefixOfNamespace(m.SchemaName.Namespace), ":", m.GetType().Name) ).ToArray <string>() }, new Ows100.DomainType() { name = Discovery.ConstraintLanguageParameter, Value = new string[] { "FILTER", "CQL_TEXT" } } }; operations.Add(getRecords); } Ows100.Operation getRecordById = CreateOperation("GetRecordById", GetEndPoints()); if (getRecordById != null) { var parameters = new Ows100.DomainType[] { new Ows100.DomainType() { name = OutputFormatParameter, Value = OgcService.XmlMimeTypes }, new Ows100.DomainType() { name = OutputSchemaParameter, Value = ((Discovery)Service).SupportedRecordTypes.Select <IXMetaData, string>(m => m.SchemaName.NamespaceName).ToArray <string>() } }; getRecordById.Parameter = parameters; operations.Add(getRecordById); } if (operations.Count > 0) { return new Ows100.OperationsMetadata() { Operation = operations } } ; return(null); }