query); if (!empty($req)) { if ('WPS' != V::geti('service', '', $request->query)) { throw new Api_WfsException("Only WPS Service is allowed"); } $methodName = "{$req}Action"; if (!method_exists($this, $methodName)) { throw new Api_WfsException("Not Implemented " . htmlspecialchars($req), 501); } $this->DBG("WpsServer->{$methodName}() ...", __LINE__); $document = $this->$methodName($urlQuery); } else { $this->DBG("WpsServer->parseXMLRequest() ...", __LINE__); $document = $this->parseXMLRequest(); header('Content-type: application/xml'); echo ''; echo $document; exit;// TODO: return $document; } IF(V::get('DBG','',$_GET)){echo'
$document (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($document);echo'';}
if ('raw' == V::get('outputFormat', '', $request->query)) {
header('Content-type: text/plain; charset=utf-8');
echo $document;
} else {
header('Content-type: application/xml');
echo $document;
}
}
function parseXMLRequest() {
$data = array();
$tags = [];
$reqContent = Request::getRequestBody();
if (empty($reqContent)) throw new Exception("Empty request");
Lib::loadClass('XML');
$xml = XML::xmlToArray($reqContent);
if (empty($xml)) throw new Exception("Error structure from request");
$rootTagName = $xml[0];
switch ($rootTagName) {
case 'wps:Execute': return $this->_runExecute($xml);
default: throw new Api_WfsException("Not implemented WPS xml request '{$rootTagName}'" . __LINE__, 501);
}
}
function _runExecute($xml) {
$funInfo = self::_parseExecuteXmlArray($xml);
$identifier = V::get('identifier', '', $funInfo);
$args = V::get('args', [], $funInfo, 'array');
if (empty($identifier)) throw new Exception("Parse xml request error - missing identifier");
Lib::loadClass('Api_WpsHelper');
$wpsProcess = Api_WpsHelper::getUserWpsProcess($identifier);
Api_WpsHelper::validateProcessArgs($wpsProcess, $args);
Api_WpsHelper::executeProcess($wpsProcess, $args);
exit;
}
function describeProcessAction() {
$identifier = V::geti('identifier', '', $_REQUEST);
if (empty($identifier)) throw new HttpException("Missing identifier", 400);
if ('JTS:Aarea' === $identifier) return self::exampleDescribeProcess_JTS_Area();
if ('vec:Feature' === $identifier) return self::exampleDescribeProcess_vec_Feature();
$wpsServerUrl = $this->getBaseUri();
$wpsProcess = Api_WpsHelper::getUserWpsProcess($identifier);
if (!$wpsProcess) throw new Api_WfsException("Forbidden", 403);
Api_WpsV1_DescribeProcess::sendDescribeProcessXml($wpsServerUrl, $wpsProcess);
}
static function exampleDescribeProcess_JTS_Area() {
header('Content-type: application/xml; charset=utf-8');
echo '