[Mapbender-commits] r9714 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Mar 27 09:24:30 PDT 2017


Author: armin11
Date: 2017-03-27 09:24:30 -0700 (Mon, 27 Mar 2017)
New Revision: 9714

Modified:
   trunk/mapbender/http/classes/class_owsPostQueryParser.php
Log:
Bugfix for owsproxy post handling

Modified: trunk/mapbender/http/classes/class_owsPostQueryParser.php
===================================================================
--- trunk/mapbender/http/classes/class_owsPostQueryParser.php	2017-03-24 08:47:24 UTC (rev 9713)
+++ trunk/mapbender/http/classes/class_owsPostQueryParser.php	2017-03-27 16:24:30 UTC (rev 9714)
@@ -26,6 +26,7 @@
 	var $serviceType; //string
 	var $serviceVersion; //string
 	var $serviceRequestType; //string
+	var $serviceResourceName; //string - layer name(s), featuretype name(s)
 	var $parsingSuccessful; //boolean
 	/**
 	 * Constructor of the OwsPostQueryHandler
@@ -33,6 +34,7 @@
 	 */
 	function __construct($postData){
 		//parse xml via dom
+		//$e = new mb_exception($postData);
 		$this->parsingSuccessfull = false;
 		$queryDomObject = new DOMDocument();
 		libxml_use_internal_errors(true);
@@ -50,7 +52,23 @@
 		}
 		if ($queryDomObject !== false) {
 			$xpath = new DOMXPath($queryDomObject);
-			$rootNamespace = $queryDomObject->lookupNamespaceUri($queryDomObject->namespaceURI);
+			//test if namespace is used in operation declaration
+			$this->serviceRequestType = $queryDomObject->documentElement->tagName;
+			//explode this
+			$explodedTagName = explode(':', $this->serviceRequestType);
+			if (count($explodedTagName) == 2) {
+				$hasNamespace = true;
+			} else {
+				$hasNamespace = false;
+			}
+			if ($hasNamespace) {
+				$this->serviceRequestType = $explodedTagName[1];
+				//get relevant namespace uri for first element (root)
+				$rootNamespace = $queryDomObject->lookupNamespaceUri($explodedTagName[0]);
+			} else {
+				$rootNamespace = $queryDomObject->lookupNamespaceUri($queryDomObject->namespaceURI);
+			}
+			
 			//$e = new mb_exception("class_owsPostQueryHandler.php: ".json_encode($rootNamespace));
 			switch ($rootNamespace) {
 				case "http://www.opengis.net/wfs/2.0": 
@@ -65,8 +83,23 @@
 					$this->serviceType = "WMS";
                                 	break;
 			}
-			//$xpath->registerNamespace('defaultns', $rootNamespace); 
-			$this->serviceRequestType = $queryDomObject->documentElement->tagName;
+			if ($this->serviceType == "WFS") {
+				//read out typename from wfs query as attribute
+				//register namespace
+				if ($hasNamespace) {
+					$xpath->registerNamespace($explodedTagName[0], $rootNamespace); 
+					$queryNodeList = $xpath->query('/'.$explodedTagName[0].':'.$this->serviceRequestType.'/'.$explodedTagName[0].':Query');
+				} else {
+					$xpath->registerNamespace('defaultns', $rootNamespace);
+					$queryNodeList = $xpath->query('/defaultns:'.$this->serviceRequestType.'/defaultns:Query');
+				}
+				//array of requests that need typenames
+				$typenameRequired = array('getfeature','describefeaturetype');
+				if (in_array(strtolower($this->serviceRequestType), $typenameRequired)) {
+					$this->serviceResourceName = $queryNodeList->item(0)->getAttribute('typeName');
+				}
+			}
+			//$e = new mb_exception("class_owsPostQueryHandler.php: ".$this->serviceRequestType);
 			$this->serviceVersion = $queryDomObject->documentElement->getAttribute("version");
 			//validate extracted parameters
 		}



More information about the Mapbender_commits mailing list