コード例 #1
0
            /// <summary>
            ///  To retrieve informations about the CSW service.
            /// </summary>
            /// <remarks>
            /// </remarks>
            /// <param name="param1">capabilitiesxml details </param>
            private bool ParseCapabilities(string capabilitiesxml) {
                try {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(capabilitiesxml);
                    XmlNamespaceManager xmlnsManager = new XmlNamespaceManager(xmlDoc.NameTable);
                    if (this.Profile.CswNamespace.Length <= 0) {
                        this.Profile.CswNamespace = CswProfiles.DEFAULT_CSW_NAMESPACE;
                    }
                    xmlnsManager.AddNamespace("ows", "http://www.opengis.net/ows");
                    xmlnsManager.AddNamespace("csw", this.Profile.CswNamespace);
                    xmlnsManager.AddNamespace("wrs", "http://www.opengis.net/cat/wrs");
                    xmlnsManager.AddNamespace("wrs10", "http://www.opengis.net/cat/wrs/1.0");
                    xmlnsManager.AddNamespace("xlink", "http://www.w3.org/1999/xlink");
                    xmlnsManager.AddNamespace("wcs", "http://www.opengis.net/wcs");
                    //setting capabilities
                    if (capabilities == null) capabilities = new CswCatalogCapabilities();

                    if (isWCSService(capabilitiesxml))
                    {
                        capabilities.GetRecordByID_GetURL = xmlDoc.SelectSingleNode("/wcs:WCS_Capabilities/wcs:Capability/wcs:Request/wcs:GetCoverage/wcs:DCPType/wcs:HTTP/wcs:Get/wcs:OnlineResource/@xlink:href", xmlnsManager).Value;

                        if (capabilities.GetRecordByID_GetURL == null || capabilities.GetRecordByID_GetURL.Trim().Length == 0)
                        {
                            Utils.logger.writeLog(Resources.NoValidCoverageUrl);
                            throw new Exception(Resources.NoValidCoverageUrl);
                        }
                    }
                    else
                    {

                        if (this.profile.Name == "INSPIRE CSW 2.0.2 AP ISO")
                        {
                            capabilities.GetRecords_PostURL = xmlDoc.SelectSingleNode("//ows:OperationsMetadata/ows:Operation[@name='GetRecords']/ows:DCP/ows:HTTP/ows:Post[translate(ows:Constraint/ows:Value, 'SOAP', 'soap')='soap']/@xlink:href", xmlnsManager).Value;
                            capabilities.GetRecords_IsSoapEndPoint = true;
                        } else
                            capabilities.GetRecords_PostURL = xmlDoc.SelectSingleNode("//ows:OperationsMetadata/ows:Operation[@name='GetRecords']/ows:DCP/ows:HTTP/ows:Post[translate(ows:Constraint/ows:Value, 'XML', 'xml')='xml']/@xlink:href", xmlnsManager).Value;

                        if (capabilities.GetRecords_PostURL == null || capabilities.GetRecords_PostURL.Trim().Length == 0)
                        {
                            Utils.logger.writeLog(Resources.NoValidPostUrl);
                            throw new Exception(Resources.NoValidPostUrl);
                        }

                        capabilities.GetRecordByID_GetURL = xmlDoc.SelectSingleNode("//ows:OperationsMetadata/ows:Operation[@name='GetRecordById']/ows:DCP/ows:HTTP/ows:Get/@xlink:href", xmlnsManager).Value;
                    }

                    return true;
                }
                catch (Exception e) {
                    Utils.logger.writeLog(e.StackTrace);
                    return false;
                }
                
            }
コード例 #2
0
ファイル: CswCatalog.cs プロジェクト: k4th/geoportal-server
            /// <summary>
            ///  To retrieve informations about the CSW service.
            /// </summary>
            /// <remarks>
            /// </remarks>
            /// <param name="param1">capabilitiesxml details </param>
            private bool ParseCapabilities(string capabilitiesxml) {
                try {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(capabilitiesxml);
                    XmlNamespaceManager xmlnsManager = new XmlNamespaceManager(xmlDoc.NameTable);
                    if (this.Profile.CswNamespace.Length <= 0) {
                        this.Profile.CswNamespace = CswProfiles.DEFAULT_CSW_NAMESPACE;
                    }
                    xmlnsManager.AddNamespace("ows", "http://www.opengis.net/ows");
                    xmlnsManager.AddNamespace("csw", this.Profile.CswNamespace);
                    xmlnsManager.AddNamespace("wrs", "http://www.opengis.net/cat/wrs");
                    xmlnsManager.AddNamespace("wrs10", "http://www.opengis.net/cat/wrs/1.0");
                    xmlnsManager.AddNamespace("xlink", "http://www.w3.org/1999/xlink");
                    xmlnsManager.AddNamespace("wcs", "http://www.opengis.net/wcs");
                    //setting capabilities
                    if (capabilities == null) capabilities = new CswCatalogCapabilities();

                    if (isWCSService(capabilitiesxml))
                    {
                        capabilities.GetRecordByID_GetURL = xmlDoc.SelectSingleNode("/wcs:WCS_Capabilities/wcs:Capability/wcs:Request/wcs:GetCoverage/wcs:DCPType/wcs:HTTP/wcs:Get/wcs:OnlineResource", xmlnsManager).Attributes["xlink:href"].Value;

                        if (capabilities.GetRecordByID_GetURL == null || capabilities.GetRecordByID_GetURL.Trim().Length == 0)
                        {
                            Utils.logger.writeLog(Resources.NoValidCoverageUrl);
                            throw new Exception(Resources.NoValidCoverageUrl);
                        }
                    }
                    else
                    {

                     //   XmlNodeList parentNodeList = xmlDoc.SelectNodes("//ows:OperationsMetadata/ows:Operation[@name='GetRecords']/ows:DCP/ows:HTTP/ows:Post", xmlnsManager);

                        capabilities.GetRecords_PostURL = xmlDoc.SelectSingleNode("//ows:OperationsMetadata/ows:Operation[@name='GetRecords']/ows:DCP/ows:HTTP/ows:Post", xmlnsManager).Attributes["xlink:href"].Value;

                      /*  if (parentNodeList.Count > 1)
                        {
                            XmlNodeList nodeList = xmlDoc.SelectNodes("//ows:OperationsMetadata/ows:Operation[@name='GetRecords']/ows:DCP/ows:HTTP/ows:Post/ows:Constraint/ows:Value", xmlnsManager);
                            if (nodeList != null && nodeList.Count >0 && (nodeList.Item(0).InnerText.Equals("SOAP") || nodeList.Item(0).InnerText.Equals("soap")))
                            {
                                capabilities.GetRecords_IsSoapEndPoint = true;
                            }
                            else if(capabilities.GetRecords_PostURL.ToLower().Contains("soap"))
                            {
                                capabilities.GetRecords_IsSoapEndPoint = true;
                            }
                            //  capabilities.GetRecords_PostURL = xmlDoc.SelectSingleNode("//ows:OperationsMetadata/ows:Operation[@name='GetRecords']/ows:DCP/ows:HTTP/ows:Post", xmlnsManager).Attributes["xlink:href"].Value;
                        }*/
                        
                       
                      
                       XmlNodeList nodeList = xmlDoc.SelectNodes("//ows:OperationsMetadata/ows:Operation[@name='GetRecords']/ows:DCP/ows:HTTP/ows:Post/ows:Constraint/ows:Value", xmlnsManager);

                       for (int iter = 0; iter < nodeList.Count; iter++)
                        {
                            capabilities.GetRecords_PostURL = nodeList.Item(iter).ParentNode.ParentNode.Attributes["xlink:href"].Value;

                            if (this.profile.Name == "INSPIRE CSW 2.0.2 AP ISO")
                            {
                                if (nodeList.Item(iter).InnerText.Equals("SOAP") || nodeList.Item(iter).InnerText.Equals("soap") || capabilities.GetRecords_PostURL.ToLower().Contains("soap"))
                                {                                
                                    capabilities.GetRecords_IsSoapEndPoint = true;
                                    break;
                                }
                            }
                            else
                            {
                                if (nodeList.Item(iter).InnerText.Equals("XML") || nodeList.Item(iter).InnerText.Equals("xml"))
                                {
                                     break;
                                }
                            }
                        }
                        


                        if (capabilities.GetRecords_PostURL == null || capabilities.GetRecords_PostURL.Trim().Length == 0)
                        {
                            Utils.logger.writeLog(Resources.NoValidPostUrl);
                            throw new Exception(Resources.NoValidPostUrl);
                        }

                        //   capabilities.GetRecords_PostURL = xmlDoc.SelectSingleNode("//ows:OperationsMetadata/ows:Operation[@name='GetRecords']/ows:DCP/ows:HTTP/ows:Post", xmlnsManager).Attributes["xlink:href"].Value;

                        capabilities.GetRecordByID_GetURL = xmlDoc.SelectSingleNode("//ows:OperationsMetadata/ows:Operation[@name='GetRecordById']/ows:DCP/ows:HTTP/ows:Get", xmlnsManager).Attributes["xlink:href"].Value;
                    }

                    return true;
                }
                catch (Exception e) {
                    Utils.logger.writeLog(e.StackTrace);
                    return false;
                }
                
            }