From db92d37d2f2c6653652f1c8ca2de9352fa463f8f Mon Sep 17 00:00:00 2001
From: ArmandBahi <armand.bahi@veremes.com>
Date: Tue, 25 Sep 2018 10:35:24 +0200
Subject: [PATCH] Add 'vmap/vas/rest/ws/vm4ms/' from commit
 '3062a55117c3d6dc99b81137eb496363d0a72bbc'

git-subtree-dir: vmap/vas/rest/ws/vm4ms
git-subtree-mainline: 0e1e3e3d9fdb87e57414ceaa3e9077e0da2601ff
git-subtree-split: 3062a55117c3d6dc99b81137eb496363d0a72bbc
---
 vas/rest/ws/vm4ms/CoordinateSystem.class.inc  |  131 ++
 vas/rest/ws/vm4ms/CoordinateSystems.class.inc |  318 +++++
 vas/rest/ws/vm4ms/Layer.class.inc             |  276 ++++
 vas/rest/ws/vm4ms/LayerConnection.class.inc   |   87 ++
 vas/rest/ws/vm4ms/LayerConnections.class.inc  |  390 ++++++
 vas/rest/ws/vm4ms/LayerType.class.inc         |   73 ++
 vas/rest/ws/vm4ms/LayerTypes.class.inc        |  130 ++
 vas/rest/ws/vm4ms/LayerWmsService.class.inc   |  103 ++
 vas/rest/ws/vm4ms/LayerWmsServices.class.inc  |  139 +++
 vas/rest/ws/vm4ms/Layers.class.inc            | 1112 +++++++++++++++++
 vas/rest/ws/vm4ms/MapServer.class.inc         |  216 ++++
 .../ws/vm4ms/MapServerDebugLevel.class.inc    |   44 +
 .../ws/vm4ms/MapServerDebugLevels.class.inc   |  130 ++
 vas/rest/ws/vm4ms/Metadata.class.inc          |   87 ++
 vas/rest/ws/vm4ms/Metadatas.class.inc         |  306 +++++
 vas/rest/ws/vm4ms/PrivateLayer.class.inc      |   81 ++
 vas/rest/ws/vm4ms/PrivateLayers.class.inc     |  197 +++
 vas/rest/ws/vm4ms/PrivateWmsService.class.inc |   58 +
 .../ws/vm4ms/PrivateWmsServiceLayer.class.inc |   51 +
 .../vm4ms/PrivateWmsServiceLayers.class.inc   |  146 +++
 .../ws/vm4ms/PrivateWmsServices.class.inc     |  206 +++
 vas/rest/ws/vm4ms/PublicLayer.class.inc       |   80 ++
 vas/rest/ws/vm4ms/PublicLayers.class.inc      |  197 +++
 vas/rest/ws/vm4ms/PublicWmsService.class.inc  |  146 +++
 .../ws/vm4ms/PublicWmsServiceLayer.class.inc  |   51 +
 .../ws/vm4ms/PublicWmsServiceLayers.class.inc |  189 +++
 vas/rest/ws/vm4ms/PublicWmsServices.class.inc |  248 ++++
 vas/rest/ws/vm4ms/Source.class.inc            |   87 ++
 vas/rest/ws/vm4ms/Sources.class.inc           |  292 +++++
 vas/rest/ws/vm4ms/Versions.class.inc          |   79 ++
 .../ws/vm4ms/Vm4msMetadataAccess.class.inc    |  726 +++++++++++
 vas/rest/ws/vm4ms/Vm4msMetadataAccess.sql.inc |   22 +
 vas/rest/ws/vm4ms/Vmap4MapServer.class.inc    |   17 +
 .../ws/vm4ms/Vmap4MapServer.class.sql.inc     |   31 +
 vas/rest/ws/vm4ms/WebObject.class.inc         |  133 ++
 vas/rest/ws/vm4ms/WebObjects.class.inc        |  306 +++++
 vas/rest/ws/vm4ms/WmsService.class.inc        |   86 ++
 vas/rest/ws/vm4ms/WmsServiceLayer.class.inc   |   51 +
 vas/rest/ws/vm4ms/WmsServiceLayers.class.inc  |  290 +++++
 vas/rest/ws/vm4ms/WmsServices.class.inc       |  576 +++++++++
 vas/rest/ws/vm4ms/overview.phtml              |   24 +
 41 files changed, 7912 insertions(+)
 create mode 100755 vas/rest/ws/vm4ms/CoordinateSystem.class.inc
 create mode 100755 vas/rest/ws/vm4ms/CoordinateSystems.class.inc
 create mode 100755 vas/rest/ws/vm4ms/Layer.class.inc
 create mode 100755 vas/rest/ws/vm4ms/LayerConnection.class.inc
 create mode 100755 vas/rest/ws/vm4ms/LayerConnections.class.inc
 create mode 100755 vas/rest/ws/vm4ms/LayerType.class.inc
 create mode 100755 vas/rest/ws/vm4ms/LayerTypes.class.inc
 create mode 100755 vas/rest/ws/vm4ms/LayerWmsService.class.inc
 create mode 100755 vas/rest/ws/vm4ms/LayerWmsServices.class.inc
 create mode 100755 vas/rest/ws/vm4ms/Layers.class.inc
 create mode 100755 vas/rest/ws/vm4ms/MapServer.class.inc
 create mode 100755 vas/rest/ws/vm4ms/MapServerDebugLevel.class.inc
 create mode 100755 vas/rest/ws/vm4ms/MapServerDebugLevels.class.inc
 create mode 100755 vas/rest/ws/vm4ms/Metadata.class.inc
 create mode 100755 vas/rest/ws/vm4ms/Metadatas.class.inc
 create mode 100755 vas/rest/ws/vm4ms/PrivateLayer.class.inc
 create mode 100755 vas/rest/ws/vm4ms/PrivateLayers.class.inc
 create mode 100755 vas/rest/ws/vm4ms/PrivateWmsService.class.inc
 create mode 100755 vas/rest/ws/vm4ms/PrivateWmsServiceLayer.class.inc
 create mode 100755 vas/rest/ws/vm4ms/PrivateWmsServiceLayers.class.inc
 create mode 100755 vas/rest/ws/vm4ms/PrivateWmsServices.class.inc
 create mode 100755 vas/rest/ws/vm4ms/PublicLayer.class.inc
 create mode 100755 vas/rest/ws/vm4ms/PublicLayers.class.inc
 create mode 100755 vas/rest/ws/vm4ms/PublicWmsService.class.inc
 create mode 100755 vas/rest/ws/vm4ms/PublicWmsServiceLayer.class.inc
 create mode 100755 vas/rest/ws/vm4ms/PublicWmsServiceLayers.class.inc
 create mode 100755 vas/rest/ws/vm4ms/PublicWmsServices.class.inc
 create mode 100755 vas/rest/ws/vm4ms/Source.class.inc
 create mode 100755 vas/rest/ws/vm4ms/Sources.class.inc
 create mode 100755 vas/rest/ws/vm4ms/Versions.class.inc
 create mode 100755 vas/rest/ws/vm4ms/Vm4msMetadataAccess.class.inc
 create mode 100755 vas/rest/ws/vm4ms/Vm4msMetadataAccess.sql.inc
 create mode 100755 vas/rest/ws/vm4ms/Vmap4MapServer.class.inc
 create mode 100755 vas/rest/ws/vm4ms/Vmap4MapServer.class.sql.inc
 create mode 100755 vas/rest/ws/vm4ms/WebObject.class.inc
 create mode 100755 vas/rest/ws/vm4ms/WebObjects.class.inc
 create mode 100755 vas/rest/ws/vm4ms/WmsService.class.inc
 create mode 100755 vas/rest/ws/vm4ms/WmsServiceLayer.class.inc
 create mode 100755 vas/rest/ws/vm4ms/WmsServiceLayers.class.inc
 create mode 100755 vas/rest/ws/vm4ms/WmsServices.class.inc
 create mode 100755 vas/rest/ws/vm4ms/overview.phtml

diff --git a/vas/rest/ws/vm4ms/CoordinateSystem.class.inc b/vas/rest/ws/vm4ms/CoordinateSystem.class.inc
new file mode 100755
index 00000000..3100068a
--- /dev/null
+++ b/vas/rest/ws/vm4ms/CoordinateSystem.class.inc
@@ -0,0 +1,131 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file CoordinateSystem.class.inc
+ * \class CoordinateSystem
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the CoordinateSystem php class
+ *
+ * This class defines operation for one coordinate system
+ * 
+ */
+class CoordinateSystem extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("coordsys_id", "epsg", "definition", "label", "epsg_definition");
+    }
+
+    /**
+     * @SWG\Get(path="/coordinatesystems/{coordsys_id}", 
+     *   tags={"CoordinateSystems"},
+     *   summary="Get coordinate system",
+     *   description="Request to get coordinate system by id",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="coordsys_id",
+     *     in="path",
+     *     description="coordsys id",
+     *     required=true,
+     *     type="string",
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/coordinatesystems")
+     *     )
+     *  )
+     */
+
+    /**
+     * get informations about coordinate system
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        $this->aFields = $this->getFields($this->aProperties['schema_vm4ms'], 'coordsys', 'coordsys_id');
+    }
+
+    /**
+     * delete a coordinate system
+     */
+    function DELETE() {
+        require $this->sRessourcesFile;
+        $bLayersExist = false;
+
+        // Vérifie qu'il y ait aucune couche associée
+        if ($this->areLayersAssociated()) {
+            $bLayersExist = true;
+            $this->oError = new VitisError(1, 'ERROR_LAYER_ASSOCIATED');
+            $this->oConnection->oError = new VitisError(1, 'ERROR_LAYER_ASSOCIATED');
+        }
+
+        if (!$bLayersExist) {
+            $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'coordsys', 'coordsys_id', $this->aValues['my_vitis_id'], 'string');
+            if ($this->oConnection->oBd->enErreur()) {
+                $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+            } else {
+                $this->aFields['coordsys_id'] = $this->aValues['my_vitis_id'];
+            }
+        }
+    }
+
+    /**
+     * Return true if a layer is associated
+     * @return boolean
+     */
+    function areLayersAssociated() {
+        require_once 'Layers.class.inc';
+
+        $aGetLayersPath = Array('vm4ms', 'layers');
+
+        $this->aValues['my_vitis_id'] = trim($this->aValues['my_vitis_id'], '"');
+        $this->aValues['my_vitis_id'] = trim($this->aValues['my_vitis_id'], "'");
+
+        // Récupère l'id du service vMap
+        $aGetLayersValues = Array(
+            'token' => $this->aValues['token'],
+            'filter' => '{"relation": "AND", "operators": [{"column": "coordsys_id", "compare_operator": "=", "value": ' . $this->aValues['my_vitis_id'] . '}]}',
+            'vitis_version' => $this->aValues['vitis_version'],
+            'id' => 'layers',
+            'output' => $this->aValues['output'],
+            'sEncoding' => $this->aValues['sEncoding'],
+            'sSourceEncoding' => $this->aValues['sSourceEncoding'],
+            'xslstylesheet' => $this->aValues['xslstylesheet'],
+            'module' => 'vm4ms'
+        );
+        $oLayers = new Layers($aGetLayersPath, $aGetLayersValues, $this->aProperties);
+        $oLayers->GET();
+
+        if (count($oLayers->aObjects) > 0) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/CoordinateSystems.class.inc b/vas/rest/ws/vm4ms/CoordinateSystems.class.inc
new file mode 100755
index 00000000..af573c39
--- /dev/null
+++ b/vas/rest/ws/vm4ms/CoordinateSystems.class.inc
@@ -0,0 +1,318 @@
+<?php
+
+/**
+ * \file CoordinateSystems.class.inc
+ * \class CoordinateSystems
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the CoordinateSystems php class
+ *
+ * This class defines Rest Api to Vmap4MapServer CoordinateSystems
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'CoordinateSystem.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+require_once 'Vm4msMetadataAccess.class.inc';
+
+class CoordinateSystems extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/coordinatesystems",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/coordinatesystems")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="CoordinateSystems",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("coordsys_id", "epsg", "definition", "label", "epsg_definition");
+    }
+
+    /**
+     * @SWG\Get(path="/coordinatesystems",
+     *   tags={"CoordinateSystems"},
+     *   summary="Get coordinate systems",
+     *   description="Request to get coordinate systems",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/coordinatesystems")
+     *     )
+     *  )
+     */
+
+    /**
+     * get CoordinateSystems
+     * @return  CoordinateSystems
+     */
+    function GET() {
+        $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'coordsys', 'coordsys_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Post(path="/coordinatesystems",
+     *   tags={"CoordinateSystems"},
+     *   summary="Add coordinate system",
+     *   description="Request to add a coordinate system",
+     *   operationId="POST",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="formData",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="coordsys_id",
+     *     in="formData",
+     *     description="srid",
+     *     required=true,
+     *     type="integer"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="epsg",
+     *     in="formData",
+     *     description="epsg code",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="definition",
+     *     in="formData",
+     *     description="definition",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/coordinatesystems")
+     *   )
+     *  )
+     * )
+     */
+
+    /**
+     * insert coordinate system
+     * @return array containing the status and the message
+     */
+    function POST() {
+        $aReturn = $this->genericPost($this->aProperties['schema_vm4ms'], 'coordsys', false, 'coordsys_id');
+        if ($aReturn['sStatus'] == 1) {
+            $aXmlRacineAttribute['status'] = 1;
+            $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            $oCoordinateSystem = new CoordinateSystem($this->aPath, $this->aValues, $this->aProperties, $this->oConnection);
+            $oCoordinateSystem->GET();
+        } else {
+            $sMessage = $aReturn['sMessage'];
+        }
+        return $sMessage;
+    }
+
+    /**
+     * @SWG\Put(path="/coordinatesystems/{coordsys_id}",
+     *   tags={"CoordinateSystems"},
+     *   summary="Update CoordinateSystem",
+     *   description="Request to update coordinate system",
+     *   operationId="PUT",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   consumes= { "multipart/form-data"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="coordsys_id",
+     *     in="path",
+     *     description="srid",
+     *     required=true,
+     *     type="integer"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="epsg",
+     *     in="query",
+     *     description="epsg code",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="definition",
+     *     in="query",
+     *     description="definition",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/coordinatesystems")
+     *     ),
+     * 
+     *  )
+     */
+
+    /**
+     * modify coordinate system
+     * @return array containing the status and the message
+     */
+    function PUT() {
+        $aReturn = $this->genericPut($this->aProperties['schema_vm4ms'], 'coordsys', 'coordsys_id');
+
+        // Génère les fichiers de projection        
+        $oVm4msMetadataAccess = new Vm4msMetadataAccess($this->oConnection->oBd, '', '', session_id(), $this->aProperties);
+        $oVm4msMetadataAccess->generateProjFiles();
+
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Delete(path="/coordinatesystems/",
+     *   tags={"CoordinateSystems"},
+     *   summary="delete CoordinateSystem",
+     *   description="Request to delete CoordinateSystem",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="idList",
+     *     in="query",
+     *     description="id of the coordinate systems",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/coordinatesystems")
+     *     )
+     *  )
+     */
+    /**
+     * @SWG\Delete(path="/coordinatesystems/{coordsys_id}",
+     *   tags={"CoordinateSystems"},
+     *   summary="delete CoordinateSystem",
+     *   description="Request to delete CoordinateSystem",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="coordsys_id",
+     *     in="path",
+     *     description="id of the coordinate system",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/coordinatesystems")
+     *     )
+     *  )
+     */
+
+    /**
+     * delete coordinate system
+     * @return id of coordinate system deleted or error object if a coordinate system is not deleted
+     */
+    function DELETE() {
+        $aReturn = $this->genericDelete($this->aProperties['schema_vm4ms'], 'coordsys', 'coordsys_id');
+        return $aReturn['sMessage'];
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/Layer.class.inc b/vas/rest/ws/vm4ms/Layer.class.inc
new file mode 100755
index 00000000..7ae59498
--- /dev/null
+++ b/vas/rest/ws/vm4ms/Layer.class.inc
@@ -0,0 +1,276 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file Layer.class.inc
+ * \class Layer
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the Layer php class
+ *
+ * This class defines operation for one layer
+ *
+ */
+class Layer extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layer_id", "name", "title", "coordsys_id", "coordsys_label", "source_id", "connection_id", "tableschema", "tablename", "tableidfield", "definition", "opacity", "active", "ms_layertype_id", "wmsservices", "wmsservices_label", "private_connection", "connection_label", "source_label", "definitiontmp", "metadata_id");
+    }
+
+    /**
+     * @SWG\Get(path="/layers/{ms_layer_id}",
+     *   tags={"Layers"},
+     *   summary="Get layer",
+     *   description="Request to get layer by id",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="ms_layer_id",
+     *     in="path",
+     *     description="layer id",
+     *     required=true,
+     *     type="string",
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layers")
+     *     )
+     *  )
+     */
+
+    /**
+     * get informations about layer
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        // Infos de la couche.
+        $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+        $aParams['ms_layer_id'] = array('value' => $this->aValues['my_vitis_id'], 'type' => 'number');
+        $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getLayer'], $aParams);
+        if ($this->oConnection->oBd->nombreLigne($oPDOresult) > 0) {
+            $this->aFields = $this->oConnection->oBd->ligneSuivante($oPDOresult);
+            // Flux wms rattachés à la couche.
+            if (in_array("wmsservices", $this->aSelectedFields)) {
+                $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getLayerWmsServices'], $aParams);
+                $sListWmsServiceId = "";
+                $aListWmsServiceName = array();
+                while ($aLigne = $this->oConnection->oBd->ligneSuivante($oPDOresult)) {
+                    if ($sListWmsServiceId == "")
+                        $sListWmsServiceId = $aLigne["wmsservice_id"];
+                    else
+                        $sListWmsServiceId .= "|" . $aLigne["wmsservice_id"];
+                    $aListWmsServiceName[] = $aLigne["wmsservice_id"];
+                }
+                $oPDOresult = $this->oConnection->oBd->fermeResultat();
+                $this->aFields['wmsservices'] = $sListWmsServiceId;
+                $this->aFields['wmsservices_label'] = implode(',', $aListWmsServiceName);
+            }
+        }
+    }
+
+    /**
+     * delete a layer
+     */
+    function DELETE() {
+        require $this->sRessourcesFile;
+        // Liste des flux WMS associés à la couche.
+        $aWmsServicesId = array();
+        $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+        $aParams['ms_layer_id'] = array('value' => $this->aValues['my_vitis_id'], 'type' => 'number');
+
+        // Services associés
+        $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getLayerWmsServices'], $aParams);
+        while ($aLigne = $this->oConnection->oBd->ligneSuivante($oPDOresult)) {
+            $aWmsServicesId[] = $aLigne['wmsservice_id'];
+        }
+
+        // Nom de la couche.
+        $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getLayerName'], $aParams);
+        $aLayer = $this->oConnection->oBd->ligneSuivante($oPDOresult);
+        $oPDOresult = $this->oConnection->oBd->fermeResultat();
+
+        // Test si la couche est associée à un calque
+        $bAreVmapCalquesAssociated = $this->areVmapCalquesAssociated($aWmsServicesId, $aLayer['name']);
+
+        if ($bAreVmapCalquesAssociated === false) {
+            // Supprime l'association des flux WMS rattachés à la couche.
+            $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'wmsservice_ms_layer', 'ms_layer_id', $this->aValues["my_vitis_id"]);
+            // Création du fichier .map de tous les flux WMS associés à la couche.
+            $oLayer = new Layer($this->aPath, $this->aValues, $this->aProperties, $this->oConnection);
+            $oLayer->GET();
+            $oLayer->createLayerWmsServicesMapFile($oLayer->aFields['private_connection'], $aWmsServicesId);
+            // Supprime la couche.
+            $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'ms_layer', 'name', $aLayer['name'], 'text');
+            if ($this->oConnection->oBd->enErreur()){
+                $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+            }else{
+                $this->aFields['ms_layer_id'] = $this->aValues['my_vitis_id'];
+                // Supprime le template GetFeatureInfo associé
+                $oVm4msMetadataAccess = new Vm4msMetadataAccess($this->oConnection->oBd, '', '', session_id(), $this->aProperties);
+                $oVm4msMetadataAccess->deleteGetFeatureInfoTemplate($this->aValues['my_vitis_id'], $this->aValues['token'], $aLayer['name']);
+            }
+        }else {
+            $sErrorMessage = 'Le ou les calque(s) vMap suivants sont associés à cette couche: ' . implode(', ', $bAreVmapCalquesAssociated);
+            $this->oError = new VitisError(1, $sErrorMessage);
+            $this->oConnection->oError = new VitisError(1, $sErrorMessage);
+        }
+    }
+
+    /**
+     * Création du fichier .map (prod.) de tous les flux WMS associés à la couche.
+     * @param boolean $bPrivateConnection
+     * @param array $aWmsServicesId
+     * @return message
+     */
+    function createLayerWmsServicesMapFile($bPrivateConnection, $aWmsServicesId = array()) {
+        require $this->sRessourcesFile;
+        // Flux WMS privé.
+        if ($bPrivateConnection) { // $this->aFields['private_connection']
+            /*
+              $aValues = array('token' => session_id(), 'wmsservice_id' => $this->aProperties['private_wms_service'], 'my_vitis_id' => $this->aProperties['private_wms_service'], 'type' => 'prod');
+              $oWmsServices = new WmsServices($this->aPath, $aValues, $this->aProperties, $this->oConnection);
+              $oWmsServices->GET();
+              $oWmsServices->createMapFile();
+             */
+        } else {
+            // Tous les fluxs WMS publics.
+            if (empty($aWmsServicesId)) {
+                $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+                $aParams['ms_layer_id'] = array('value' => $this->aValues['my_vitis_id'], 'type' => 'number');
+                $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getLayerWmsServices'], $aParams);
+                while ($aLigne = $this->oConnection->oBd->ligneSuivante($oPDOresult)) {
+                    $aWmsServicesId[] = $aLigne['wmsservice_id'];
+                }
+                $oPDOresult = $this->oConnection->oBd->fermeResultat();
+            }
+            // Création des fichiers .map des flux WMS.
+            foreach ($aWmsServicesId as $sWmsServiceId) {
+                $aValues = array('token' => session_id(), 'wmsservice_id' => $sWmsServiceId, 'my_vitis_id' => $sWmsServiceId, 'type' => 'prod', 'sEncoding' => $this->aValues['sEncoding'], 'sSourceEncoding' => $this->aValues['sSourceEncoding'], 'output' => $this->aValues['output']);
+                $oWmsServices = new WmsServices($this->aPath, $aValues, $this->aProperties, $this->oConnection);
+                $oWmsServices->GET();
+                $oWmsServices->createMapFile();
+            }
+        }
+    }
+
+    /**
+     * Return false if any vMap calque is associated to the layer, otherwise returns the list of the associated calques
+     * @param string $aWmsServices
+     * @param type $sLayerName
+     * @return string|false
+     */
+    function areVmapCalquesAssociated($aWmsServices, $sLayerName) {
+        require $this->sRessourcesFile;
+
+        if (!count($aWmsServices) > 0) {
+            return false;
+        }
+
+        for ($i = 0; $i < count($aWmsServices); $i++) {
+            $aWmsServices[$i] = "'vm4ms_" . $aWmsServices[$i] . "'";
+        }
+
+        if (!count($aWmsServices) > 0) {
+            return false;
+        }
+
+        $aParams['sSchemaVm4ms'] = array();
+        $aSql['getVmapCalquesFromVM4MSService'] = str_replace('[serviceIdList]', implode(',', $aWmsServices), $aSql['getVmapCalquesFromVM4MSService']);
+
+        $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getVmapCalquesFromVM4MSService'], $aParams);
+        $aCalques = $this->oConnection->oBd->getResultTableAssoc($oPDOresult);
+
+        $bAreVmapCalquesAssociated = false;
+        for ($i = 0; $i < count($aCalques); $i++) {
+            $aCalqueLayerList = explode(',', $aCalques[$i]['layer_list']);
+            if (in_array($sLayerName, $aCalqueLayerList)) {
+                if ($bAreVmapCalquesAssociated === false) {
+                    $bAreVmapCalquesAssociated = array($aCalques[$i]['name']);
+                } else {
+                    array_push($bAreVmapCalquesAssociated, $aCalques[$i]['name']);
+                }
+            }
+        }
+        return $bAreVmapCalquesAssociated;
+    }
+
+    /**
+     * Test la définition de la couche passée en paramètre
+     * en comptant les mots clés et les balises END
+     */
+    function testDefinitionIndent() {
+
+        $sDefinition = $this->aFields['definition'];
+        if (!empty($sDefinition)) {
+
+            /**
+             * Mots clés nécessitant une balise END
+             */
+            $aTagKeywords = array('COMPOSITE', 'MAP', 'LINESET', 'MARKERSET', 'POINTS', 'SHADESET', 'STYLE', 'CLASS', 'FEATURE', 'JOIN', 'LABEL', 'LAYER', 'LEGEND', 'PROJECTION', 'GRID', 'QUERY', 'OUTPUTFORMAT', 'QUERYMAP', 'REFERENCE', 'SCALEBAR', 'WEB', 'METADATA', 'FONTSET', 'SYMBOLSET', 'VALIDATION', 'PATTERN');
+
+            $sTagKeywords = '';
+            $iTagKeywords = 0;
+            $iEndKeywords = $this->countTagsInDefinition($sDefinition, 'END');
+            for ($i = 0; $i < count($aTagKeywords); $i++) {
+                $iSubStrCount = $this->countTagsInDefinition($sDefinition, $aTagKeywords[$i]);
+                if ($iSubStrCount > 0) {
+                    $iTagKeywords += $iSubStrCount;
+                    if (!empty($sTagKeywords)) {
+                        $sTagKeywords .= ', ';
+                    }
+                    $sTagKeywords .= $aTagKeywords[$i] . ': ' . $iSubStrCount;
+                }
+            }
+            if ($iTagKeywords === $iEndKeywords) {
+                $this->aFields['definition_structure_valid'] = true;
+            } else {
+                $this->aFields['definition_structure_valid'] = false;
+                if ($iTagKeywords > $iEndKeywords) {
+                    $this->aFields['definition_structure_error'] = 'MISSING_END_TAG';
+                } else if ($iTagKeywords < $iEndKeywords) {
+                    $this->aFields['definition_structure_error'] = 'TOO_MUCH_END_TAGS';
+                } else {
+                    $this->aFields['definition_structure_error'] = 'INDETERMINATED_ERROR';
+                }
+                $this->aFields['definition_structure_tags'] = $sTagKeywords . ', END: ' . $iEndKeywords;
+            }
+        }
+    }
+
+    /**
+     * Compte le nombre de fois qu'une balise est définie dans la définition
+     * @param string $sDefinition
+     * @param string $sTag
+     * @return integer
+     */
+    function countTagsInDefinition($sDefinition, $sTag) {
+        // Tous les mots entiers ne commencant pas par { ou #
+        return preg_match_all('/((?:[^{#"]|\A)(\b))' . $sTag . '(\b|\Z)/', $sDefinition);
+    }
+
+}
+
+?>
diff --git a/vas/rest/ws/vm4ms/LayerConnection.class.inc b/vas/rest/ws/vm4ms/LayerConnection.class.inc
new file mode 100755
index 00000000..2b7d8a96
--- /dev/null
+++ b/vas/rest/ws/vm4ms/LayerConnection.class.inc
@@ -0,0 +1,87 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file LayerConnection.class.inc
+ * \class LayerConnection
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the LayerConnection php class
+ *
+ * This class defines operation for one connection
+ * 
+ */
+class LayerConnection extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("connection_id", "name", "private", "server", "port", "database", "user", "password");
+    }
+
+    /**
+     * @SWG\Get(path="/layerconnections/{connection_id}",
+     *   tags={"LayerConnections"},
+     *   summary="Get connection",
+     *   description="Request to get connection by id",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="connection_id",
+     *     in="path",
+     *     description="connection id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layerconnections")
+     *     )
+     *  )
+     */
+
+    /**
+     * get informations about connection
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        $this->aFields = $this->getFields($this->aProperties['schema_vm4ms'], 'connection', 'connection_id');
+    }
+
+    /**
+     * delete a connection
+     */
+    function DELETE() {
+        require $this->sRessourcesFile;
+        $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'connection', 'connection_id', $this->aValues['my_vitis_id'], 'string');
+        if ($this->oConnection->oBd->enErreur()) {
+            $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+        } else {
+            $this->aFields['connection_id'] = $this->aValues['my_vitis_id'];
+        }
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/LayerConnections.class.inc b/vas/rest/ws/vm4ms/LayerConnections.class.inc
new file mode 100755
index 00000000..66b6308a
--- /dev/null
+++ b/vas/rest/ws/vm4ms/LayerConnections.class.inc
@@ -0,0 +1,390 @@
+<?php
+
+/**
+ * \file LayerConnections.class.inc
+ * \class LayerConnections
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the LayerConnections php class
+ *
+ * This class defines Rest Api to Vmap4MapServer Connections
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'LayerConnection.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+
+class LayerConnections extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/layerconnections",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/layerconnections")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="LayerConnections",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("connection_id", "name", "private", "server", "port", "database", "user", "password");
+    }
+
+    /**
+     * @SWG\Get(path="/layerconnections",
+     *   tags={"LayerConnections"},
+     *   summary="Get connection",
+     *   description="Request to get connection",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layerconnections")
+     *     )
+     *  )
+     */
+
+    /**
+     * get LayerConnections
+     * @return  LayerConnections
+     */
+    function GET() {
+        $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'connection', 'connection_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Post(path="/layerconnections",
+     *   tags={"LayerConnections"},
+     *   summary="Add connection",
+     *   description="Request to add a connection",
+     *   operationId="POST",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="formData",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="name",
+     *     in="formData",
+     *     description="name",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="server",
+     *     in="formData",
+     *     description="server",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="database",
+     *     in="formData",
+     *     description="database",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="port",
+     *     in="formData",
+     *     description="port",
+     *     required=true,
+     *     type="integer"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="user",
+     *     in="formData",
+     *     description="user",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="password",
+     *     in="formData",
+     *     description="password",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="private",
+     *     in="formData",
+     *     description="private",
+     *     required=true,
+     *     type="boolean",
+     *     default=false
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layerconnections")
+     *   )
+     *  )
+     * )
+     */
+
+    /**
+     * insert connection
+     * @return array containing the status and the message
+     */
+    function POST() {
+        if (!empty($this->aValues['private']) && $this->aValues['private'] == 'true') {
+            $this->aValues['server'] = '';
+            $this->aValues['port'] = '';
+            $this->aValues['user'] = '';
+            $this->aValues['password'] = '';
+        }
+        $aReturn = $this->genericPost($this->aProperties['schema_vm4ms'], 'connection', $this->aProperties['schema_vm4ms'] . '.seq_common', 'connection_id');
+        if ($aReturn['sStatus'] == 1) {
+            $aXmlRacineAttribute['status'] = 1;
+            $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            $oLayerConnection = new LayerConnection($this->aPath, $this->aValues, $this->aProperties, $this->oConnection);
+            $oLayerConnection->GET();
+        } else {
+            $sMessage = $aReturn['sMessage'];
+        }
+        return $sMessage;
+    }
+
+    /**
+     * @SWG\Put(path="/layerconnections/{connection_id}",
+     *   tags={"LayerConnections"},
+     *   summary="Update LayerConnection",
+     *   description="Request to update connection",
+     *   operationId="PUT",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   consumes= { "multipart/form-data"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="connection_id",
+     *     in="path",
+     *     description="connection id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="name",
+     *     in="query",
+     *     description="name",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="server",
+     *     in="query",
+     *     description="server",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="database",
+     *     in="query",
+     *     description="database",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="port",
+     *     in="query",
+     *     description="port",
+     *     required=false,
+     *     type="integer"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="user",
+     *     in="query",
+     *     description="user",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="password",
+     *     in="query",
+     *     description="password",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="private",
+     *     in="query",
+     *     description="private",
+     *     required=false,
+     *     type="boolean",
+     *     default=false
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layerconnections")
+     *     ),
+     * 
+     *  )
+     */
+
+    /**
+     * modify connection
+     * @return array containing the status and the message
+     */
+    function PUT() {
+        if (!empty($this->aValues['private']) && $this->aValues['private'] == 'true') {
+            $this->aValues['server'] = '';
+            $this->aValues['port'] = '';
+            $this->aValues['user'] = '';
+            $this->aValues['password'] = '';
+        }
+        $aReturn = $this->genericPut($this->aProperties['schema_vm4ms'], 'connection', 'connection_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Delete(path="/layerconnections/",
+     *   tags={"LayerConnections"},
+     *   summary="delete LayerConnection",
+     *   description="Request to delete LayerConnection",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="idList",
+     *     in="query",
+     *     description="id of the connections",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layerconnections")
+     *     )
+     *  )
+     */
+    /**
+     * @SWG\Delete(path="/layerconnections/{connection_id}",
+     *   tags={"LayerConnections"},
+     *   summary="delete LayerConnection",
+     *   description="Request to delete LayerConnection",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="connection_id",
+     *     in="path",
+     *     description="id of the connection",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layerconnections")
+     *     )
+     *  )
+     */
+
+    /**
+     * delete connection
+     * @return id of connection deleted or error object if a connection is not deleted
+     */
+    function DELETE() {
+        $aReturn = $this->genericDelete($this->aProperties['schema_vm4ms'], 'connection', 'connection_id');
+        return $aReturn['sMessage'];
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/LayerType.class.inc b/vas/rest/ws/vm4ms/LayerType.class.inc
new file mode 100755
index 00000000..db41b66f
--- /dev/null
+++ b/vas/rest/ws/vm4ms/LayerType.class.inc
@@ -0,0 +1,73 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file LayerType.class.inc
+ * \class LayerType
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the LayerType php class
+ *
+ * This class defines operation for one layer type
+ * 
+ */
+class LayerType extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layertype_id");
+    }
+
+    /**
+     * @SWG\Get(path="/layertypes/{ms_layertype_id}", 
+     *   tags={"LayerTypes"},
+     *   summary="Get layer type",
+     *   description="Request to get layer type by id",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="ms_layertype_id",
+     *     in="path",
+     *     description="layer type id",
+     *     required=true,
+     *     type="string",
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layertypes")
+     *     )
+     *  )
+     */
+
+    /**
+     * get informations about layer type
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        $this->aFields = $this->getFields($this->aProperties['schema_vm4ms'], 'ms_layertype', 'ms_layertype_id');
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/LayerTypes.class.inc b/vas/rest/ws/vm4ms/LayerTypes.class.inc
new file mode 100755
index 00000000..f4983030
--- /dev/null
+++ b/vas/rest/ws/vm4ms/LayerTypes.class.inc
@@ -0,0 +1,130 @@
+<?php
+
+/**
+ * \file LayerTypes.class.inc
+ * \class LayerTypes
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the LayerTypes php class
+ *
+ * This class defines Rest Api to Vmap4MapServer LayerTypes
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'LayerType.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+
+class LayerTypes extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/layertypes",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/layertypes")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="LayerTypes",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layertype_id");
+    }
+
+    /**
+     * @SWG\Get(path="/layertypes",
+     *   tags={"LayerTypes"},
+     *   summary="Get layertypes",
+     *   description="Request to get layer types",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layertypes")
+     *     )
+     *  )
+     */
+
+    /**
+     * get LayerTypes
+     * @return  LayerTypes
+     */
+    function GET() {
+        $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'ms_layertype', 'ms_layertype_id');
+        return $aReturn['sMessage'];
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/LayerWmsService.class.inc b/vas/rest/ws/vm4ms/LayerWmsService.class.inc
new file mode 100755
index 00000000..ae1a5e2c
--- /dev/null
+++ b/vas/rest/ws/vm4ms/LayerWmsService.class.inc
@@ -0,0 +1,103 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file LayerWmsService.class.inc
+ * \class LayerWmsService
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the LayerWmsService php class
+ *
+ * This class defines operation for one  wms service layer
+ * 
+ */
+class LayerWmsService extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layer_id", "name", "title", "coordsys_id", "source_id", "connection_id", "tableschema", "tablename", "tableidfield", "definition", "opacity", "active", "ms_layertype_id", "wmsservices", "wmsservices_label", "private_connection", "connection_label", "source_label", "definitiontmp");
+    }
+
+    /**
+     * @SWG\Get(path="/layerwmsservices/{ms_layer_id}", 
+     *   tags={"LayerWmsServices"},
+     *   summary="Get layer",
+     *   description="Request to get layer by id",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="ms_layer_id",
+     *     in="path",
+     *     description="layer id",
+     *     required=true,
+     *     type="string",
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layerwmsservices")
+     *     )
+     *  )
+     */
+
+    /**
+     * get informations about wms service layer
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        // Infos de la couche.
+        $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+        $aParams['ms_layer_id'] = array('value' => $this->aValues['my_vitis_id'], 'type' => 'number');
+        $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getLayer'], $aParams);
+        if ($this->oConnection->oBd->nombreLigne($oPDOresult) > 0) {
+            $this->aFields = $this->oConnection->oBd->ligneSuivante($oPDOresult);
+            // Flux wms rattachés à la couche.
+            if (in_array("wmsservices", $this->aSelectedFields)) {
+                $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getLayerWmsServices'], $aParams);
+                $sListWmsServiceId = "";
+                $aListWmsServiceName = array();
+                while ($aLigne = $this->oConnection->oBd->ligneSuivante($oPDOresult)) {
+                    if ($sListWmsServiceId == "")
+                        $sListWmsServiceId = $aLigne["wmsservice_id"];
+                    else
+                        $sListWmsServiceId .= "|" . $aLigne["wmsservice_id"];
+                    $aListWmsServiceName[] = $aLigne["wmsservice_id"];
+                }
+                $oPDOresult = $this->oConnection->oBd->fermeResultat();
+                $this->aFields['wmsservices'] = $sListWmsServiceId;
+                $this->aFields['wmsservices_label'] = implode(',', $aListWmsServiceName);
+            }
+        }
+    }
+
+    /**
+     * delete a wms service layer
+     */
+    function DELETE() {
+        
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/LayerWmsServices.class.inc b/vas/rest/ws/vm4ms/LayerWmsServices.class.inc
new file mode 100755
index 00000000..9d47345f
--- /dev/null
+++ b/vas/rest/ws/vm4ms/LayerWmsServices.class.inc
@@ -0,0 +1,139 @@
+<?php
+
+/**
+ * \file LayerWmsServices.class.inc
+ * \class LayerWmsServices
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the LayerWmsServices php class
+ *
+ * This class defines Rest Api to Vmap LayerWmsServices
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'LayerWmsService.class.inc';
+require_once 'WmsServices.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+
+class LayerWmsServices extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/layerwmsservices",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/layerwmsservices")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="LayerWmsServices",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layer_id", "name", "title", "coordsys_id", "source_id", "connection_id", "tableschema", "tablename", "tableidfield", "definition", "opacity", "active", "ms_layertype_id", "private_connection", "connection_label", "source_label", "definitiontmp");
+    }
+
+    /**
+     * get  wms service layers
+     * @return LayerWmsServices
+     */
+    function GET() {
+        $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'v_ms_layer', 'ms_layer_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Put(path="/layerwmsservices/{ms_layer_id}",
+     *   tags={"LayerWmsServices"},
+     *   summary="Update layer wms services",
+     *   description="Request to update the wms services of a layer",
+     *   operationId="PUT",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="ms_layer_id",
+     *     in="path",
+     *     description="Id of the layer",
+     *     required=true,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="wmsservices",
+     *     in="query",
+     *     description="Layers of the wms service",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Properties Response",
+     *         @SWG\Schema(ref="#/definitions/layerwmsservices")
+     *     )
+     *  )
+     */
+
+    /**
+     * modify layers of wms service
+     * @return array containing the status and the message
+     */
+    function PUT() {
+        require $this->sRessourcesFile;
+        // Supprime l'association des flux WMS rattachés à la couche.
+        $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'wmsservice_ms_layer', 'ms_layer_id', $this->aValues["my_vitis_id"]);
+        // Couches à rattacher à la carte ?
+        if (!empty($this->aValues['wmsservices'])) {
+            $aWmsServices = explode('|', $this->aValues['wmsservices']);
+            foreach ($aWmsServices as $sWmsService) {
+                $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+                $aParams['ms_layer_id'] = array('value' => $this->aValues['my_vitis_id'], 'type' => 'number');
+                $aParams['wmsservice_id'] = array('value' => $sWmsService, 'type' => 'string');
+                $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['insertLayerWmsServices'], $aParams);
+                if ($this->oConnection->oBd->enErreur()) {
+                    $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+                    $oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+                    $aXmlRacineAttribute['status'] = 0;
+                    $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+                } else {
+                    $aXmlRacineAttribute['status'] = 1;
+                    $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+                    // Création du fichier .map du flux WMS.
+                    $aValues = array('token' => session_id(), 'wmsservice_id' => $sWmsService, 'my_vitis_id' => $sWmsService, 'type' => 'prod', 'creation' => true, 'sEncoding' => $this->aValues['sEncoding'], 'sSourceEncoding' => $this->aValues['sSourceEncoding'], 'output' => $this->aValues['output']);
+                    $aPath = array('vm4ms', 'wmsservices', $this->aValues["my_vitis_id"]);
+                    $oWmsServices = new WmsServices($this->aPath, $aValues, $this->aProperties, $this->oConnection);
+                    $oWmsServices->GET();
+                    $oWmsServices->createMapFile();
+                }
+            }
+        }
+        return $sMessage;
+    }
+
+    /**
+     * delete wms service layers
+     * @return id of wms service layer deleted or error object if a wms service layer is not deleted
+     */
+    function DELETE() {
+        
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/Layers.class.inc b/vas/rest/ws/vm4ms/Layers.class.inc
new file mode 100755
index 00000000..e3582b6b
--- /dev/null
+++ b/vas/rest/ws/vm4ms/Layers.class.inc
@@ -0,0 +1,1112 @@
+<?php
+
+/**
+ * \file Layers.class.inc
+ * \class Layers
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the Layers php class
+ *
+ * This class defines Rest Api to Vmap4MapServer Layers
+ *
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'Layer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+require_once 'Vm4msMetadataAccess.class.inc';
+require_once 'WmsServices.class.inc';
+
+class Layers extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/layers",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/layers")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="Layers",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layer_id", "name", "title", "coordsys_id", "coordsys_label", "source_id", "connection_id", "tableschema", "tablename", "tableidfield", "definition", "opacity", "active", "ms_layertype_id", "private_connection", "connection_label", "source_label", "definitiontmp", "metadata_id");
+    }
+
+    /**
+     * @SWG\Get(path="/layers",
+     *   tags={"Layers"},
+     *   summary="Get layers",
+     *   description="Request to get layers",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layers")
+     *     )
+     *  )
+     */
+
+    /**
+     * @SWG\Get(path="/layers/{ms_layer_id}/MapFile",
+     *   tags={"Layers"},
+     *   summary="Get layer map file",
+     *   description="Request to get the map file of a layer by id",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="ms_layer_id",
+     *     in="path",
+     *     description="layer id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layers")
+     *     )
+     *  )
+     */
+
+    /**
+     * @SWG\Get(path="/layers/{ms_layer_id}/MapServerLog",
+     *   tags={"Layers"},
+     *   summary="Get mapserver log of layer test",
+     *   description="Request to get the content of the mapserver log for the test of the layer",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="ms_layer_id",
+     *     in="path",
+     *     description="layer id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layers")
+     *     )
+     *  )
+     */
+
+    /**
+     * @SWG\Get(path="/layers/{ms_layer_id}/GetFeatureInfoTemplate",
+     *   tags={"Layers"},
+     *   summary="Get layer GetFeatureInfo template",
+     *   description="Request to get the content of the layer GetFeatureInfo template",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="ms_layer_id",
+     *     in="path",
+     *     description="layer id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layers")
+     *     )
+     *  )
+     */
+    /**
+     * @SWG\Get(path="/layers/{ms_layer_id}/GeneratedGetFeatureInfoTemplate",
+     *   tags={"Layers"},
+     *   summary="Get layer GetFeatureInfo template",
+     *   description="Request to get the content of the layer GetFeatureInfo template",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="ms_layer_id",
+     *     in="path",
+     *     description="layer id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layers")
+     *     )
+     *  )
+     */
+
+    /**
+     * get Layers
+     * @return  Layers
+     */
+    function GET() {
+        if (in_array('vm4ms_admin', $this->oConnection->aPrivileges)) {
+            // Obligatoire pour le test des couches
+            $this->preTestLayers();
+            $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'v_ms_layer', 'ms_layer_id');
+            if ($aReturn['sStatus'] == 1) {
+                $sMessage = $this->testLayers();
+            } else {
+                $sMessage = $aReturn['sMessage'];
+            }
+        }
+        if (!empty($this->aPath[3])) {
+            if ($this->aPath[3] == "MapFile")
+                $sMessage = $this->getMapFile();
+            else if ($this->aPath[3] == "MapServerLog")
+                $sMessage = $this->getMapServerLog();
+            else if ($this->aPath[3] == "GetFeatureInfoTemplate")
+                $sMessage = $this->getGetFeatureInfoTemplate();
+            else if ($this->aPath[3] == "GeneratedGetFeatureInfoTemplate")
+                $sMessage = $this->getGeneratedGetFeatureInfoTemplate();
+        }
+        return $sMessage;
+    }
+
+    /**
+     * Création d'un fichier ".map" pour la couche avec MapServer.
+     */
+    function createMapFile() {
+        require $this->sRessourcesFile;
+        //$oBd = $this->oConnection->oBd;
+        $oBd = new BD($this->aProperties["owner_login"], $this->aProperties["owner_pass"], $this->aProperties["database"], $this->aProperties["server"], $this->aProperties["port"], $this->aProperties["sgbd"], $this->aProperties["page_encoding"]);
+        if ($oBd->erreurRencontree) {
+            $oError = new VitisError(1, $oBd->sMessage);
+            $aXmlRacineAttribute['status'] = 0;
+            $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            $bXMLError = true;
+            writeToErrorLog('Error: ' . $oBd->sMessage . ' -> ' . __FUNCTION__ . '(' . $this->aProperties["test_wms_service"] . ')' . ' in ' . __FILE__ . ' on line ' . __LINE__);
+        } else {
+            // Login et mdp.
+            $sLogin = '';
+            $sPassword = '';
+            if (!empty($this->aValues['user_login']) && !empty($this->aValues['user_password'])) {
+                $sLogin = $this->aValues['user_login'];
+                $sPassword = $this->aValues['user_password'];
+            }
+            // Création du fichier ".map".
+            $oVm4msMetadataAccess = new Vm4msMetadataAccess($oBd, $sLogin, $sPassword, hash('sha256', session_id()), $this->aProperties);
+            $sMapFile = $oVm4msMetadataAccess->saveLayerTestMapFile($this->aProperties["test_wms_service"], $this->aValues['my_vitis_id']);
+            $this->aObjects[0]->aFields['map_file'] = $sMapFile;
+            // Source des couches du flux de test.
+            $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+            $aParams['wmsservice_id'] = array('value' => $this->aProperties["test_wms_service"], 'type' => 'string');
+            $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getWmsServiceLayersSource'], $aParams);
+            if (!$this->oConnection->oBd->erreurRencontree) {
+                $aLayersSource = array($this->aObjects[0]->aFields['name'] => $this->aObjects[0]->aFields['source_label']);
+                while ($aLayer = $this->oConnection->oBd->ligneSuivante($oPDOresult))
+                    $aLayersSource[$aLayer['name']] = $aLayer['source'];
+                $this->aObjects[0]->aFields['layers_sources'] = $aLayersSource;
+            }
+            $aXmlRacineAttribute['status'] = 1;
+            $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+        }
+        return $sMessage;
+    }
+
+    /**
+     * Retourne les infos du fichier ".map" de test pour la couche.
+     */
+    function getMapFile() {
+        require $this->sRessourcesFile;
+        // Nom du fichier ".map".
+        $sMapFileHash = hash('sha256', $this->aValues['token']);
+        $this->aObjects[0]->aFields['map_file'] = $this->aProperties["map_dir"] . '/wms_test/' . $sMapFileHash . '_' . $this->aObjects[0]->aFields['name'] . '.map';
+        $this->aObjects[0]->aFields['map_file_hash'] = $sMapFileHash;
+        // Contenu du fichier ".map".
+        if (file_exists($this->aObjects[0]->aFields['map_file']))
+            $this->aObjects[0]->aFields['map_file_content'] = file_get_contents($this->aObjects[0]->aFields['map_file']);
+        // Source des couches du flux de test.
+        $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+        $aParams['wmsservice_id'] = array('value' => $this->aProperties["test_wms_service"], 'type' => 'string');
+        $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getWmsServiceLayersSource'], $aParams);
+        if (!$this->oConnection->oBd->erreurRencontree) {
+            $aLayersSource = array($this->aObjects[0]->aFields['name'] => $this->aObjects[0]->aFields['source_label']);
+            while ($aLayer = $this->oConnection->oBd->ligneSuivante($oPDOresult))
+                $aLayersSource[$aLayer['name']] = $aLayer['source'];
+            $this->aObjects[0]->aFields['layers_sources'] = $aLayersSource;
+        }
+        $aXmlRacineAttribute['status'] = 1;
+        $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+        return $sMessage;
+    }
+
+    /**
+     * Retourne le contenu du fichier de log de MapServer pour le test de la couche.
+     */
+    function getMapServerLog() {
+        // Nom du flux de test utilisé.
+        $sMsLogFile = $this->aProperties['ms_log_dir'] . '/test/' . hash('sha256', session_id()) . '_' . $this->aObjects[0]->aFields['name'] . '.log';
+        if (file_exists($sMsLogFile))
+            $this->aObjects[0]->aFields['log_file_content'] = utf8_encode(file_get_contents($sMsLogFile));
+        $aXmlRacineAttribute['status'] = 1;
+        $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+        return $sMessage;
+    }
+
+    /**
+     * Fonction à lancer avant les tests de couches
+     * Ajoute l'attribut definition au cas où definition_structure_valid soit demandé mais definition non
+     */
+    function preTestLayers() {
+        // Obligatoire pour le test des couches
+        if (!empty($this->aValues['attributs'])) {
+            $aAttributs = explode('|', $this->aValues['attributs']);
+            $this->aPreTestOriginialAttributes = $aAttributs;
+            // Cas où definition_structure_valid soit demandé mais definition non
+            if (!in_array('definition', $aAttributs) && in_array('definition_structure_valid', $aAttributs)) {
+                array_push($aAttributs, 'definition');
+                $this->aValues['attributs'] = implode('|', $aAttributs);
+            }
+        }
+    }
+
+    /**
+     * Fonction à lancer après le test de couche
+     * Supprime l'attribut "definition" si il n'était pas dans les attributs demandés
+     */
+    function postTestLayers() {
+        // Supprime l'attribut "definition" si il n'était pas dans les attributs demandés
+        if (isset($this->aPreTestOriginialAttributes)) {
+            if (!in_array('definition', $this->aPreTestOriginialAttributes)) {
+                foreach ($this->aObjects as $oLayer) {
+                    if (!empty($oLayer->aFields['definition'])) {
+                        unset($oLayer->aFields['definition']);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Test l'ensemble des couches
+     * @return string
+     */
+    function testLayers() {
+        foreach ($this->aObjects as $oObj) {
+            if (!empty($oObj->aFields['definition'])) {
+                $oObj->testDefinitionIndent();
+            }
+        }
+        $this->postTestLayers();
+        $aXmlRacineAttribute['status'] = 1;
+        $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+        return $sMessage;
+    }
+
+    /**
+     * Retourne le contenu du fichier template GetFeatureInfo de la couche.
+     */
+    function getGetFeatureInfoTemplate() {
+        // Nom du flux de test utilisé.
+        $sFilePath = $this->aProperties['map_dir'] . '/template/getfeatureinfo/' . $this->aObjects[0]->aFields['name'] . '.html';
+        if (file_exists($sFilePath)){
+            $this->aObjects[0]->aFields['getfeatureinfo_template'] = utf8_encode(file_get_contents($sFilePath));
+        }
+        $aXmlRacineAttribute['status'] = 1;
+        $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+        return $sMessage;
+    }
+
+    /**
+     * Retourne le résultat de la génération du template GetFeatureInfo
+     *
+     */
+    function getGeneratedGetFeatureInfoTemplate() {
+        require $this->sRessourcesFile;
+
+        if (empty($this->aValues['my_vitis_id'])) {
+            return false;
+        }
+
+        // Création du fichier template
+        $oVm4msMetadataAccess = new Vm4msMetadataAccess($this->oConnection->oBd, '', '', session_id(), $this->aProperties);
+        $sTemplate = $oVm4msMetadataAccess->generateGetFeatureInfoTemplateContent($this->aValues['my_vitis_id'], $this->aValues['token']);
+        $this->aObjects[0]->aFields['generated_getfeatureinfo_template'] = $sTemplate;
+
+        $aXmlRacineAttribute['status'] = 1;
+        $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+        return $sMessage;
+    }
+
+    /**
+     * Crée un fichier template GetFeatureInfo
+     *
+     * \return Retourne true ou false si la génération à fonctionnée.
+     */
+    function createGetFeatureInfoTemplate() {
+        require $this->sRessourcesFile;
+
+        if (empty($this->aValues['my_vitis_id'])) {
+            return false;
+        }
+
+        // Création du fichier template
+        $oVm4msMetadataAccess = new Vm4msMetadataAccess($this->oConnection->oBd, '', '', session_id(), $this->aProperties);
+        $bMapCreated = $oVm4msMetadataAccess->createGetFeatureInfoTemplate($this->aValues['my_vitis_id'], $this->aValues['token']);
+
+        return $bMapCreated;
+    }
+
+    /**
+     * @SWG\Post(path="/layers",
+     *   tags={"Layers"},
+     *   summary="Add layer",
+     *   description="Request to add a layer",
+     *   operationId="POST",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="formData",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="name",
+     *     in="formData",
+     *     description="layer name (without spaces and accents)",
+     *     required=true,
+     *     type="string",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="title",
+     *     in="formData",
+     *     description="title",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="coordsys_id",
+     *     in="formData",
+     *     description="coordinate system id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="source_id",
+     *     in="formData",
+     *     description="source id",
+     *     required=false,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="connection_id",
+     *     in="formData",
+     *     description="connection id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="ms_layertype_id",
+     *     in="formData",
+     *     description="layer type id (LINE, POINT...)",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="tableschema",
+     *     in="formData",
+     *     description="table schema",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="tablename",
+     *     in="formData",
+     *     description="table name",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="tableidfield",
+     *     in="formData",
+     *     description="table id field",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="definition",
+     *     in="formData",
+     *     description="definition",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="active",
+     *     in="formData",
+     *     description="active",
+     *     required=true,
+     *     type="boolean",
+     *     default=true
+     *   ),
+     *   @SWG\Parameter(
+     *     name="opacity",
+     *     in="formData",
+     *     description="opacity",
+     *     required=false,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layers")
+     *   )
+     *  )
+     * )
+     */
+    /**
+     * @SWG\Post(path="/layers/MapFile",
+     *   tags={"Layers"},
+     *   summary="Create layer map file",
+     *   description="Request to create the map file of a layer by id",
+     *   operationId="POST",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="ms_layer_id",
+     *     in="query",
+     *     description="layer id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="user_login",
+     *     in="query",
+     *     description="login of the user",
+     *     required=false,
+     *     type="string",
+     *   ),
+     *   @SWG\Parameter(
+     *     name="user_password",
+     *     in="query",
+     *     description="password of the user",
+     *     required=false,
+     *     type="string",
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layers")
+     *     )
+     *  )
+     */
+
+    /**
+     * insert layer
+     * @return array containing the status and the message
+     */
+    function POST() {
+        // Création d'une couche ou d'un fichier ".map".
+        if (!empty($this->aPath[2])) {
+            if ($this->aPath[2] == "MapFile") {
+                $this->aValues['my_vitis_id'] = $this->aValues['ms_layer_id'];
+                $aReturn['sStatus'] = 1;
+                if (in_array('vm4ms_admin', $this->oConnection->aPrivileges)) {
+                    $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'v_ms_layer', 'ms_layer_id');
+                    $sMessage = $aReturn['sMessage'];
+                }
+                if ($aReturn['sStatus'] == 1) {
+                    $this->createMapFile();
+                    $sMessage = $this->getMapFile();
+                }
+            }
+        } else {
+            require $this->sRessourcesFile;
+            // Vide le schéma, la table et la colonne si aucune connexion est sélectionnée.
+            if (empty($this->aValues['connection_id'])) {
+                $this->aValues['tableschema'] = null;
+                $this->aValues['tablename'] = null;
+                $this->aValues['tableidfield'] = null;
+                $this->aValues['connection_id'] = null;
+            }
+            // Vérification du nom de la couche (unique).
+            $aParams = array();
+            $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+            $aParams['name'] = array('value' => $this->aValues['name'], 'type' => 'string');
+            $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getLayerId'], $aParams);
+            if ($this->oConnection->oBd->enErreur()) {
+                $oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+                $aXmlRacineAttribute['status'] = 0;
+                $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            }
+            else {
+                if ($this->oConnection->oBd->nombreLigne($oPDOresult) > 0) {
+                    $oError = new VitisError(1, 'Une couche avec ce nom existe déja.');
+                    $aXmlRacineAttribute['status'] = 0;
+                    $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+                }
+                else {
+                    $aReturn = $this->genericPost($this->aProperties['schema_vm4ms'], 'ms_layer', false, 'ms_layer_id');
+                    if ($aReturn['sStatus'] == 1) {
+                        $aXmlRacineAttribute['status'] = 1;
+                        $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+                        // Association des flux WMS à la couche.
+                        if (!empty($this->aValues['wmsservices'])) {
+                            $aWmsServices = explode('|', $this->aValues['wmsservices']);
+                            foreach ($aWmsServices as $sWmsService) {
+                                $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+                                $aParams['ms_layer_id'] = array('value' => $this->aValues['my_vitis_id'], 'type' => 'number');
+                                $aParams['wmsservice_id'] = array('value' => $sWmsService, 'type' => 'string');
+                                $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['insertLayerWmsServices'], $aParams);
+                                if ($this->oConnection->oBd->enErreur()) {
+                                    $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+                                    $oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+                                    $aXmlRacineAttribute['status'] = 0;
+                                    $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+                                }
+                            }
+                            // Création du fichier .map de tous les flux WMS associés à la couche.
+                            $oLayer = new Layer($this->aPath, $this->aValues, $this->aProperties, $this->oConnection);
+                            $oLayer->GET();
+                            $oLayer->createLayerWmsServicesMapFile($oLayer->aFields['private_connection']);
+                        }
+                        // Création du template GetFeatureInfo
+                        $this->createGetFeatureInfoTemplate();
+                    } else
+                        $sMessage = $aReturn['sMessage'];
+                }
+            }
+        }
+        return $sMessage;
+    }
+
+    /**
+     * @SWG\Put(path="/layers/{ms_layer_id}",
+     *   tags={"Layers"},
+     *   summary="Update Layer",
+     *   description="Request to update layer",
+     *   operationId="PUT",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   consumes= { "multipart/form-data"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="ms_layer_id",
+     *     in="path",
+     *     description="layer id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="title",
+     *     in="query",
+     *     description="title",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="coordsys_id",
+     *     in="query",
+     *     description="coordinate system id",
+     *     required=false,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="source_id",
+     *     in="query",
+     *     description="source id",
+     *     required=false,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="connection_id",
+     *     in="query",
+     *     description="connection id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="ms_layertype_id",
+     *     in="query",
+     *     description="layer type id",
+     *     required=false,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="tableschema",
+     *     in="query",
+     *     description="table schema",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="tablename",
+     *     in="query",
+     *     description="table name",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="tableidfield",
+     *     in="query",
+     *     description="table id field",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="definition",
+     *     in="query",
+     *     description="definition",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="active",
+     *     in="query",
+     *     description="active",
+     *     required=false,
+     *     type="boolean",
+     *     default=true
+     *   ),
+     *   @SWG\Parameter(
+     *     name="opacity",
+     *     in="query",
+     *     description="opacity",
+     *     required=false,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="create_ws_map_file",
+     *     in="query",
+     *     description="create wms services map file",
+     *     required=true,
+     *     type="boolean",
+     *     default=true
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layers")
+     *     ),
+     *
+     *  )
+     */
+    /**
+     * @SWG\Put(path="/layers/activate",
+     *   tags={"Layers"},
+     *   summary="Activate layers",
+     *   description="Request to activate layers",
+     *   operationId="PUT",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="idList",
+     *     in="query",
+     *     description="List of layers id",
+     *     required=true,
+     *     type="string",
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layers")
+     *     )
+     *  )
+     */
+    /**
+     * @SWG\Put(path="/layers/desactivate",
+     *   tags={"Layers"},
+     *   summary="Desactivate layers",
+     *   description="Request to desactivate layers",
+     *   operationId="PUT",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="idList",
+     *     in="query",
+     *     description="List of layers id",
+     *     required=true,
+     *     type="string",
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layers")
+     *     )
+     *  )
+     */
+
+    /**
+     * @SWG\Put(path="/layers/{ms_layer_id}/GetFeatureInfoTemplate",
+     *   tags={"Layers"},
+     *   summary="Update layer GetFeatureInfo template",
+     *   description="Request to put the content of the layer GetFeatureInfo template",
+     *   operationId="PUT",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="ms_layer_id",
+     *     in="path",
+     *     description="layer id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="getfeatureinfo_template",
+     *     in="query",
+     *     description="New GetFeatureInfo template",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layers")
+     *     )
+     *  )
+     */
+
+    /**
+     * modify layer
+     * @return array containing the status and the message
+     */
+    function PUT() {
+        if ($this->aPath[2] == "activate")
+            $sMessage = $this->activateLayer();
+        else if ($this->aPath[2] == "desactivate")
+            $sMessage = $this->desactivateLayer();
+        else if ($this->aPath[3] == "GetFeatureInfoTemplate")
+            $sMessage = $this->updateGetFeatureInfoTemplate();
+        else {
+            require $this->sRessourcesFile;
+            // Création du fichier .map des flux WMS associés à la couche.
+            $bCreateWsMapFile = true;
+            if ($this->aValues["create_ws_map_file"] == "false")
+                $bCreateWsMapFile = false;
+            unset($this->aValues["create_ws_map_file"]);
+            // Sauvegarde la définition dans le champ "definitiontmp".
+            if ($this->aValues['test_layer'] == 'true') {
+                $this->aValues['definitiontmp'] = $this->aValues['definition'];
+                unset($this->aValues['definition']);
+            } else
+                $this->aValues['definitiontmp'] = '';
+            // Vide le schéma, la table et la colonne si aucune connexion est sélectionnée.
+            if (empty($this->aValues['connection_id'])) {
+                $this->aValues['tableschema'] = null;
+                $this->aValues['tablename'] = null;
+                $this->aValues['tableidfield'] = null;
+                $this->aValues['connection_id'] = null;
+            }
+            //
+            $aReturn = $this->genericPut($this->aProperties['schema_vm4ms'], 'ms_layer', 'ms_layer_id');
+            if ($aReturn['sStatus'] == 0) {
+                $sMessage = $aReturn['sMessage'];
+                return $sMessage;
+            }
+            // Suppression de l'association de la couche aux flux WMS si la connexion est privée.
+            if (!empty($this->aValues['connection_id'])) {
+                $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+                $aParams['connection_id'] = array('value' => $this->aValues["connection_id"], 'type' => 'number');
+                $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getConnectionType'], $aParams);
+                $aConnection = $this->oConnection->oBd->ligneSuivante($oPDOresult);
+                if ($aConnection['private'] === true)
+                    $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'wmsservice_ms_layer', 'ms_layer_id', $this->aValues["my_vitis_id"]);
+            }
+            $sMessage = $aReturn['sMessage'];
+            // Création du fichier .map de tous les flux WMS associés à la couche.
+            if ($aReturn["sStatus"] == 1 && $bCreateWsMapFile) {
+                $oLayer = new Layer($this->aPath, $this->aValues, $this->aProperties, $this->oConnection);
+                $oLayer->GET();
+                $oLayer->createLayerWmsServicesMapFile($oLayer->aFields['private_connection']);
+            }
+        }
+        return $sMessage;
+    }
+
+    /**
+     * activateLayer
+     */
+    function activateLayer() {
+        require $this->sRessourcesFile;
+        $aReturn = array('sStatus' => 1, 'sMessage' => '');
+        $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+        $aParams['idList'] = array('value' => $this->aValues['idList'], 'type' => 'group');
+        $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['activateLayers'], $aParams);
+        if ($this->oConnection->oBd->enErreur())
+            $aReturn = array('sStatus' => 0, 'message' => $this->oConnection->oBd->getBDMessage(), 'error_code' => 1);
+        $aXmlRacineAttribute['sStatus'] = $aReturn['sStatus'];
+        if ($aReturn['sStatus'] == 1)
+            $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+        else {
+            $oError = new VitisError($aReturn['error_code'], $aReturn['message']);
+            $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+        }
+        return $sMessage;
+    }
+
+    /**
+     * desactivateLayer
+     */
+    function desactivateLayer() {
+        require $this->sRessourcesFile;
+        $aReturn = array('sStatus' => 1, 'sMessage' => '');
+        $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+        $aParams['idList'] = array('value' => $this->aValues['idList'], 'type' => 'group');
+        $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['desactivateLayers'], $aParams);
+        if ($this->oConnection->oBd->enErreur())
+            $aReturn = array('sStatus' => 0, 'message' => $this->oConnection->oBd->getBDMessage(), 'error_code' => 1);
+        $aXmlRacineAttribute['sStatus'] = $aReturn['sStatus'];
+        if ($aReturn['sStatus'] == 1)
+            $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+        else {
+            $oError = new VitisError($aReturn['error_code'], $aReturn['message']);
+            $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+        }
+        return $sMessage;
+    }
+
+    /**
+     * Update the GetFeatureInfo template
+     */
+    function updateGetFeatureInfoTemplate() {
+
+        if (empty($this->aValues['my_vitis_id'])) {
+            $oError = new VitisError(0, 'Param my_vitis_id required');
+            $aXmlRacineAttribute['status'] = 0;
+            $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            return $sMessage;
+        }
+        if (empty($this->aValues['token'])) {
+            $oError = new VitisError(0, 'Param token required');
+            $aXmlRacineAttribute['status'] = 0;
+            $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            return $sMessage;
+        }
+        if (empty($this->aValues['getfeatureinfo_template'])) {
+            $oError = new VitisError(0, 'Param getfeatureinfo_template required');
+            $aXmlRacineAttribute['status'] = 0;
+            $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            return $sMessage;
+        }
+
+        // MAJ du fichier template
+        $oVm4msMetadataAccess = new Vm4msMetadataAccess($this->oConnection->oBd, '', '', session_id(), $this->aProperties);
+        $bMapUpdated = $oVm4msMetadataAccess->updateGetFeatureInfoTemplate($this->aValues['my_vitis_id'], $this->aValues['token'], $this->aValues['getfeatureinfo_template']);
+
+        if (!$bMapUpdated) {
+            $oError = new VitisError(0, 'Error while updating the template');
+            $aXmlRacineAttribute['status'] = 0;
+            $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            return $sMessage;
+        } else {
+            $aXmlRacineAttribute['status'] = 1;
+            $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            return $sMessage;
+        }
+    }
+
+    /**
+     * @SWG\Delete(path="/layers/",
+     *   tags={"Layers"},
+     *   summary="delete Layer",
+     *   description="Request to delete Layer",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="idList",
+     *     in="query",
+     *     description="id of the layers",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layers")
+     *     )
+     *  )
+     */
+    /**
+     * @SWG\Delete(path="/layers/{ms_layer_id}",
+     *   tags={"Layers"},
+     *   summary="delete Layer",
+     *   description="Request to delete Layer",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="ms_layer_id",
+     *     in="path",
+     *     description="id of the layer",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/layers")
+     *     )
+     *  )
+     */
+
+    /**
+     * delete layer
+     * @return id of layer deleted or error object if a layer is not deleted
+     */
+    function DELETE() {
+        $aReturn = $this->genericDelete($this->aProperties['schema_vm4ms'], 'ms_layer', 'ms_layer_id');
+        return $aReturn['sMessage'];
+    }
+
+}
+
+?>
diff --git a/vas/rest/ws/vm4ms/MapServer.class.inc b/vas/rest/ws/vm4ms/MapServer.class.inc
new file mode 100755
index 00000000..52477243
--- /dev/null
+++ b/vas/rest/ws/vm4ms/MapServer.class.inc
@@ -0,0 +1,216 @@
+<?php
+
+/**
+ * \file MapServer.class.inc
+ * \class MapServer
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the MapServer php class
+ *
+ * This class defines Rest Api to Vmap4MapServer MapServer
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+
+class MapServer extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/mapserver",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/mapserver")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="MapServer",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+    }
+
+    /**
+     * @SWG\Get(path="/mapserver/Symbols",
+     *   tags={"MapServer"},
+     *   summary="Get mapserver symbols",
+     *   description="Request to get the symbols of MapServer",
+     *   operationId="GET",
+     *   produces={"application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/mapserver")
+     *     )
+     *  )
+     */
+    /**
+     * @SWG\Get(path="/mapserver/Fonts",
+     *   tags={"MapServer"},
+     *   summary="Get mapserver fonts",
+     *   description="Request to get the fonts of MapServer",
+     *   operationId="GET",
+     *   produces={"application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/mapserver")
+     *     )
+     *  )
+     */
+
+    /**
+     * get MapServer
+     * @return  MapServer
+     */
+    function GET() {
+        if (!empty($this->aPath[2])) {
+            if (!in_array('vm4ms_admin', $this->oConnection->aPrivileges)) {
+                $oError = new VitisError(0, 'INSUFFICIENT_PRIVILEGES');
+                $aXmlRacineAttribute['status'] = 0;
+                $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+                return $sMessage;
+            }
+            if ($this->aPath[2] == "Symbols")
+                $sMessage = $this->getSymbols();
+            else if ($this->aPath[2] == "Fonts")
+                $sMessage = $this->getFonts();
+            return $sMessage;
+        }
+    }
+
+    /**
+     * Retourne les symboles du fichier "symbols.sym".
+     */
+    function getSymbols() {
+        $sMsSymbolsFile = $this->aProperties["map_dir"] . '/symbols/symbols.sym';
+        if (file_exists($sMsSymbolsFile)) {
+            $aFile = file($sMsSymbolsFile);
+            $bSearchName = false;
+            $aSymbols = array();
+            $sResult = '';
+            $i = 1;
+            foreach ($aFile as $iLine => $sLine) {
+                if (trim($sLine) != 'SYMBOLSET') {
+                    if ($bSearchName) {
+                        $iNbName = substr_count($sLine, 'name') + substr_count($sLine, 'Name') + substr_count($sLine, 'NAME');
+                        if ($iNbName != 0) {
+                            //$sAlinea = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
+                            $sAlinea = '';
+                            $sDef .= $sAlinea . $sLine;
+                            $bLoop = true;
+                            $iLineDef = $iLine + 1;
+                            $iNbEndAllowed = 0;
+                            $aSymbol['definition'][] = $sLine;
+                            while ($bLoop) {
+                                $sLineDef = $aFile[$iLineDef];
+                                $iNbEnd = substr_count($sLineDef, 'end') + substr_count($sLineDef, 'End') + substr_count($sLineDef, 'END');
+                                $iNbPoints = substr_count($sLineDef, 'points') + substr_count($sLineDef, 'Points') + substr_count($sLineDef, 'POINTS');
+                                $iNbStyle = substr_count($sLineDef, 'style') + substr_count($sLineDef, 'Style') + substr_count($sLineDef, 'STYLE');
+                                if ($iNbEnd == 0) {
+                                    $sDef .= $sAlinea . $sLineDef;
+                                    if ($iNbPoints != 0 || $iNbStyle != 0) {
+                                        $iNbEndAllowed++;
+                                        //$sAlinea .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
+                                        $sAlinea .= '';
+                                    }
+                                } else {
+                                    if ($iNbPoints == 0 && $iNbStyle == 0) {
+                                        if ($iNbEndAllowed == 0) {
+                                            $bLoop = false;
+                                            $sAlinea = "";
+                                        } else {
+                                            $iNbEndAllowed = $iNbEndAllowed - 1;
+                                            //$sAlinea = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
+                                            $sAlinea = '';
+                                        }
+                                    }
+                                    $sDef .= $sAlinea . $sLineDef;
+                                }
+                                $aSymbol['definition'][] = $sLineDef;
+                                $iLineDef++;
+                            }
+                            $sLine = str_replace(array('name', 'Name', 'NAME'), "", $sLine);
+                            $sLine = ltrim(rtrim($sLine));
+                            if ($sLine{0} == "'" || $sLine{0} == '"') {
+                                $sLine = substr($sLine, 1);
+                            }
+                            if ($sLine{strlen($sLine) - 1} == "'" || $sLine{strlen($sLine) - 1} == '"') {
+                                $sLine = substr($sLine, 0, strlen($sLine) - 1);
+                            }
+                            //$sResult .= "<tr><td>- <a href='javascript:getDefSymbol(\"".$sLine."\")' title='Afficher la définition' style='color: black; font-size: 10pt; font-weight: bold;'>".$sLine."</a><div id='".$sLine."' class='attribute2' style='display:none;'>".$sDef."</div></td></tr>";
+                            $sResult .= $sDef;
+                            $bSearchName = false;
+                            $sDef = "";
+                            $aSymbol['name'] = $sLine;
+                            $aSymbol['id'] = 'symbol_' . $i++;
+                            $aSymbols[] = $aSymbol;
+                        }
+                    } else {
+                        $aSymbol = array();
+                        $aSymbol['definition'][] = 'SYMBOL';
+                        $iNbSymbol = substr_count($sLine, 'symbol') + substr_count($sLine, 'Symbol') + substr_count($sLine, 'SYMBOL');
+                        if ($iNbSymbol != 0) {
+                            $bSearchName = true;
+                            $sDef = $sLine;
+                        }
+                    }
+                }
+            }
+            $this->aObjects[0]->aFields['symbols_content'] = $aSymbols;
+        }
+        $aXmlRacineAttribute['status'] = 1;
+        $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+        return $sMessage;
+    }
+
+    /**
+     * Retourne les polices du fichier "fonts.list".
+     */
+    function getFonts() {
+        $sMsFontsFile = $this->aProperties["map_dir"] . '/fonts/fonts.list';
+        if (file_exists($sMsFontsFile)) {
+            $sFontsContent = strtolower(file_get_contents($sMsFontsFile));
+            $sFontsContent = str_replace(PHP_EOL, '|', $sFontsContent);
+            $aFonts = explode('|', $sFontsContent);
+            $aFilteredFonts = array();
+            foreach ($aFonts as $sFont) {
+                $sFont = preg_replace('/\s+/', ' ', $sFont);
+                $aFont = explode(' ', $sFont, 2);
+                $aFilteredFonts[] = array('name' => trim($aFont[0]), 'filename' => $aFont[1]);
+            }
+            $this->aObjects[0]->aFields['fonts'] = $aFilteredFonts;
+        }
+        $aXmlRacineAttribute['status'] = 1;
+        $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+        return $sMessage;
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/MapServerDebugLevel.class.inc b/vas/rest/ws/vm4ms/MapServerDebugLevel.class.inc
new file mode 100755
index 00000000..c558fb49
--- /dev/null
+++ b/vas/rest/ws/vm4ms/MapServerDebugLevel.class.inc
@@ -0,0 +1,44 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file MapServerDebugLevel.class.inc
+ * \class MapServerDebugLevel
+ *
+ * \author Yoann Perollet <yoann.perollet@veremes.com>.
+ *
+ * 	\brief This file contains the MapServerDebugLevel php class
+ *
+ * This class defines operation for one MapServerDebugLevel
+ * 
+ */
+class MapServerDebugLevel extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array('msdebuglevel_id', 'label_id', 'translation');
+    }
+
+    /**
+     * get informations about mapserverdebuglevel
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        $this->aFields = $this->getFields($this->aProperties['schema_vm4ms'], "v_msdebuglevel", "msdebuglevel_id");
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/MapServerDebugLevels.class.inc b/vas/rest/ws/vm4ms/MapServerDebugLevels.class.inc
new file mode 100755
index 00000000..569d85ae
--- /dev/null
+++ b/vas/rest/ws/vm4ms/MapServerDebugLevels.class.inc
@@ -0,0 +1,130 @@
+<?php
+
+/**
+ * \file MapServerDebugLevels.class.inc
+ * \class MapServerDebugLevels
+ *
+ * \author Yoann Perollet <yoann.perollet@veremes.com>.
+ *
+ * 	\brief This file contains the MapServerDebugLevels php class
+ *
+ * This class defines Rest Api to Gtf order statutes
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once 'MapServerDebugLevel.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+
+class MapServerDebugLevels extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/mapserverdebuglevels",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/mapserverdebuglevels")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="MapServerDebugLevels",
+     *   description="Operations about MapServerDebugLevels"
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array('msdebuglevel_id', 'label_id', 'translation');
+    }
+
+    /**
+     * @SWG\Get(path="/mapserverdebuglevels",
+     *   tags={"MapServerDebugLevels"},
+     *   summary="Get MapServerDebugLevels",
+     *   description="Request to get MapServerDebugLevels",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="boolean"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/mapserverdebuglevels")
+     *     )
+     *  )
+     */
+
+    /**
+     * get MapServerDebugLevels
+     * @return  MapServerDebugLevels
+     */
+    function GET() {
+        $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], "v_msdebuglevel", "msdebuglevel_id");
+        return $aReturn['sMessage'];
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/Metadata.class.inc b/vas/rest/ws/vm4ms/Metadata.class.inc
new file mode 100755
index 00000000..69781b2e
--- /dev/null
+++ b/vas/rest/ws/vm4ms/Metadata.class.inc
@@ -0,0 +1,87 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file Metadata.class.inc
+ * \class Metadata
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the Metadata php class
+ *
+ * This class defines operation for one metadata
+ * 
+ */
+class Metadata extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("metadata_id", "name", "definition");
+    }
+
+    /**
+     * @SWG\Get(path="/metadatas/{metadata_id}", 
+     *   tags={"Metadatas"},
+     *   summary="Get metadata",
+     *   description="Request to get metadata by id",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="metadata_id",
+     *     in="path",
+     *     description="metadata id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/metadatas")
+     *     )
+     *  )
+     */
+
+    /**
+     * get informations about metadata
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        $this->aFields = $this->getFields($this->aProperties['schema_vm4ms'], 'metadata', 'metadata_id');
+    }
+
+    /**
+     * delete a metadata
+     */
+    function DELETE() {
+        require $this->sRessourcesFile;
+        $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'metadata', 'metadata_id', $this->aValues['my_vitis_id'], 'string');
+        if ($this->oConnection->oBd->enErreur()) {
+            $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+        } else {
+            $this->aFields['metadata_id'] = $this->aValues['my_vitis_id'];
+        }
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/Metadatas.class.inc b/vas/rest/ws/vm4ms/Metadatas.class.inc
new file mode 100755
index 00000000..61847b73
--- /dev/null
+++ b/vas/rest/ws/vm4ms/Metadatas.class.inc
@@ -0,0 +1,306 @@
+<?php
+
+/**
+ * \file Metadatas.class.inc
+ * \class Metadatas
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the Metadatas php class
+ *
+ * This class defines Rest Api to Vmap4MapServer Metadatas
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'Metadata.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+
+class Metadatas extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/metadatas",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/metadatas")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="Metadatas",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("metadata_id", "name", "definition");
+    }
+
+    /**
+     * @SWG\Get(path="/metadatas",
+     *   tags={"Metadatas"},
+     *   summary="Get metadate",
+     *   description="Request to get metadata",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/metadatas")
+     *     )
+     *  )
+     */
+
+    /**
+     * get Metadatas
+     * @return  Metadatas
+     */
+    function GET() {
+        $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'metadata', 'metadata_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Post(path="/metadatas",
+     *   tags={"Metadatas"},
+     *   summary="Add metadata",
+     *   description="Request to add a metadata",
+     *   operationId="POST",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="formData",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="name",
+     *     in="formData",
+     *     description="name",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="definition",
+     *     in="formData",
+     *     description="definition",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/metadatas")
+     *   )
+     *  )
+     * )
+     */
+
+    /**
+     * insert metadata
+     * @return array containing the status and the message
+     */
+    function POST() {
+        $aReturn = $this->genericPost($this->aProperties['schema_vm4ms'], 'metadata', $this->aProperties['schema_vm4ms'] . '.seq_common', 'metadata_id');
+        if ($aReturn['sStatus'] == 1) {
+            $aXmlRacineAttribute['status'] = 1;
+            $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            $oMetadata = new Metadata($this->aPath, $this->aValues, $this->aProperties, $this->oConnection);
+            $oMetadata->GET();
+        } else {
+            $sMessage = $aReturn['sMessage'];
+        }
+        return $sMessage;
+    }
+
+    /**
+     * @SWG\Put(path="/metadatas/{metadata_id}",
+     *   tags={"Metadatas"},
+     *   summary="Update Metadata",
+     *   description="Request to update metadata",
+     *   operationId="PUT",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   consumes= { "multipart/form-data"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="metadata_id",
+     *     in="path",
+     *     description="metadata id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="name",
+     *     in="query",
+     *     description="name",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="definition",
+     *     in="query",
+     *     description="definition",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/metadatas")
+     *     ),
+     * 
+     *  )
+     */
+
+    /**
+     * modify metadata
+     * @return array containing the status and the message
+     */
+    function PUT() {
+        $aReturn = $this->genericPut($this->aProperties['schema_vm4ms'], 'metadata', 'metadata_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Delete(path="/metadatas/",
+     *   tags={"Metadatas"},
+     *   summary="delete Metadata",
+     *   description="Request to delete Metadata",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="idList",
+     *     in="query",
+     *     description="id of the metadatas",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/metadatas")
+     *     )
+     *  )
+     */
+    /**
+     * @SWG\Delete(path="/metadatas/{metadata_id}",
+     *   tags={"Metadatas"},
+     *   summary="delete Metadata",
+     *   description="Request to delete Metadata",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="metadata_id",
+     *     in="path",
+     *     description="id of the metadata",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/metadatas")
+     *     )
+     *  )
+     */
+
+    /**
+     * delete metadata
+     * @return id of metadata deleted or error object if a metadata is not deleted
+     */
+    function DELETE() {
+        $aReturn = $this->genericDelete($this->aProperties['schema_vm4ms'], 'metadata', 'metadata_id');
+        return $aReturn['sMessage'];
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/PrivateLayer.class.inc b/vas/rest/ws/vm4ms/PrivateLayer.class.inc
new file mode 100755
index 00000000..c2a25105
--- /dev/null
+++ b/vas/rest/ws/vm4ms/PrivateLayer.class.inc
@@ -0,0 +1,81 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file PrivateLayer.class.inc
+ * \class PrivateLayer
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the PrivateLayer php class
+ *
+ * This class defines operation for one private layer
+ * 
+ */
+class PrivateLayer extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layer_id", "name", "title", "coordsys_id", "source_id", "connection_id", "tableschema", "tablename", "tableidfield", "definition", "opacity", "active", "ms_layertype_id", "wmsservices", "wmsservices_label", "private_connection");
+    }
+
+    /**
+     * get informations about private layer
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        $this->aFields = $this->getFields($this->aProperties['schema_vm4ms'], 'v_private_ms_layer', 'ms_layer_id');
+        /*
+          // Flux wms rattachés à la couche.
+          if (in_array("wmsservices", $this->aSelectedFields)){
+          $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+          $aParams['ms_layer_id'] = array('value' => $this->aValues['my_vitis_id'], 'type' => 'number');
+          $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getPrivateLayerWmsServices'], $aParams);
+
+          $sListWmsServiceId = "";
+          $aListWmsServiceName = array();
+          while($aLigne=$this->oConnection->oBd->ligneSuivante ($oPDOresult)) {
+          if ($sListWmsServiceId == ""){
+          $sListWmsServiceId = $aLigne["wmsservice_id"];
+          }else{
+          $sListWmsServiceId .= "|".$aLigne["wmsservice_id"];
+          }
+          $aListWmsServiceName[] = $aLigne["wmsservice_id"];
+          }
+          $oPDOresult=$this->oConnection->oBd->fermeResultat();
+          $this->aFields['wmsservices'] = $sListWmsServiceId;
+          $this->aFields['wmsservices_label'] = implode(',', $aListWmsServiceName);
+          }
+         */
+    }
+
+    /**
+     * delete a private layer
+     */
+    function DELETE() {
+        /*
+          require $this->sRessourcesFile;
+          $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'ms_layer', 'ms_layer_id', $this->aValues['my_vitis_id'], 'string');
+          if ($this->oConnection->oBd->enErreur()) {
+          $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+          } else {
+          $this->aFields['ms_layer_id'] = $this->aValues['my_vitis_id'];
+          }
+         */
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/PrivateLayers.class.inc b/vas/rest/ws/vm4ms/PrivateLayers.class.inc
new file mode 100755
index 00000000..7d2f4244
--- /dev/null
+++ b/vas/rest/ws/vm4ms/PrivateLayers.class.inc
@@ -0,0 +1,197 @@
+<?php
+
+/**
+ * \file PrivateLayers.class.inc
+ * \class PrivateLayers
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the PrivateLayers php class
+ *
+ * This class defines Rest Api to Vmap4MapServer PrivateLayers
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'PrivateLayer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+
+class PrivateLayers extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/privatelayers",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/privatelayers")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="PrivateLayers",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layer_id", "name", "title", "coordsys_id", "source_id", "connection_id", "tableschema", "tablename", "tableidfield", "definition", "opacity", "active", "ms_layertype_id", "private_connection");
+    }
+
+    /**
+     * @SWG\Get(path="/privatelayers",
+     *   tags={"Layers"},
+     *   summary="Get private layers",
+     *   description="Request to get private layers",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/privatelayers")
+     *     )
+     *  )
+     */
+
+    /**
+     * get PrivateLayers
+     * @return  PrivateLayers
+     */
+    function GET() {
+        $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'v_private_ms_layer', 'ms_layer_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * insert private layer
+     * @return array containing the status and the message
+     */
+    function POST() {
+        /*
+          $aReturn = $this->genericPost($this->aProperties['schema_vm4ms'], 'ms_layer', false, 'ms_layer_id');
+          if ($aReturn['sStatus'] == 1){
+          $aXmlRacineAttribute['status'] = 1;
+          $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+          $oPrivateLayer = new PrivateLayer($this->aPath, $this->aValues, $this->aProperties, $this->oConnection);
+          $oPrivateLayer->GET();
+          // Ajoute les flux WMS associés à la couche.
+          if (!empty($this->aValues['wmsservices'])) {
+          require $this->sRessourcesFile;
+          $aWmsServices = explode('|', $this->aValues['wmsservices']);
+          foreach ($aWmsServices as $iWmsServiceId) {
+          $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+          $aParams['ms_layer_id'] = array('value' => $this->aValues['my_vitis_id'], 'type' => 'number');
+          $aParams['wmsservice_id'] = array('value' => $iWmsServiceId, 'type' => 'string');
+          $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['insertPrivateLayerWmsServices'], $aParams);
+          }
+          }
+          }else{
+          $sMessage = $aReturn['sMessage'];
+          }
+          return $sMessage;
+         */
+    }
+
+    /**
+     * modify private layer
+     * @return array containing the status and the message
+     */
+    function PUT() {
+        /*
+          $aReturn = $this->genericPut($this->aProperties['schema_vm4ms'], 'ms_layer', 'ms_layer_id');
+          // Supprime les flux WMS rattachés à la couche.
+          $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'wmsservice_ms_layer', 'ms_layer_id', $this->aValues["my_vitis_id"], 'text');
+          // Ajoute les flux WMS associés à la couche.
+          if (!empty($this->aValues['wmsservices'])) {
+          require $this->sRessourcesFile;
+          $aWmsServices = explode('|', $this->aValues['wmsservices']);
+          foreach ($aWmsServices as $iWmsServiceId) {
+          $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+          $aParams['ms_layer_id'] = array('value' => $this->aValues['my_vitis_id'], 'type' => 'number');
+          $aParams['wmsservice_id'] = array('value' => $iWmsServiceId, 'type' => 'string');
+          $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['insertPrivateLayerWmsServices'], $aParams);
+          }
+          }
+          return $aReturn['sMessage'];
+         */
+    }
+
+    /**
+     * delete private layer
+     * @return id of layer deleted or error object if a layer is not deleted
+     */
+    function DELETE() {
+        /*
+          $aReturn = $this->genericDelete($this->aProperties['schema_vm4ms'], 'ms_layer', 'ms_layer_id');
+          // Supprime les flux WMS rattachés à la couche.
+          $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'wmsservice_ms_layer', 'ms_layer_id', $this->aValues["my_vitis_id"], 'text');
+          return $aReturn['sMessage'];
+         */
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/PrivateWmsService.class.inc b/vas/rest/ws/vm4ms/PrivateWmsService.class.inc
new file mode 100755
index 00000000..04ba682a
--- /dev/null
+++ b/vas/rest/ws/vm4ms/PrivateWmsService.class.inc
@@ -0,0 +1,58 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file PrivateWmsService.class.inc
+ * \class PrivateWmsService
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the PrivateWmsService php class
+ *
+ * This class defines operation for one private wms service
+ * 
+ */
+class PrivateWmsService extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("wmsservice_id", "description", "definition", "web_id", "web_name", "msdebuglevel_id");
+    }
+
+    /**
+     * get informations about private wms service
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        $this->aFields = $this->getFields($this->aProperties['schema_vm4ms'], 'v_private_wms_service', 'wmsservice_id');
+        $this->aFields['wms_service_url'] = $this->aProperties["ms_cgi_url"] . '/private/[token]';
+    }
+
+    /**
+     * delete a private wms service
+     */
+    function DELETE() {
+        require $this->sRessourcesFile;
+        $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'wmsservice', 'wmsservice_id', $this->aValues['my_vitis_id'], 'string');
+        if ($this->oConnection->oBd->enErreur()) {
+            $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+        } else {
+            $this->aFields['wmsservice_id'] = $this->aValues['my_vitis_id'];
+        }
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/PrivateWmsServiceLayer.class.inc b/vas/rest/ws/vm4ms/PrivateWmsServiceLayer.class.inc
new file mode 100755
index 00000000..66953513
--- /dev/null
+++ b/vas/rest/ws/vm4ms/PrivateWmsServiceLayer.class.inc
@@ -0,0 +1,51 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file PrivateWmsServiceLayer.class.inc
+ * \class PrivateWmsServiceLayer
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the Private WmsServiceLayer php class
+ *
+ * This class defines operation for one private wms service layer
+ * 
+ */
+class PrivateWmsServiceLayer extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layer_id", "name", "title", "active", "opacity");
+    }
+
+    /**
+     * get informations about wms service layer
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        $this->aFields = $this->getFields($this->aProperties['schema_vm4ms'], 'v_private_ms_layer', 'ms_layer_id');
+    }
+
+    /**
+     * delete a wms service layer
+     */
+    function DELETE() {
+        
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/PrivateWmsServiceLayers.class.inc b/vas/rest/ws/vm4ms/PrivateWmsServiceLayers.class.inc
new file mode 100755
index 00000000..91ed9679
--- /dev/null
+++ b/vas/rest/ws/vm4ms/PrivateWmsServiceLayers.class.inc
@@ -0,0 +1,146 @@
+<?php
+
+/**
+ * \file PrivateWmsServiceLayers.class.inc
+ * \class PrivateWmsServiceLayers
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the PrivateWmsServiceLayers php class
+ *
+ * This class defines Rest Api to Vmap PrivateWmsServiceLayers
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'PrivateWmsServiceLayer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+
+class PrivateWmsServiceLayers extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/privatewmsservicelayers",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/privatewmsservicelayers")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="PrivateWmsServiceLayers",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layer_id", "name", "title", "active", "opacity");
+    }
+
+    /**
+     * @SWG\Get(path="/privatewmsservicelayers",
+     *   tags={"WmsServiceLayers"},
+     *   summary="Get private wms service layers",
+     *   description="Request to get private wms service layers",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Porperties Response",
+     *         @SWG\Schema(ref="#/definitions/privatewmsservicelayers")
+     *     )
+     *  )
+     */
+
+    /**
+     * get private wms service layers
+     * @return PrivateWmsServiceLayers
+     */
+    function GET() {
+        $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'v_private_ms_layer', 'ms_layer_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * modify layers of wms service
+     * @return array containing the status and the message
+     */
+    function PUT() {
+        
+    }
+
+    /**
+     * delete wms service layers
+     * @return id of wms service layer deleted or error object if a wms service layer is not deleted
+     */
+    function DELETE() {
+        
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/PrivateWmsServices.class.inc b/vas/rest/ws/vm4ms/PrivateWmsServices.class.inc
new file mode 100755
index 00000000..c8880b98
--- /dev/null
+++ b/vas/rest/ws/vm4ms/PrivateWmsServices.class.inc
@@ -0,0 +1,206 @@
+<?php
+
+/**
+ * \file PrivateWmsServices.class.inc
+ * \class PrivateWmsServices
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the PrivateWmsServices php class
+ *
+ * This class defines Rest Api to Vmap4MapServer PrivateWmsServices
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'PrivateWmsService.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+require_once 'Vm4msMetadataAccess.class.inc';
+
+class PrivateWmsServices extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/privatewmsservices",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/privatewmsservices")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="PrivateWmsServices",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("wmsservice_id", "description", "definition", "web_id", "web_name", "msdebuglevel_id");
+    }
+
+    /**
+     * @SWG\Get(path="/privatewmsservices",
+     *   tags={"WmsServices"},
+     *   summary="Get Private Wms Services",
+     *   description="Request to get Private Wms Services",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/privatewmsservices")
+     *     )
+     *  )
+     */
+
+    /**
+     * get PrivateWmsServices
+     * @return  PrivateWmsServices
+     */
+    function GET() {
+        $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'v_private_wms_service', 'wmsservice_id');
+        if ($aReturn['sStatus'] == 0) {
+            $sMessage = $aReturn['sMessage'];
+            return $sMessage;
+        }
+
+        // Écrit les url
+        for ($i = 0; $i < count($this->aObjects); $i++) {
+            $this->aObjects[$i]->aFields['wms_service_url'] = $this->aProperties["ms_cgi_url"] . '/private/[token]';
+        }
+
+        // Reformatte la réponse 
+        if (isset($this->aValues['sEncoding'])) {
+            $sEncoding = $this->aValues['sEncoding'];
+        } else {
+            $sEncoding = null;
+        }if (isset($this->aValues['sSourceEncoding'])) {
+            $sSourceEncoding = $this->aValues['sSourceEncoding'];
+        } else {
+            $sSourceEncoding = null;
+        }if (isset($this->aValues['output'])) {
+            $output = $this->aValues['output'];
+        } else {
+            $output = null;
+        }
+        $aXmlRacineAttribute['status'] = 1;
+        $sMessage = $this->asDocument('', 'vitis', $sEncoding, True, $aXmlRacineAttribute, $sSourceEncoding, $output);
+        $aReturn = array('sStatus' => $aXmlRacineAttribute['status'], "sMessage" => $sMessage);
+
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * insert private wms service
+     * @return array containing the status and the message
+     */
+    function POST() {
+        $aReturn = $this->genericPost($this->aProperties['schema_vm4ms'], 'wmsservice', false, 'wmsservice_id');
+        if ($aReturn['sStatus'] == 1) {
+            $aXmlRacineAttribute['status'] = 1;
+            $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            $oPrivateWmsService = new PrivateWmsService($this->aPath, $this->aValues, $this->aProperties, $this->oConnection);
+            $oPrivateWmsService->GET();
+        } else {
+            $sMessage = $aReturn['sMessage'];
+        }
+        return $sMessage;
+    }
+
+    /**
+     * modify private wms service
+     * @return array containing the status and the message
+     */
+    function PUT() {
+        $aReturn = $this->genericPut($this->aProperties['schema_vm4ms'], 'wmsservice', 'wmsservice_id');
+        $sMessage = $aReturn['sMessage'];
+        $oBd = new BD($this->aProperties["owner_login"], $this->aProperties["owner_pass"], $this->aProperties["database"], $this->aProperties["server"], $this->aProperties["port"], $this->aProperties["sgbd"], $this->aProperties["page_encoding"]);
+        if ($oBd->erreurRencontree) {
+            $oError = new VitisError(1, $oBd->sMessage);
+            $aXmlRacineAttribute['status'] = 0;
+            $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            $bXMLError = true;
+        } else {
+            // Création du fichier .map du flux WMS.
+            $oVm4msMetadataAccess = new Vm4msMetadataAccess($this->oConnection->oBd, '', '', session_id(), $this->aProperties);
+            $oVm4msMetadataAccess->saveWmsServiceMapFile($this->aValues['my_vitis_id']);
+        }
+        return $sMessage;
+    }
+
+    /**
+     * delete private wms service
+     * @return id of private wms service deleted or error object if a private wms service is not deleted
+     */
+    function DELETE() {
+        $aReturn = $this->genericDelete($this->aProperties['schema_vm4ms'], 'wmsservice', 'wmsservice_id');
+        return $aReturn['sMessage'];
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/PublicLayer.class.inc b/vas/rest/ws/vm4ms/PublicLayer.class.inc
new file mode 100755
index 00000000..c2081aec
--- /dev/null
+++ b/vas/rest/ws/vm4ms/PublicLayer.class.inc
@@ -0,0 +1,80 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file PublicLayer.class.inc
+ * \class PublicLayer
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the PublicLayer php class
+ *
+ * This class defines operation for one publiclayer
+ * 
+ */
+class PublicLayer extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layer_id", "name", "title", "coordsys_id", "source_id", "connection_id", "tableschema", "tablename", "tableidfield", "definition", "opacity", "active", "ms_layertype_id", "wmsservices", "wmsservices_label", "private_connection");
+    }
+
+    /**
+     * get informations about public layer
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        $this->aFields = $this->getFields($this->aProperties['schema_vm4ms'], 'v_public_ms_layer', 'ms_layer_id');
+        /*
+          // Flux wms rattachés à la couche.
+          if (in_array("wmsservices", $this->aSelectedFields)){
+          $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+          $aParams['ms_layer_id'] = array('value' => $this->aValues['my_vitis_id'], 'type' => 'number');
+          $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getPublicLayerWmsServices'], $aParams);
+          $sListWmsServiceId = "";
+          $aListWmsServiceName = array();
+          while($aLigne=$this->oConnection->oBd->ligneSuivante ($oPDOresult)) {
+          if ($sListWmsServiceId == ""){
+          $sListWmsServiceId = $aLigne["wmsservice_id"];
+          }else{
+          $sListWmsServiceId .= "|".$aLigne["wmsservice_id"];
+          }
+          $aListWmsServiceName[] = $aLigne["wmsservice_id"];
+          }
+          $oPDOresult=$this->oConnection->oBd->fermeResultat();
+          $this->aFields['wmsservices'] = $sListWmsServiceId;
+          $this->aFields['wmsservices_label'] = implode(',', $aListWmsServiceName);
+          }
+         */
+    }
+
+    /**
+     * delete a public layer
+     */
+    function DELETE() {
+        /*
+          require $this->sRessourcesFile;
+          $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'ms_layer', 'ms_layer_id', $this->aValues['my_vitis_id']);
+          if ($this->oConnection->oBd->enErreur()) {
+          $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+          } else {
+          $this->aFields['ms_layer_id'] = $this->aValues['my_vitis_id'];
+          }
+         */
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/PublicLayers.class.inc b/vas/rest/ws/vm4ms/PublicLayers.class.inc
new file mode 100755
index 00000000..19586d4b
--- /dev/null
+++ b/vas/rest/ws/vm4ms/PublicLayers.class.inc
@@ -0,0 +1,197 @@
+<?php
+
+/**
+ * \file PublicLayers.class.inc
+ * \class PublicLayers
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the PublicLayers php class
+ *
+ * This class defines Rest Api to Vmap4MapServer PublicLayers
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'PublicLayer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+
+class PublicLayers extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/publiclayers",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/publiclayers")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="PublicLayers",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layer_id", "name", "title", "coordsys_id", "source_id", "connection_id", "tableschema", "tablename", "tableidfield", "definition", "opacity", "active", "ms_layertype_id", "private_connection");
+    }
+
+    /**
+     * @SWG\Get(path="/publiclayers",
+     *   tags={"Layers"},
+     *   summary="Get public layers",
+     *   description="Request to get public layers",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/publiclayers")
+     *     )
+     *  )
+     */
+
+    /**
+     * get PublicLayers
+     * @return  PublicLayers
+     */
+    function GET() {
+        $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'v_public_ms_layer', 'ms_layer_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * insert publiclayer
+     * @return array containing the status and the message
+     */
+    function POST() {
+        /*
+          $aReturn = $this->genericPost($this->aProperties['schema_vm4ms'], 'ms_layer', false, 'ms_layer_id');
+          if ($aReturn['sStatus'] == 1){
+          $aXmlRacineAttribute['status'] = 1;
+          $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+          $oPublicLayer = new PublicLayer($this->aPath, $this->aValues, $this->aProperties, $this->oConnection);
+          $oPublicLayer->GET();
+          // Ajoute les flux WMS associés à la couche.
+          if (!empty($this->aValues['wmsservices'])) {
+          require $this->sRessourcesFile;
+          $aWmsServices = explode('|', $this->aValues['wmsservices']);
+          foreach ($aWmsServices as $iWmsServiceId) {
+          $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+          $aParams['ms_layer_id'] = array('value' => $this->aValues['my_vitis_id'], 'type' => 'number');
+          $aParams['wmsservice_id'] = array('value' => $iWmsServiceId, 'type' => 'string');
+          $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['insertPublicLayerWmsServices'], $aParams);
+          }
+          }
+          }else{
+          $sMessage = $aReturn['sMessage'];
+          }
+          return $sMessage;
+         */
+    }
+
+    /**
+     * modify public layer
+     * @return array containing the status and the message
+     */
+    function PUT() {
+        /*
+          $aReturn = $this->genericPut($this->aProperties['schema_vm4ms'], 'ms_layer', 'ms_layer_id');
+          // Supprime les flux WMS rattachés à la couche.
+          $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'wmsservice_ms_layer', 'ms_layer_id', $this->aValues["my_vitis_id"], 'text');
+          // Ajoute les flux WMS associés à la couche.
+          if (!empty($this->aValues['wmsservices'])) {
+          require $this->sRessourcesFile;
+          $aWmsServices = explode('|', $this->aValues['wmsservices']);
+          foreach ($aWmsServices as $iWmsServiceId) {
+          $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+          $aParams['ms_layer_id'] = array('value' => $this->aValues['my_vitis_id'], 'type' => 'number');
+          $aParams['wmsservice_id'] = array('value' => $iWmsServiceId, 'type' => 'string');
+          $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['insertPublicLayerWmsServices'], $aParams);
+          }
+          }
+          return $aReturn['sMessage'];
+         */
+    }
+
+    /**
+     * delete public layer
+     * @return id of layer deleted or error object if a layer is not deleted
+     */
+    function DELETE() {
+        /*
+          $aReturn = $this->genericDelete($this->aProperties['schema_vm4ms'], 'ms_layer', 'ms_layer_id');
+          // Supprime les flux WMS rattachés à la couche.
+          $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'wmsservice_ms_layer', 'ms_layer_id', $this->aValues["my_vitis_id"], 'text');
+          return $aReturn['sMessage'];
+         */
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/PublicWmsService.class.inc b/vas/rest/ws/vm4ms/PublicWmsService.class.inc
new file mode 100755
index 00000000..56cad928
--- /dev/null
+++ b/vas/rest/ws/vm4ms/PublicWmsService.class.inc
@@ -0,0 +1,146 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once 'PublicWmsServiceLayers.class.inc';
+require_once __DIR__ . '/../vmap/Services.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file PublicWmsService.class.inc
+ * \class PublicWmsService
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the PublicWmsService php class
+ *
+ * This class defines operation for one public wms service
+ * 
+ */
+class PublicWmsService extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("wmsservice_id", "description", "definition", "web_id", "web_name", "msdebuglevel_id");
+    }
+
+    /**
+     * get informations about public wms service
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        $this->aFields = $this->getFields($this->aProperties['schema_vm4ms'], 'v_public_wms_service', 'wmsservice_id');
+        $this->aFields['wms_service_url'] = $this->aProperties["ms_cgi_url"] . "/public/" . $this->aFields['wmsservice_id'];
+    }
+
+    /**
+     * delete a public wms service
+     */
+    function DELETE() {
+        require $this->sRessourcesFile;
+
+        $bServicesExist = false;
+        $bLayersExist = false;
+
+        // Vérifie qu'il y ait aucune couche associée
+        if ($this->areLayersAssociated()) {
+            $bLayersExist = true;
+            $this->oError = new VitisError(1, 'ERROR_LAYER_ASSOCIATED');
+            $this->oConnection->oError = new VitisError(1, 'ERROR_LAYER_ASSOCIATED');
+        }
+
+        // Vérifie qu'il y ait aucun service vMap associée
+        if ($this->areVmapServicesAssociated()) {
+            $bServicesExist = true;
+            $this->oError = new VitisError(1, 'ERROR_SERVICE_ASSOCIATED');
+            $this->oConnection->oError = new VitisError(1, 'ERROR_SERVICE_ASSOCIATED');
+        }
+
+        if (!$bLayersExist && !$bServicesExist) {
+            $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'wmsservice', 'wmsservice_id', $this->aValues['my_vitis_id'], 'text');
+            if ($this->oConnection->oBd->enErreur()) {
+                $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+            } else {
+                $this->aFields['wmsservice_id'] = $this->aValues['my_vitis_id'];
+            }
+        }
+    }
+
+    /**
+     * Return true if a vMap service is associated
+     * @return boolean
+     */
+    function areVmapServicesAssociated() {
+        $aVmapServicePath = Array('vmap', 'services');
+
+        $this->aValues['my_vitis_id'] = trim($this->aValues['my_vitis_id'], '"');
+        $this->aValues['my_vitis_id'] = trim($this->aValues['my_vitis_id'], "'");
+
+        // Récupère l'id du service vMap
+        $aVmapGetServiceValues = Array(
+            'token' => $this->aValues['token'],
+            'filter' => '{"relation": "AND", "operators": [{"column": "name", "compare_operator": "=", "value": "vm4ms_' . $this->aValues['my_vitis_id'] . '"}]}',
+            'vitis_version' => $this->aValues['vitis_version'],
+            'id' => 'services',
+            'output' => $this->aValues['output'],
+            'sEncoding' => $this->aValues['sEncoding'],
+            'sSourceEncoding' => $this->aValues['sSourceEncoding'],
+            'xslstylesheet' => $this->aValues['xslstylesheet'],
+            'module' => 'vmap'
+        );
+        $oVmapService = new Services($aVmapServicePath, $aVmapGetServiceValues, $this->aProperties, false, $this->oConnection);
+        $oVmapService->GET();
+
+        if (count($oVmapService->aObjects) > 0) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Return true if a layer is associated
+     * @return boolean
+     */
+    function areLayersAssociated() {
+        $aGetLayersPath = Array('vm4ms', 'publicwmsservicelayers');
+
+        $this->aValues['my_vitis_id'] = trim($this->aValues['my_vitis_id'], '"');
+        $this->aValues['my_vitis_id'] = trim($this->aValues['my_vitis_id'], "'");
+
+        // Récupère l'id du service vMap
+        $aGetLayersValues = Array(
+            'token' => $this->aValues['token'],
+            'filter' => '{"relation": "AND", "operators": [{"column": "wmsservice_id", "compare_operator": "=", "value": "' . $this->aValues['my_vitis_id'] . '"}]}',
+            'vitis_version' => $this->aValues['vitis_version'],
+            'id' => 'publicwmsservicelayers',
+            'output' => $this->aValues['output'],
+            'sEncoding' => $this->aValues['sEncoding'],
+            'sSourceEncoding' => $this->aValues['sSourceEncoding'],
+            'xslstylesheet' => $this->aValues['xslstylesheet'],
+            'module' => 'vm4ms'
+        );
+        $oPublicWmsServiceLayers = new PublicWmsServiceLayers($aGetLayersPath, $aGetLayersValues, $this->aProperties, false, $this->oConnection);
+        $oPublicWmsServiceLayers->GET();
+
+        if (count($oPublicWmsServiceLayers->aObjects) > 0) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/PublicWmsServiceLayer.class.inc b/vas/rest/ws/vm4ms/PublicWmsServiceLayer.class.inc
new file mode 100755
index 00000000..fa8bf70a
--- /dev/null
+++ b/vas/rest/ws/vm4ms/PublicWmsServiceLayer.class.inc
@@ -0,0 +1,51 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file PublicWmsServiceLayer.class.inc
+ * \class PublicWmsServiceLayer
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the Public WmsServiceLayer php class
+ *
+ * This class defines operation for one public wms service layer
+ * 
+ */
+class PublicWmsServiceLayer extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layer_id", "name", "title", "active", "wmsservice_id", "opacity");
+    }
+
+    /**
+     * get informations about wms service layer
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        $this->aFields = $this->getFields($this->aProperties['schema_vm4ms'], 'v_public_wms_service_ms_layer', 'wmsservice_id');
+    }
+
+    /**
+     * delete a wms service layer
+     */
+    function DELETE() {
+        
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/PublicWmsServiceLayers.class.inc b/vas/rest/ws/vm4ms/PublicWmsServiceLayers.class.inc
new file mode 100755
index 00000000..aae1322a
--- /dev/null
+++ b/vas/rest/ws/vm4ms/PublicWmsServiceLayers.class.inc
@@ -0,0 +1,189 @@
+<?php
+
+/**
+ * \file PublicWmsServiceLayers.class.inc
+ * \class PublicWmsServiceLayers
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the PublicWmsServiceLayers php class
+ *
+ * This class defines Rest Api to Vmap PublicWmsServiceLayers
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'PublicWmsServiceLayer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+
+class PublicWmsServiceLayers extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/publicwmsservicelayers",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/publicwmsservicelayers")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="PublicWmsServiceLayers",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layer_id", "name", "title", "active", "wmsservice_id", "opacity");
+    }
+
+    /**
+     * @SWG\Get(path="/publicwmsservicelayers",
+     *   tags={"WmsServiceLayers"},
+     *   summary="Get public wms service layers",
+     *   description="Request to get public wms service layers",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Porperties Response",
+     *         @SWG\Schema(ref="#/definitions/publicwmsservicelayers")
+     *     )
+     *  )
+     */
+
+    /**
+     * get public wms service layers
+     * @return PublicWmsServiceLayers
+     */
+    function GET() {
+        $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'v_public_wms_service_ms_layer', 'wmsservice_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * modify layers of wms service
+     * @return array containing the status and the message
+     */
+    function PUT() {
+        /*
+          require $this->sRessourcesFile;
+          // Couches à rattacher à la carte ?
+          if (!empty($this->aValues['wmsservice_ms_layers'])) {
+          $aLayers = explode('|', $this->aValues['wmsservice_ms_layers']);
+          foreach ($aLayers as $iLayerId) {
+          $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+          $aParams['ms_layer_id'] = array('value' => $iLayerId, 'type' => 'number');
+          $aParams['wmsservice_id'] = array('value' => $this->aValues["my_vitis_id"], 'type' => 'string');
+          $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['insertPublicWmsServiceLayers'], $aParams);
+          if ($this->oConnection->oBd->enErreur()) {
+          $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+          $oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+          $aXmlRacineAttribute['status'] = 0;
+          $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+          }
+          else {
+          $aXmlRacineAttribute['status'] = 1;
+          $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+          }
+          }
+          }
+          return $sMessage;
+         */
+    }
+
+    /**
+     * delete wms service layers
+     * @return id of wms service layer deleted or error object if a wms service layer is not deleted
+     */
+    function DELETE() {
+        /*
+          require $this->sRessourcesFile;
+          // Couches à supprimer ?
+          if (!empty($this->aValues['idList'])) {
+          $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+          $aParams['idList'] = array('value' => str_replace('|', ',', $this->aValues['idList']), 'type' => 'string');
+          $aParams['wmsservice_id'] = array('value' => $this->aValues["my_vitis_id"], 'type' => 'string');
+          $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['deletePublicWmsServiceLayers'], $aParams);
+          if ($this->oConnection->oBd->enErreur()) {
+          $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+          $oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+          $aXmlRacineAttribute['status'] = 0;
+          $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+          }
+          else {
+          $aXmlRacineAttribute['status'] = 1;
+          $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+          }
+          }
+          return $sMessage;
+         */
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/PublicWmsServices.class.inc b/vas/rest/ws/vm4ms/PublicWmsServices.class.inc
new file mode 100755
index 00000000..bf95e95e
--- /dev/null
+++ b/vas/rest/ws/vm4ms/PublicWmsServices.class.inc
@@ -0,0 +1,248 @@
+<?php
+
+/**
+ * \file PublicWmsServices.class.inc
+ * \class PublicWmsServices
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the PublicWmsServices php class
+ *
+ * This class defines Rest Api to Vmap4MapServer PublicWmsServices
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'PublicWmsService.class.inc';
+require_once __DIR__ . '/../vmap/Services.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+require_once 'Vm4msMetadataAccess.class.inc';
+
+class PublicWmsServices extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/publicwmsservices",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/publicwmsservices")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="PublicWmsServices",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("wmsservice_id", "description", "definition", "web_id", "web_name", "msdebuglevel_id");
+    }
+
+    /**
+     * @SWG\Get(path="/publicwmsservices",
+     *   tags={"WmsServices"},
+     *   summary="Get Public Wms Services",
+     *   description="Request to get Public Wms Services",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/publicwmsservices")
+     *     )
+     *  )
+     */
+
+    /**
+     * get PublicWmsServices
+     * @return  PublicWmsServices
+     */
+    function GET() {
+        $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'v_public_wms_service', 'wmsservice_id');
+        if ($aReturn['sStatus'] == 0) {
+            $sMessage = $aReturn['sMessage'];
+            return $sMessage;
+        }
+
+        // Écrit les url
+        for ($i = 0; $i < count($this->aObjects); $i++) {
+            $this->aObjects[$i]->aFields['wms_service_url'] = $this->aProperties["ms_cgi_url"] . "/public/" . $this->aObjects[$i]->aFields['wmsservice_id'];
+        }
+
+        // Reformatte la réponse 
+        if (isset($this->aValues['sEncoding'])) {
+            $sEncoding = $this->aValues['sEncoding'];
+        } else {
+            $sEncoding = null;
+        }if (isset($this->aValues['sSourceEncoding'])) {
+            $sSourceEncoding = $this->aValues['sSourceEncoding'];
+        } else {
+            $sSourceEncoding = null;
+        }if (isset($this->aValues['output'])) {
+            $output = $this->aValues['output'];
+        } else {
+            $output = null;
+        }
+        $aXmlRacineAttribute['status'] = 1;
+        $sMessage = $this->asDocument('', 'vitis', $sEncoding, True, $aXmlRacineAttribute, $sSourceEncoding, $output);
+        $aReturn = array('sStatus' => $aXmlRacineAttribute['status'], "sMessage" => $sMessage);
+
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * insert public wms service
+     * @return array containing the status and the message
+     */
+    function POST() {
+
+        // Ajout du flux vm4ms
+        $aReturn = $this->genericPost($this->aProperties['schema_vm4ms'], 'wmsservice', false, 'wmsservice_id');
+        if ($aReturn['sStatus'] == 1) {
+            $aXmlRacineAttribute['status'] = 1;
+            $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+
+            // Ajout du service vMap associé
+            $this->createVmapService();
+        } else {
+            $sMessage = $aReturn['sMessage'];
+        }
+
+        return $sMessage;
+    }
+
+    /**
+     * Create the associated vMap service
+     * @return string
+     */
+    function createVmapService() {
+        //$sFilename = $this->aProperties["map_dir"] . '/wms_public/' . $this->aValues['wmsservice_id'] . ".map";
+        $aVmapGetServiceValues = Array(
+            'token' => $this->aValues['token'],
+            'filter' => '{"relation": "AND", "operators": [{"column": "name", "compare_operator": "=", "value": "vm4ms_' . $this->aValues['my_vitis_id'] . '"}]}',
+            'vitis_version' => $this->aValues['vitis_version'],
+            'id' => 'services',
+            'output' => $this->aValues['output'],
+            'sEncoding' => $this->aValues['sEncoding'],
+            'sSourceEncoding' => $this->aValues['sSourceEncoding'],
+            'xslstylesheet' => $this->aValues['xslstylesheet'],
+            'module' => 'vmap'
+        );
+        $aVmapPostServiceValues = array(
+            'token' => $this->aValues['token'],
+            'service_type_id' => 'imagewms',
+            'service_type_version' => '1.3.0',
+            'service_vm4ms' => true,
+            'name' => 'vm4ms_' . $this->aValues['wmsservice_id'],
+            'description' => $this->aValues['description'],
+            'url' => '[ms_cgi_url]/public/' . $this->aValues['wmsservice_id']
+        );
+        $oVmapService = new Services($this->aPath, $aVmapGetServiceValues, $this->aProperties);
+        $oVmapService->GET();
+        if (!isset($oVmapService->aObjects[0])) {
+            $oVmapService->aValues = $aVmapPostServiceValues;
+            $sMessage = $oVmapService->POST();
+            return $sMessage;
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * modify public wms service
+     * @return array containing the status and the message
+     */
+    function PUT() {
+        $aReturn = $this->genericPut($this->aProperties['schema_vm4ms'], 'wmsservice', 'wmsservice_id');
+        $sMessage = $aReturn['sMessage'];
+        $oBd = new BD($this->aProperties["owner_login"], $this->aProperties["owner_pass"], $this->aProperties["database"], $this->aProperties["server"], $this->aProperties["port"], $this->aProperties["sgbd"], $this->aProperties["page_encoding"]);
+        if ($oBd->erreurRencontree) {
+            $oError = new VitisError(1, $oBd->sMessage);
+            $aXmlRacineAttribute['status'] = 0;
+            $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            $bXMLError = true;
+        } else {
+            // Création du fichier .map du flux WMS.
+            $oVm4msMetadataAccess = new Vm4msMetadataAccess($this->oConnection->oBd, '', '', session_id(), $this->aProperties);
+            $oVm4msMetadataAccess->saveWmsServiceMapFile($this->aValues['my_vitis_id']);
+        }
+        return $sMessage;
+    }
+
+    /**
+     * delete public wms service
+     * @return id of public wms service deleted or error object if a public wms service is not deleted
+     */
+    function DELETE() {
+        $aReturn = $this->genericDelete($this->aProperties['schema_vm4ms'], 'wmsservice', 'wmsservice_id');
+        return $aReturn['sMessage'];
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/Source.class.inc b/vas/rest/ws/vm4ms/Source.class.inc
new file mode 100755
index 00000000..a9ee6f78
--- /dev/null
+++ b/vas/rest/ws/vm4ms/Source.class.inc
@@ -0,0 +1,87 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file Source.class.inc
+ * \class Source
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the Source php class
+ *
+ * This class defines operation for one source
+ * 
+ */
+class Source extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("source_id", "name", "definition");
+    }
+
+    /**
+     * @SWG\Get(path="/sources/{source_id}", 
+     *   tags={"Sources"},
+     *   summary="Get source",
+     *   description="Request to get source by id",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="source_id",
+     *     in="path",
+     *     description="source id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/sources")
+     *     )
+     *  )
+     */
+
+    /**
+     * get informations about source
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        $this->aFields = $this->getFields($this->aProperties['schema_vm4ms'], 'source', 'source_id');
+    }
+
+    /**
+     * delete a source object
+     */
+    function DELETE() {
+        require $this->sRessourcesFile;
+        $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'source', 'source_id', $this->aValues['my_vitis_id'], 'string');
+        if ($this->oConnection->oBd->enErreur()) {
+            $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+        } else {
+            $this->aFields['source_id'] = $this->aValues['my_vitis_id'];
+        }
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/Sources.class.inc b/vas/rest/ws/vm4ms/Sources.class.inc
new file mode 100755
index 00000000..0b490219
--- /dev/null
+++ b/vas/rest/ws/vm4ms/Sources.class.inc
@@ -0,0 +1,292 @@
+<?php
+
+/**
+ * \file Sources.class.inc
+ * \class Sources
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the Sources php class
+ *
+ * This class defines Rest Api to Vmap4MapServer Sources
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'Source.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+
+class Sources extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/sources",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/sources")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="Sources",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("source_id", "name", "definition");
+    }
+
+    /**
+     * @SWG\Get(path="/sources",
+     *   tags={"Sources"},
+     *   summary="Get source",
+     *   description="Request to get source object",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/sources")
+     *     )
+     *  )
+     */
+
+    /**
+     * get Sources
+     * @return  Sources
+     */
+    function GET() {
+        $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'source', 'source_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Post(path="/sources",
+     *   tags={"Sources"},
+     *   summary="Add source",
+     *   description="Request to add a source object",
+     *   operationId="POST",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="formData",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="name",
+     *     in="formData",
+     *     description="name",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/sources")
+     *   )
+     *  )
+     * )
+     */
+
+    /**
+     * insert source
+     * @return array containing the status and the message
+     */
+    function POST() {
+        $aReturn = $this->genericPost($this->aProperties['schema_vm4ms'], 'source', $this->aProperties['schema_vm4ms'] . '.seq_common', 'source_id');
+        if ($aReturn['sStatus'] == 1) {
+            $aXmlRacineAttribute['status'] = 1;
+            $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            $oSource = new Source($this->aPath, $this->aValues, $this->aProperties, $this->oConnection);
+            $oSource->GET();
+        } else {
+            $sMessage = $aReturn['sMessage'];
+        }
+        return $sMessage;
+    }
+
+    /**
+     * @SWG\Put(path="/sources/{source_id}",
+     *   tags={"Sources"},
+     *   summary="Update Source",
+     *   description="Request to update source",
+     *   operationId="PUT",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   consumes= { "multipart/form-data"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="source_id",
+     *     in="path",
+     *     description="source id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="name",
+     *     in="query",
+     *     description="name",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/sources")
+     *     ),
+     * 
+     *  )
+     */
+
+    /**
+     * modify source
+     * @return array containing the status and the message
+     */
+    function PUT() {
+        $aReturn = $this->genericPut($this->aProperties['schema_vm4ms'], 'source', 'source_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Delete(path="/sources/",
+     *   tags={"Sources"},
+     *   summary="delete Source",
+     *   description="Request to delete Source",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="idList",
+     *     in="query",
+     *     description="id of the source",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/sources")
+     *     )
+     *  )
+     */
+    /**
+     * @SWG\Delete(path="/sources/{source_id}",
+     *   tags={"Sources"},
+     *   summary="delete Source",
+     *   description="Request to delete Source",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="source_id",
+     *     in="path",
+     *     description="id of the source",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/sources")
+     *     )
+     *  )
+     */
+
+    /**
+     * delete source
+     * @return id of source deleted or error object if a source is not deleted
+     */
+    function DELETE() {
+        $aReturn = $this->genericDelete($this->aProperties['schema_vm4ms'], 'source', 'source_id');
+        return $aReturn['sMessage'];
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/Versions.class.inc b/vas/rest/ws/vm4ms/Versions.class.inc
new file mode 100755
index 00000000..748467b6
--- /dev/null
+++ b/vas/rest/ws/vm4ms/Versions.class.inc
@@ -0,0 +1,79 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+
+/**
+ * \file versions.class.inc
+ * \class Versions
+ *
+ * \author Yoann Perollet <yoann.perollet@veremes.com>.
+ *
+ * 	\brief This file contains the Versions php class
+ *
+ * This class defines the rest api for versions
+ * 
+ */
+class Versions extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/Versions",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/Versions")
+     *   }
+     * )
+     * @SWG\Tag(
+     *   name="Versions",
+     *   description="Operations about versions"
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $versions ptroperties
+     */
+    function __construct($aPath, $aValues, $properties) {
+        $this->aValues = $aValues;
+        $this->aPath = $aPath;
+        $this->aProperties = $properties;
+    }
+
+    /**
+     * @SWG\Get(path="/Versions",
+     *   tags={"Versions"},
+     *   summary="Get versions",
+     *   description="Request to get versions",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *  @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/Versions")
+     *     )
+     *  )
+     */
+
+    /**
+     * 
+     * @return versions
+     */
+    function GET() {
+        $this->getVersion("vm4ms");
+        //$this->aFields = $this->aVersions;
+        //
+        $aXmlRacineAttribute['status'] = 1;
+        $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+        return $sMessage;
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/Vm4msMetadataAccess.class.inc b/vas/rest/ws/vm4ms/Vm4msMetadataAccess.class.inc
new file mode 100755
index 00000000..5c3a004a
--- /dev/null
+++ b/vas/rest/ws/vm4ms/Vm4msMetadataAccess.class.inc
@@ -0,0 +1,726 @@
+<?php
+
+/**
+ * \file Vm4msMetadataAccess.class.inc
+ * \brief Vm4msMetadataAccess.class.inc \n \n Ce fichier contient la classe php Vm4msMetadataAccess.
+ */
+class Vm4msMetadataAccess {
+
+    /**
+     * Base de donnée liée.
+     */
+    var $oBd;
+
+    /**
+     * Nom de l'utilisateur courant.
+     */
+    var $sLogin;
+
+    /**
+     * Mot de passe de l'utilisateur courant.
+     */
+    var $sPassword;
+
+    /**
+     * Identifiant de la session PHP.
+     */
+    var $sSID;
+
+    /**
+     * Tableau contenant les paramètres de configuration de l'application.
+     */
+    var $aProperties;
+
+    /**
+     * Fichier contenant les requêtes SQL.
+     */
+    var $sSQLFile = 'Vm4msMetadataAccess.sql.inc';
+
+    /**
+     * Tableau des requêtes sql utilisées par la classe.
+     */
+    var $aSql;
+
+    /**
+     * Test d'une couche ou d'un flux.
+     */
+    var $bTestMode = false;
+
+    /**
+     * Définition d'une connexion. // vm4ms_public
+     */
+    var $sConnectionDefinition = '
+    CONNECTIONTYPE postgis
+    CONNECTION "user=\'{CONNECTION_LOGIN}\' password=\'{CONNECTION_PASSWORD}\' dbname=\'{CONNECTION_DATABASE}\' host=\'{CONNECTION_SERVER}\' port=\'{CONNECTION_PORT}\'"
+    ';
+
+    /**
+     * \param $oBd Base de données liée.
+     * \param $sLogin Identifiant de l'utilisateur en cours.
+     * \param $sPassword Mot de passe de l'utilisateur en cours.
+     * \param $sSID Identifiant de la session PHP en cours.
+     * \param $properties Tableau contenant les paramètres de configuration de l'application.
+     */
+    function __construct($oBd, $sLogin, $sPassword, $sSID, $properties) {
+        $this->oBd = $oBd;
+        $this->sLogin = $sLogin;
+        $this->sPassword = $sPassword;
+        $this->sSID = $sSID;
+        $this->aProperties = $properties;
+        include $this->sSQLFile;
+        $this->aSql = $aSql[$oBd->sgbd];
+        // Création des répertoires pour les flux WMS + dossier temporaire pour MapServer.
+        $aWmsDir = array('wms_test', 'wms_public', 'wms_private', 'tmp', 'proj');
+        foreach ($aWmsDir as $sWmsDir) {
+            $sWmsDir = $this->aProperties["map_dir"] . '/' . $sWmsDir;
+            if (!is_dir($sWmsDir))
+                mkdir($sWmsDir, 0777);
+        }
+        // Création des dossiers de logs pour MapServer.
+        if (!file_exists($this->aProperties['ms_log_dir']))
+            mkdir($this->aProperties['ms_log_dir'], 0777);
+        if (!file_exists($this->aProperties['ms_log_dir'] . '/test/'))
+            mkdir($this->aProperties['ms_log_dir'] . '/test/', 0777);
+        if (!file_exists($this->aProperties['ms_log_dir'] . '/prod/'))
+            mkdir($this->aProperties['ms_log_dir'] . '/prod/', 0777);
+
+        // Remplace l'échappement sur les doubles quotes.
+        if (!empty($this->aProperties['test_wms_service_default_content']))
+            $this->aProperties['test_wms_service_default_content'] = preg_replace('/\\\\+"/', '"', $this->aProperties['test_wms_service_default_content']);
+    }
+
+    /**
+     * Création du fichier ".map" à utiliser pour le service WMS et ses couches.
+     * \param $sWmsServiceId Identifiant du service WMS qui va être utilisée.
+     * \return Retourne le chemin du fichier "map" à utiliser.
+     */
+    function saveWmsServiceTestMapFile($sWmsServiceId) {
+        $this->bTestMode = true;
+        $this->sWmsServiceId = $sWmsServiceId;
+        $sWmsServiceDef = $this->getWmsServiceDef($sWmsServiceId);
+        // Supprime les accents et caractères spéciaux.
+        $sWmsServiceId = htmlentities($sWmsServiceId, ENT_NOQUOTES, 'UTF-8');
+        $sWmsServiceId = preg_replace('#&([A-za-z])(?:acute|cedil|caron|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $sWmsServiceId);
+        $sWmsServiceId = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $sWmsServiceId); // pour les ligatures e.g. '&oelig;'
+        $sWmsServiceId = preg_replace('#&[^;]+;#', '', $sWmsServiceId); // supprime les autres caractères
+        $sWmsServiceId = str_replace(' ', '_', $sWmsServiceId); // Remplace les espaces.
+        // Nom du fichier ".map".
+        $sToken = hash('sha256', $this->sSID);
+        $sMapServerProjDir = $this->aProperties["map_dir"] . '/proj';
+        if ($sWmsServiceId == $this->aProperties['private_wms_service']) {
+            $sFilename = $this->aProperties["map_dir"] . '/wms_test/' . $sToken . ".map";
+            $sMapServerLogFile = $this->aProperties['ms_log_dir'] . '/test/' . $sToken . '.log';
+        } else {
+            $sFilename = $this->aProperties["map_dir"] . '/wms_test/' . $sToken . '_' . $sWmsServiceId . ".map";
+            $sMapServerLogFile = $this->aProperties['ms_log_dir'] . '/test/' . $sToken . '_' . $sWmsServiceId . '.log';
+        }
+        // Fichier de log pour MapServer.
+        $sWmsServiceDef = str_replace("{MS_LOG_FILE}", $sMapServerLogFile, $sWmsServiceDef);
+        $sWmsServiceDef = str_replace("{MS_PROJ_DIR}", $sMapServerProjDir, $sWmsServiceDef);
+        // Contenu par défaut du flux de test.
+        if (!empty($this->aProperties['test_wms_service_default_content']))
+            $sWmsServiceDef = preg_replace('/^\s*MAP\s*(\n|\r)/', "MAP\r\n#Début Configuration par défaut du serveur de test\r\n" . str_replace("<return>", "\r\n", $this->aProperties['test_wms_service_default_content']) . "\r\n#Fin Configuration par défaut du serveur de test\r\n", $sWmsServiceDef);
+        // Génère le fichier .map
+        if (file_exists($sFilename))
+            unlink($sFilename);
+        writeToFile(str_ireplace("STATUS DEFAULT", "STATUS ON", $sWmsServiceDef), $sFilename);
+        // Génère le fichier de proj
+        $this->generateProjFiles();
+        // Supprime le fichier de log de MapServer pour le flux.
+        if (file_exists($sMapServerLogFile))
+            unlink($sMapServerLogFile);
+        return $sFilename;
+    }
+
+    /**
+     * Création du fichier ".map" à utiliser pour le service WMS et ses couches.
+     * \param $sWmsServiceId Identifiant du service WMS qui va être utilisée.
+     * \return Retourne le chemin du fichier "map" à utiliser.
+     */
+    function saveWmsServiceMapFile($sWmsServiceId, $sToken = null) {
+        $this->bTestMode = false;
+        $this->sWmsServiceId = $sWmsServiceId;
+        $sWmsServiceDef = $this->getWmsServiceDef($sWmsServiceId);
+        // Supprime les accents et caractères spéciaux.
+        $sWmsServiceId = htmlentities($sWmsServiceId, ENT_NOQUOTES, 'UTF-8');
+        $sWmsServiceId = preg_replace('#&([A-za-z])(?:acute|cedil|caron|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $sWmsServiceId);
+        $sWmsServiceId = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $sWmsServiceId); // pour les ligatures e.g. '&oelig;'
+        $sWmsServiceId = preg_replace('#&[^;]+;#', '', $sWmsServiceId); // supprime les autres caractères
+        $sWmsServiceId = str_replace(' ', '_', $sWmsServiceId); // Remplace les espaces.
+        // Nom du fichier ".map".
+        $sMapServerProjDir = $this->aProperties["map_dir"] . '/proj';
+        $sMapServerLogFile = $this->aProperties['ms_log_dir'] . '/prod/' . $sWmsServiceId . '.log';
+        if ($sWmsServiceId == $this->aProperties['private_wms_service'])
+            $sFilename = $this->aProperties["map_dir"] . '/wms_private/' . hash('sha256', $sToken) . ".map";
+        else
+            $sFilename = $this->aProperties["map_dir"] . '/wms_public/' . $sWmsServiceId . ".map";
+        // Fichier de log pour MapServer.
+        $sWmsServiceDef = str_replace("{MS_LOG_FILE}", $sMapServerLogFile, $sWmsServiceDef);
+        $sWmsServiceDef = str_replace("{MS_PROJ_DIR}", $sMapServerProjDir, $sWmsServiceDef);
+        // Sauve le fichier .map
+        if (file_exists($sFilename))
+            unlink($sFilename);
+        writeToFile(str_ireplace("STATUS DEFAULT", "STATUS ON", $sWmsServiceDef), $sFilename);
+        // Génère le fichier de proj
+        $this->generateProjFiles();
+        // Supprime le fichier de log de MapServer pour le flux.
+        if (file_exists($sMapServerLogFile))
+            unlink($sMapServerLogFile);
+        return $sFilename;
+    }
+
+    /**
+     * Retourne la définition d'un service WMS.
+     * \param $sWmsServiceId Identifiant du service WMS qui va être utilisé.
+     * \param $sLayerDef Definition d'une ou plusieurs couches à associer.
+     * \return Retourne la définition d'un service WMS.
+     */
+    function getWmsServiceDef($sWmsServiceId, $sLayerDef = '') {
+        $oBd = $this->oBd;
+        $aProperties = $this->aProperties;
+        $aParams['sWmsServiceId'] = array('value' => $sWmsServiceId, 'type' => 'string');
+        $oPDOresult = $oBd->executeWithParams($this->aSql['getWmsServiceDef'], $aParams);
+        $aLigne = $oBd->ligneSuivante($oPDOresult);
+        $oPDOresult = $oBd->fermeResultat();
+        $sResult = $aLigne["definition"];
+        // Mode de debug.
+        if ($this->bTestMode)
+            $iDebugMode = $this->aProperties["ms_debug_mode"];
+        else
+            $iDebugMode = $aLigne["msdebuglevel_id"];
+        //
+        unset($aLigne["definition"]);
+        unset($aLigne["msdebuglevel_id"]);
+        // Others
+        foreach ($aLigne as $sFieldId => $iFieldValue) {
+            $sFieldId = substr($sFieldId, 0, -3);
+            $aObjDef[strtoupper($sFieldId)] = $this->getObjDef($iFieldValue, $sFieldId);
+        }
+        // Définitions des couches du service WMS.
+        $aParams = array();
+        if ($sWmsServiceId == $this->aProperties['private_wms_service'])
+            $sSql = $this->aSql['getPrivateWmsServiceLayersDef'];
+        else {
+            $sSql = $this->aSql['getWmsServiceLayersDef'];
+            $aParams['sWmsServiceId'] = array('value' => $sWmsServiceId, 'type' => 'string');
+        }
+        $oPDOresult = $oBd->executeWithParams($sSql, $aParams);
+        $aRecordset = $oBd->getResultTableAssoc($oPDOresult);
+        $oPDOresult = $oBd->fermeResultat();
+        $aLayerGroups = array();
+        $i = 0;
+        $aObjDef["LAYERS"] = "";
+        foreach ($aRecordset as $valeur => $aLigne)
+            $aObjDef["LAYERS"] .= $this->getWmsServiceLayerDef($aLigne);
+        // Couches optionnelles à associer.
+        $aObjDef["LAYERS"] .= PHP_EOL . $sLayerDef . PHP_EOL;
+        // Remplace les balises.
+        foreach ($aObjDef as $sObjName => $sObjDef)
+            $sResult = str_replace('{' . $sObjName . '}', $sObjDef, $sResult);
+        $sResult = str_replace('{MS_DEBUG_MODE}', $iDebugMode, $sResult);
+        //
+        return $sResult;
+    }
+
+    /**
+     * Cette méthode récupère la définition MapServer d'un objet du fichier "*.map" à générer.
+     * \param $iObjId Identifiant de l'objet à traiter.
+     * \param $sObjName Nom de l'objet à traiter (sa Classe). Par ex : "LAYER", "LEGEND"...
+     * \private
+     * \return Retourne la définition MapServer de l'objet désiré.
+     */
+    function getObjDef($iObjId, $sObjName) {
+        $sResult = "";
+        if ($iObjId) {
+            if ($sObjName == "connection")
+                $sResult = $this->getConnectionDef($iObjId);
+            else {
+                $oBd = $this->oBd;
+                $sSqlTableName = strtolower($sObjName);
+                $sSql = str_replace('[sObjName]', $sObjName, $this->aSql['getObjDef']);
+                $aParams['sSqlTableName'] = array('value' => $sSqlTableName, 'type' => 'table_name');
+                $aParams['iObjId'] = array('value' => $iObjId, 'type' => 'number');
+                $oPDOresult = $oBd->executeWithParams($sSql, $aParams);
+                $aLigne = $oBd->ligneSuivante($oPDOresult);
+                $sResult = $aLigne['definition'];
+                if ($sSqlTableName == "web") {
+                    // Template pour le test de la couche.
+                    if ($this->bTestMode) {
+                        $iPos = strrpos($sResult, 'END');
+                        $sResult = substr($sResult, 0, $iPos) . '  TEMPLATE "../template/template.html"' . PHP_EOL . '  IMAGEPATH "{TMP_DIR}"' . PHP_EOL . '  IMAGEURL "{TMP_URL}"' . PHP_EOL . substr($sResult, $iPos);
+                    }
+                    $sResult = str_replace("{TMP_DIR}", $this->aProperties["map_dir"] . '/tmp/', $sResult);
+                    $sResult = str_replace("{TMP_URL}", $this->aProperties["map_url"] . '/tmp/', $sResult);
+                    $sResult = str_replace("{MS_CGI_URL}", $this->aProperties["ms_cgi_url"] . '/', $sResult);
+                    $sResult = str_replace("{WMSSERVICE_ID}", $this->sWmsServiceId, $sResult);
+                    // Permet de ne pas cocher les boites à cocher "ignorer l'agresse GetMap" sur QGIS et FME
+                    if ($this->sWmsServiceId == $this->aProperties['private_wms_service']) {
+                        $sToken = hash('sha256', $this->sSID);
+                        $sResult = str_replace("{WMSSERVICE_URL}", $this->aProperties["ms_cgi_url"] . '/private/' . $sToken, $sResult);
+                    }else{
+                        $sResult = str_replace("{WMSSERVICE_URL}", $this->aProperties["ms_cgi_url"] . '/public/' . $this->sWmsServiceId, $sResult);
+                    }
+                }
+                $oPDOresult = $oBd->fermeResultat();
+            }
+        }
+        return $sResult . chr(13);
+    }
+
+    /**
+     * Cette méthode privée permet de récupérer la définition des couches à intégrer dans les services wms après avoir effectué
+     * une série de tests de validation.
+     * \param $aLayerInfos Informations associées à la couche à traiter.
+     * \private
+     * \return La définition de la couche traitée.
+     */
+    function getWmsServiceLayerDef($aLayerInfos) {
+        $oBd = $this->oBd;
+        $aProperties = $this->aProperties;
+        $sLayerDef = "";
+        $sLayerDef = $this->getObjDef($aLayerInfos["ms_layer_id"], "ms_layer") . chr(13);
+        $aParams['ms_layer_id'] = array('value' => $aLayerInfos['ms_layer_id'], 'type' => 'number');
+        $oPDOresult = $oBd->executeWithParams($this->aSql['getLayerDef'], $aParams);
+        $aLigneLayer = $oBd->ligneSuivante($oPDOresult);
+        $oPDOresult = $oBd->fermeResultat();
+        // Définition du système de coordonnées.
+        $aCoordsys = $this->getCoordsysDef($aLigneLayer["coordsys_id"]);
+        list($sCoordsysDef, $iSrid) = $aCoordsys;
+        $sLayerDef = str_replace("{COORDSYS}", $sCoordsysDef, $sLayerDef);
+        if (is_int($iSrid))
+            $sLayerDef = str_replace("{SRID}", $iSrid, $sLayerDef);
+        // Définition de la connexion.
+        $sConnectionDef = '';
+        if (!empty($aLigneLayer["connection_id"]))
+            $sConnectionDef = $this->getConnectionDef($aLigneLayer["connection_id"]);
+        $sLayerDef = str_replace("{CONNECTION}", $sConnectionDef, $sLayerDef);
+        // Définition des métadonnées.
+        $sMetadataDef = '';
+        if (!empty($aLigneLayer["metadata_id"]))
+            $sMetadataDef = $this->getMetadataDef($aLigneLayer["metadata_id"]);
+        $sLayerDef = str_replace("{METADATA}", $sMetadataDef, $sLayerDef);
+        //
+        $sLayerDef = str_replace("{LAYER_NAME}", $aLayerInfos['name'], $sLayerDef);
+        $sLayerDef = str_replace("{LAYER_TYPE}", $aLayerInfos['ms_layertype_id'], $sLayerDef);
+        $sLayerDef = str_replace("{LAYER_OPACITY}", $aLigneLayer["opacity"], $sLayerDef);
+        $sLayerDef = str_replace("{TABLE_ID}", $aLigneLayer["tableidfield"], $sLayerDef);
+        $sLayerDef = str_replace("{TABLE_NAME}", '\"' . $aLigneLayer["tablename"] . '\"', $sLayerDef);
+        $sLayerDef = str_replace("{TABLE_SCHEMA}", '\"' . $aLigneLayer["tableschema"] . '\"', $sLayerDef);
+        $sLayerDef = str_replace("{LAYER_TITLE}", str_replace('"', '\"', $aLigneLayer['title']), $sLayerDef);
+        $sDataDir = '';
+        if (!empty($aProperties['datadir']))
+            $sDataDir = $aProperties['datadir'];
+        $sLayerDef = str_replace("{DATADIR}", $sDataDir, $sLayerDef);
+        $sLayerDef = $sLayerDef . chr(13);
+        return $sLayerDef;
+    }
+
+    /**
+     * Cette méthode récupère la définition MapServer d'un objet COORDSYS.
+     * \param iCoordsysId Identifiant de l'objet COORDSYS
+     * \private
+     * \return Retourne la définition MapServer de l'objet.
+     */
+    function getCoordsysDef($iCoordsysId) {
+        $aResult = array('', '');
+        if ($iCoordsysId) {
+            $oBd = $this->oBd;
+            $aParams['iCoordsysId'] = array('value' => $iCoordsysId, 'type' => 'number');
+            $oPDOresult = $oBd->executeWithParams($this->aSql['getCoordsysDef'], $aParams);
+            $aLigne = $oBd->ligneSuivante($oPDOresult);
+            $oPDOresult = $oBd->fermeResultat();
+            $aResult = array($aLigne["definition"] . chr(13), $aLigne["srid"]);
+        }
+        return $aResult;
+    }
+
+    /**
+     * Création du fichier ".map" à utiliser pour le test de la couche associée à un flux WMS de test.
+     * \param $sWmsServiceId Nom du flux WMS qui va être utilisé.
+     * \param $iLayerToTest Identifiant de la couche à tester.
+     * \return Retourne le chemin du fichier "map" à utiliser.
+     */
+    function saveLayerTestMapFile($sWmsServiceId, $iLayerToTest) {
+        $oBd = $this->oBd;
+        $this->bTestMode = true;
+        $aProperties = $this->aProperties;
+        $this->sWmsServiceId = $sWmsServiceId;
+        // Infos de la couche (si elle n'est pas déja associée au flux wms de test).
+        $aParams['iLayerToTest'] = array('value' => $iLayerToTest, 'type' => 'number');
+        $aParams['sWmsServiceId'] = array('value' => $sWmsServiceId, 'type' => 'string');
+        $oPDOresult = $oBd->executeWithParams($this->aSql['getLayerInfoToTest'], $aParams);
+        $aLigne = $oBd->ligneSuivante($oPDOresult);
+        if ($aLigne['nb_layer_to_test'] == 0) {
+            $oPDOresult = $oBd->fermeResultat();
+            // Définition de la couche à tester.
+            $sLayersDef = "";
+            $sLayer = $aLigne['definitiontmp'];
+            // Définition du système de coordonnées.
+            $aCoordsys = array($aLigne['coordsys_definition'] . chr(13), $aLigne['srid']);
+            list($sCoordsysDef, $iSrid) = $aCoordsys;
+            $sLayer = str_replace("{COORDSYS}", $sCoordsysDef, $sLayer);
+            if (is_int($iSrid))
+                $sLayer = str_replace("{SRID}", $iSrid, $sLayer);
+            // Connexion.
+            $sConnectionDef = '';
+            if (!empty($aLigne['connection_id']))
+                $sConnectionDef = $this->getConnectionDef($aLigne['connection_id']);
+            $sLayer = str_replace("{CONNECTION}", $sConnectionDef, $sLayer);
+            // Définition des métadonnées.
+            $sMetadataDef = '';
+            if (!empty($aLigne["metadata_id"]))
+                $sMetadataDef = $this->getMetadataDef($aLigne["metadata_id"]);
+            $sLayer = str_replace("{METADATA}", $sMetadataDef, $sLayer);
+            // Autres tags.
+            $sLayer = str_replace("{LAYER_NAME}", $aLigne['name'], $sLayer);
+            $sLayer = str_replace("{LAYER_TYPE}", $aLigne['ms_layertype_id'], $sLayer);
+            $sLayer = str_replace("{LAYER_OPACITY}", $aLigne["opacity"], $sLayer);
+            $sLayer = str_replace("{TABLE_ID}", $aLigne["tableidfield"], $sLayer);
+            $sLayer = str_replace("{TABLE_NAME}", '\"' . $aLigne["tablename"] . '\"', $sLayer);
+            $sLayer = str_replace("{TABLE_SCHEMA}", '\"' . $aLigne["tableschema"] . '\"', $sLayer);
+            $sLayer = str_replace("{LAYER_TITLE}", str_replace('"', '\"', $aLigne['title']), $sLayer);
+            $sDataDir = '';
+            if (!empty($aProperties['datadir']))
+                $sDataDir = $aProperties['datadir'];
+            $sLayer = str_replace("{DATADIR}", $sDataDir, $sLayer);
+            $sLayersDef .= $sLayer;
+            // Définition du flux wms de test (et ses couches) avec la couche à tester.
+            $sMapDef = $this->getWmsServiceDef($sWmsServiceId, $sLayersDef);
+        }
+        else {
+            // Définition du flux wms de test (et ses couches) sans la couche à tester (déja associée).
+            $sMapDef = $this->getWmsServiceDef($sWmsServiceId);
+        }
+        // Fichier de log pour MapServer.
+        $sMapServerLogFile = $this->aProperties['ms_log_dir'] . '/test/' . hash('sha256', session_id()) . '_' . $aLigne['name'] . '.log';
+        $sMapDef = str_replace("{MS_LOG_FILE}", $sMapServerLogFile, $sMapDef);
+
+        // Dossier de proj
+        $sMapServerProjDir = $this->aProperties["map_dir"] . '/proj';
+        $sMapDef = str_replace("{MS_PROJ_DIR}", $sMapServerProjDir, $sMapDef);
+
+        // Contenu par défaut du flux de test.
+        if (!empty($this->aProperties['test_wms_service_default_content']))
+            $sMapDef = preg_replace('/^\s*MAP\s*(\n|\r)/', "MAP\r\n#Début Configuration par défaut du serveur de test\r\n" . str_replace("<return>", "\r\n", $this->aProperties['test_wms_service_default_content']) . "\r\n#Fin Configuration par défaut du serveur de test\r\n", $sMapDef);
+        // Sauve le fichier ".map".
+        $sFilename = $this->aProperties["map_dir"] . '/wms_test/' . hash('sha256', session_id()) . '_' . $aLigne['name'] . ".map";
+        if (file_exists($sFilename))
+            unlink($sFilename);
+        writeToFile($sMapDef, $sFilename);
+        // Génère le fichier de proj
+        $this->generateProjFiles();
+        // Supprime le fichier de log de MapServer pour le flux de test + la couche.
+        if (file_exists($sMapServerLogFile))
+            unlink($sMapServerLogFile);
+        return $sFilename;
+    }
+
+    /**
+     * Retourne la définition d'une connexion.
+     * \param iConnectionId Identifiant de la connexion
+     * \return Retourne la définition de la connexion.
+     */
+    function getConnectionDef($iConnectionId) {
+        // $sConnectionDefinition
+        $sDefinition = "";
+        if (!empty($iConnectionId)) {
+            $aParams['iConnectionId'] = array('value' => $iConnectionId, 'type' => 'number');
+            $oPDOresult = $this->oBd->executeWithParams($this->aSql['getConnection'], $aParams);
+            $aLigne = $this->oBd->ligneSuivante($oPDOresult);
+            $oPDOresult = $this->oBd->fermeResultat();
+            $sDefinition = $this->sConnectionDefinition;
+            $sLogin = $this->sLogin;
+            $sPassword = $this->sPassword;
+            if (empty($sLogin) && empty($sPassword)) {
+                if ((!empty($aLigne['user']) && $aLigne['user'] != '{CONNECTION_LOGIN}') && (!empty($aLigne['password']) && $aLigne['password'] != '{CONNECTION_PASSWORD}')) {
+                    $sLogin = $aLigne['user'];
+                    $sPassword = $aLigne['password'];
+                } else {
+                    $sLogin = $_SESSION["ses_Login"];
+                    $sPassword = decodepass($_SESSION["ses_Password"]);
+                }
+            }
+
+            // Ici il faudra encrypter le password
+            if ($this->aProperties['use_msencrypt']) {
+                $aCommand = array();
+                $sCommand = $this->aProperties['msencrypt_path'] . ' -key ' . $this->aProperties['msencrypt_key_path'] . ' "' . $sPassword . '"';
+                exec($sCommand, $aCommand);
+                if (!empty($aCommand[0])) {
+                    $sPassword = '{' . $aCommand[0] . '}';
+                }
+            }
+
+            $sDefinition = str_replace("{CONNECTION_LOGIN}", str_replace("'", "\'", str_replace('\\', '\\\\\\', $sLogin)), $sDefinition);
+            $sDefinition = str_replace("{CONNECTION_PASSWORD}", str_replace("'", "\'", str_replace('\\', '\\\\\\', $sPassword)), $sDefinition);
+            // Serveur.
+            if (!empty($aLigne['server']))
+                $sServer = $aLigne['server'];
+            else
+                $sServer = $this->aProperties['server'];
+            $sDefinition = str_replace("{CONNECTION_SERVER}", $sServer, $sDefinition);
+            // Port.
+            if (!empty($aLigne['port']))
+                $sPort = $aLigne['port'];
+            else
+                $sPort = $this->aProperties['port'];
+            $sDefinition = str_replace("{CONNECTION_PORT}", $sPort, $sDefinition);
+            // Base de données.
+            if (!empty($aLigne['database']))
+                $sDatabase = $aLigne['database'];
+            else
+                $sDatabase = $this->aProperties['database'];
+            $sDefinition = str_replace("{CONNECTION_DATABASE}", $sDatabase, $sDefinition);
+        }
+
+        return $sDefinition;
+    }
+
+    /**
+     * Generate the epsg file in the proj directory
+     * @return string
+     */
+    function generateProjFiles() {
+
+        $aProj = array();
+        $aSQLParams = array(
+            'sSchema' => array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name')
+        );
+        $oResult = $this->oBd->executeWithParams($this->aSql['getCoordsys'], $aSQLParams);
+        if (gettype($oResult) == 'object') {
+            $aProj = $this->oBd->getResultTableAssoc($oResult);
+        }
+
+        $sFilename = $this->aProperties["map_dir"] . '/proj/epsg';
+        if (file_exists($sFilename)) {
+            unlink($sFilename);
+        }
+
+        $sProjDefs = '';
+        for ($i = 0; $i < count($aProj); $i++) {
+            $sProjDef = '# ' . $aProj[$i]['label'] . PHP_EOL;
+            $sProjDef .= '<' . $aProj[$i]['coordsys_id'] . '> ' . $aProj[$i]['epsg_definition'] . ' <>';
+            $sProjDefs .= $sProjDef . PHP_EOL;
+        }
+
+        writeToFile($sProjDefs, $sFilename);
+        return $sFilename;
+    }
+
+    /**
+     * Retourne la définition des métadonnées d'une couche.
+     * \param iMetadataId Identifiant de la métadonnée
+     * \return Retourne la définition de la métadonnée.
+     */
+    function getMetadataDef($iMetadataId) {
+        $sDefinition = '';
+        if (!empty($iMetadataId)) {
+            $aParams['iMetadataId'] = array('value' => $iMetadataId, 'type' => 'number');
+            $oPDOresult = $this->oBd->executeWithParams($this->aSql['getMetadata'], $aParams);
+            $aLigne = $this->oBd->ligneSuivante($oPDOresult);
+            $oPDOresult = $this->oBd->fermeResultat();
+            $sDefinition = $aLigne['definition'];
+        }
+        return $sDefinition;
+    }
+
+    /**
+     * Crée un fichier template GetFeatureInfo
+     * \param $iLayerId Identifiant de la couche
+     * \param $sToken
+     * \param $sTemplate contenu à écrire ou null pour générer automatiquement
+     *
+     * \return Retourne la définition du template ou false.
+     */
+    function createGetFeatureInfoTemplate($iLayerId, $sToken, $sTemplate=null) {
+
+        // Génère le contenu du fichier si non spécifié
+        if (!isset($sTemplate)) {
+            $sTemplate = $this->generateGetFeatureInfoTemplateContent($iLayerId, $sToken);
+        }
+
+        // Récupère le nom de la couche
+        $sLayerName = $this->getLayerName($iLayerId, $sToken);
+        if (empty($sLayerName)) {
+            return false;
+        }
+
+        // Écrit le fichier
+        if (!empty($sTemplate)) {
+            if (!is_dir($this->aProperties['map_dir'])) {
+                return false;
+            }
+            if (!is_dir($this->aProperties['map_dir'] . '/template')) {
+                mkdir($this->aProperties['map_dir'] . '/template', 0777);
+            }
+            if (!is_dir($this->aProperties['map_dir'] . '/template/getfeatureinfo')) {
+                mkdir($this->aProperties['map_dir'] . '/template/getfeatureinfo', 0777);
+            }
+            file_put_contents($this->aProperties['map_dir'] . '/template/getfeatureinfo/' . $sLayerName . '.html', $sTemplate);
+        } else {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * Génère le contenu du template GetFeatureInfo
+     * \param $iLayerId Identifiant de la couche
+     * \param $sToken
+     * \return Retourne la définition du template ou false.
+     */
+    function generateGetFeatureInfoTemplateContent($iLayerId, $sToken) {
+        require_once 'Layer.class.inc';
+        $sTemplate = false;
+
+        if (empty($iLayerId)) {
+            return false;
+        }
+
+        if (empty($sToken)) {
+            return false;
+        }
+
+        if (empty($this->aProperties['getFeatureInfo_default_content'])) {
+            return false;
+        }else{
+            $sTemplate = $this->aProperties['getFeatureInfo_default_content'];
+        }
+
+        // Remplace la balise {TABLE}
+        if (strpos($sTemplate, '{TABLE}') !== false) {
+
+            // Récupère l'ensemble des colonnes de la table liée à la couche
+            $aLayerTableColumns = $this->getLayerTableColumns($iLayerId, $sToken);
+
+            $sHTMLTable = '<table><return>';
+            for ($i=0; $i < count($aLayerTableColumns); $i++) {
+                $sHTMLTable .= '<tr><return>';
+                $sHTMLTable .= '<td>' . $aLayerTableColumns[$i] . '</td><return>';
+                $sHTMLTable .= '<td>[' . $aLayerTableColumns[$i] . ']</td><return>';
+                $sHTMLTable .= '</tr><return>';
+            }
+            $sHTMLTable .= '</table><return>';
+            $sTemplate = str_replace('{TABLE}', $sHTMLTable, $sTemplate);
+        }
+
+        $sTemplate = str_replace("<return>", "\r\n", $sTemplate);
+        return $sTemplate;
+    }
+
+    /**
+     * Supprime le template GetFeatureInfo
+     * \param $iLayerId Identifiant de la couche
+     * \param $sToken
+     * \param $sLayerName Nom de la couche
+     *
+     * \return Retourne true/false
+     */
+    function deleteGetFeatureInfoTemplate($iLayerId, $sToken, $sLayerName=null) {
+
+        if (empty($iLayerId)) {
+            return false;
+        }
+        if (empty($sToken)) {
+            return false;
+        }
+
+        // Récupère le nom de la couche
+        if (empty($sLayerName)) {
+            $sLayerName = $this->getLayerName($iLayerId, $sToken);
+            if (empty($sLayerName)) {
+                return false;
+            }
+        }
+
+        // Supprime le fichier
+        $sFilePath = $this->aProperties['map_dir'] . '/template/getfeatureinfo/' . $sLayerName . '.html';
+        if (file_exists($sFilePath)) {
+            return unlink($sFilePath);
+        }else{
+            return false;
+        }
+    }
+
+    /**
+     * Met à jour le template GetFeatureInfo
+     * \param $iLayerId Identifiant de la couche
+     * \param $sToken
+     * \param $sTemplate contenu à écritre
+     *
+     * \return Retourne true/false
+     */
+    function updateGetFeatureInfoTemplate($iLayerId, $sToken, $sTemplate) {
+        return $this->createGetFeatureInfoTemplate($iLayerId, $sToken, $sTemplate);
+    }
+
+    /**
+     * Récupère le nom d'une couche
+     * \param $iLayerId Identifiant de la couche
+     * \param $sToken
+     * \return nom de la couche
+     */
+    function getLayerName($iLayerId, $sToken) {
+
+        if (empty($iLayerId)) {
+            return false;
+        }
+
+        if (empty($sToken)) {
+            return false;
+        }
+
+        $aPath = array('vm4ms', 'layers', $iLayerId);
+        $aValues = array();
+        $aValues['token'] = $sToken;
+        $aValues['output'] = 'application/json';
+        $aValues['my_vitis_id'] = $iLayerId;
+        $aValues['module'] = 'vm4ms';
+        $aValues['attributs'] = 'tableschema|tablename';
+
+        $oLayer = new Layer($aPath, $aValues, $this->aProperties);
+        $oLayer->GET();
+
+        $sLayerName = $oLayer->aFields['name'];
+
+        return $sLayerName;
+    }
+
+    /**
+     * Récupère les colonnes de la table associée à la couche
+     * \param $iLayerId Identifiant de la couche
+     * \param $sToken
+     * \return Tableau contenant les colonnes
+     */
+    function getLayerTableColumns($iLayerId, $sToken) {
+
+        if (empty($iLayerId)) {
+            return false;
+        }
+
+        if (empty($sToken)) {
+            return false;
+        }
+
+        $aPath = array('vm4ms', 'layers', $iLayerId);
+        $aValues = array();
+        $aValues['token'] = $sToken;
+        $aValues['output'] = 'application/json';
+        $aValues['my_vitis_id'] = $iLayerId;
+        $aValues['module'] = 'vm4ms';
+        $aValues['attributs'] = 'tableschema|tablename';
+
+        $oLayer = new Layer($aPath, $aValues, $this->aProperties);
+        $oLayer->GET();
+
+        $sSchema = $oLayer->aFields['tableschema'];
+        $sTable = $oLayer->aFields['tablename'];
+        $aColumns = $oLayer->getTableColumns($sSchema, $sTable);
+
+        return $aColumns;
+    }
+
+}
+
+?>
diff --git a/vas/rest/ws/vm4ms/Vm4msMetadataAccess.sql.inc b/vas/rest/ws/vm4ms/Vm4msMetadataAccess.sql.inc
new file mode 100755
index 00000000..772d4723
--- /dev/null
+++ b/vas/rest/ws/vm4ms/Vm4msMetadataAccess.sql.inc
@@ -0,0 +1,22 @@
+<?php
+
+// Test d'un flux WMS.
+$aSql['pgsql']['getWmsServiceDef'] = 'SELECT definition, web_id, msdebuglevel_id FROM ' . $this->aProperties['schema_vm4ms'] . '.wmsservice WHERE "wmsservice_id"=[sWmsServiceId]';
+$aSql['pgsql']['getObjDef'] = 'SELECT * FROM ' . $this->aProperties['schema_vm4ms'] . '.[sSqlTableName] WHERE [sObjName]_id=[iObjId]';
+$aSql['pgsql']['getWmsServiceLayersDef'] = 'SELECT wmsservice_ms_layer.wmsservice_id, wmsservice_ms_layer.ms_layer_id, ms_layer.name, ms_layer.opacity, coordsys.definition AS coordsys_def, ms_layer.ms_layertype_id FROM ' . $this->aProperties['schema_vm4ms'] . '.wmsservice_ms_layer LEFT JOIN ' . $this->aProperties['schema_vm4ms'] . '.ms_layer ON ms_layer.ms_layer_id::text = wmsservice_ms_layer.ms_layer_id::text LEFT JOIN ' . $this->aProperties['schema_vm4ms'] . '.connection ON connection.connection_id = ms_layer.connection_id LEFT JOIN ' . $this->aProperties['schema_vm4ms'] . '.coordsys ON coordsys.coordsys_id = ms_layer.coordsys_id WHERE "wmsservice_id"=[sWmsServiceId] AND ms_layer.active = true';
+$aSql['pgsql']['getLayerDef'] = 'SELECT name, "coordsys_id", "connection_id", "opacity", "tableidfield", "tablename", "tableschema", title, metadata_id FROM ' . $this->aProperties['schema_vm4ms'] . '.ms_layer WHERE "ms_layer_id" = [ms_layer_id]';
+$aSql['pgsql']['getCoordsysDef'] = 'SELECT "definition", "coordsys_id" as "srid" FROM ' . $this->aProperties['schema_vm4ms'] . '.coordsys WHERE "coordsys_id"=[iCoordsysId]';
+$aSql['pgsql']['getPrivateWmsServiceLayersDef'] = 'SELECT v_private_ms_layer.ms_layer_id, v_private_ms_layer.name, v_private_ms_layer.opacity, coordsys.definition AS coordsys_def, v_private_ms_layer.ms_layertype_id FROM ' . $this->aProperties['schema_vm4ms'] . '.v_private_ms_layer LEFT JOIN ' . $this->aProperties['schema_vm4ms'] . '.connection ON connection.connection_id = v_private_ms_layer.connection_id LEFT JOIN ' . $this->aProperties['schema_vm4ms'] . '.coordsys ON coordsys.coordsys_id = v_private_ms_layer.coordsys_id WHERE v_private_ms_layer.active = true';
+
+// Test d'une couche.
+$aSql['pgsql']['getLayerInfoToTest'] = 'SELECT ms_layer.*, coordsys.definition AS coordsys_definition, coordsys.coordsys_id as srid, connection.connection_id,(SELECT COUNT(*) FROM s_vm4ms.wmsservice_ms_layer WHERE wmsservice_id = [sWmsServiceId] AND ms_layer_id = [iLayerToTest]) AS nb_layer_to_test FROM ' . $this->aProperties['schema_vm4ms'] . '.ms_layer LEFT JOIN ' . $this->aProperties['schema_vm4ms'] . '.coordsys ON coordsys.coordsys_id = ms_layer.coordsys_id LEFT JOIN ' . $this->aProperties['schema_vm4ms'] . '.connection ON connection.connection_id = ms_layer.connection_id WHERE ms_layer_id = [iLayerToTest]';
+
+// Définition d'une connexion.
+$aSql['pgsql']['getConnection'] = 'SELECT * FROM ' . $this->aProperties['schema_vm4ms'] . '.connection WHERE connection_id = [iConnectionId]';
+
+// Génération fichiers de proj
+$aSql['pgsql']['getCoordsys'] = 'SELECT * FROM "[sSchema]".coordsys';
+
+// Définition d'une métadonnée.
+$aSql['pgsql']['getMetadata'] = 'SELECT * FROM ' . $this->aProperties['schema_vm4ms'] . '.metadata WHERE metadata_id = [iMetadataId]';
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/Vmap4MapServer.class.inc b/vas/rest/ws/vm4ms/Vmap4MapServer.class.inc
new file mode 100755
index 00000000..24136736
--- /dev/null
+++ b/vas/rest/ws/vm4ms/Vmap4MapServer.class.inc
@@ -0,0 +1,17 @@
+<?php
+
+require_once __DIR__ . "/../../class/vitis_lib/DbClass.class.inc";
+require_once __DIR__ . '/../vmap/Vmap.class.inc';
+
+class Vmap4MapServer extends Vmap {
+
+    //Chemin du fichier de ressources contenant les requêtes SQL
+    var $sRessourcesFile = 'ws/vm4ms/Vmap4MapServer.class.sql.inc';
+
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/Vmap4MapServer.class.sql.inc b/vas/rest/ws/vm4ms/Vmap4MapServer.class.sql.inc
new file mode 100755
index 00000000..841d27cf
--- /dev/null
+++ b/vas/rest/ws/vm4ms/Vmap4MapServer.class.sql.inc
@@ -0,0 +1,31 @@
+<?php
+
+//Définition des requêtes de l'api Vitis
+$aSql['checkIP'] = "SELECT user_id, ip_constraint FROM [sSchemaFramework].v_user WHERE login ='[sLogin]'";
+$aSql['getGroups'] = "SELECT group_id FROM [sSchemaFramework].v_user_group_by_rights WHERE user_id = [user_id]";
+$aSql['loginUnique'] = 'SELECT UPPER("login") FROM [sSchemaFramework]."v_user" WHERE UPPER("login")=UPPER(\'sLoginUser\')';
+$aSql['getLoginbyId'] = 'SELECT "login" FROM [sSchemaFramework]."v_user" WHERE user_id=[user_id]';
+$aSql['getTableColumn'] = 'SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = \'[sSchemaFramework]\' and table_name= \'[sTable]\'';
+$aSql['getUserPrivileges'] = 'SELECT groname FROM pg_user s LEFT OUTER JOIN pg_group g on (s.usesysid = any(g.grolist) )inner join [sSchemaFramework].v_user on "v_user".login = usename WHERE user_id = [user_id]';
+$aSql['listDomain'] = 'SELECT distinct domain, alias FROM [sSchemaFramework].domain WHERE "type" = \'AD\'';
+$aSql['createRolname'] = 'CREATE ROLE "vitis_[sDomain]" NOSUPERUSER INHERIT NOCREATEDB CREATEROLE;';
+$aSql['getInfoRolname'] = 'SELECT * FROM pg_catalog.pg_roles WHERE rolname = \'vitis_[sDomain]\'';
+// Layers
+$aSql['getLayerWmsServices'] = "SELECT DISTINCT wmsservice_id FROM [sSchemaVm4ms].wmsservice_ms_layer WHERE ms_layer_id = [ms_layer_id] ORDER BY wmsservice_id";
+$aSql['insertLayerWmsServices'] = "INSERT INTO [sSchemaVm4ms].wmsservice_ms_layer(wmsservice_id, ms_layer_id) VALUES([wmsservice_id], [ms_layer_id])";
+$aSql['getLayer'] = "SELECT ms_layer.ms_layer_id, ms_layer.name, ms_layer.title, ms_layer.coordsys_id, coordsys.label as coordsys_label, ms_layer.source_id, ms_layer.connection_id, ms_layer.tableschema, ms_layer.tablename, ms_layer.tableidfield, ms_layer.definition, ms_layer.active, ms_layer.opacity, ms_layer.ms_layertype_id , COALESCE(connection.private, false) AS private_connection, connection.name AS connection_label, source.name AS source_label, ms_layer.definitiontmp, connection.database AS database, ms_layer.metadata_id FROM [sSchemaVm4ms].ms_layer LEFT JOIN [sSchemaVm4ms].connection ON connection.connection_id = ms_layer.connection_id LEFT JOIN [sSchemaVm4ms].source ON source.source_id = ms_layer.source_id LEFT JOIN [sSchemaVm4ms].coordsys ON coordsys.coordsys_id = ms_layer.coordsys_id WHERE ms_layer_id = [ms_layer_id]";
+$aSql['getDefaultLayerId'] = "SELECT ms_layer_id FROM [sSchemaVm4ms].ms_layer WHERE name = (SELECT name FROM [sSchemaVm4ms].ms_layer WHERE ms_layer_id = [ms_layer_id])";
+$aSql['getLayerName'] = "SELECT name FROM [sSchemaVm4ms].ms_layer WHERE ms_layer_id = [ms_layer_id]";
+$aSql['publishLayerDefinition'] = "UPDATE s_vm4ms.ms_layer SET definition = definitiontmp WHERE ms_layer_id = [ms_layer_id]";
+$aSql['getConnectionType'] = "SELECT private FROM [sSchemaVm4ms].connection WHERE connection_id = [connection_id]";
+$aSql['activateLayers'] = 'UPDATE [sSchemaVm4ms].ms_layer SET active = TRUE WHERE ms_layer_id IN ([idList])';
+$aSql['desactivateLayers'] = 'UPDATE [sSchemaVm4ms].ms_layer SET active = FALSE WHERE ms_layer_id IN ([idList])';
+$aSql['getLayerId'] = "SELECT ms_layer_id FROM [sSchemaVm4ms].ms_layer WHERE name = [name]";
+// WmsServices
+$aSql['insertWmsServiceLayers'] = "INSERT INTO [sSchemaVm4ms].wmsservice_ms_layer(wmsservice_id, ms_layer_id) VALUES([wmsservice_id], [ms_layer_id])";
+$aSql['deleteWmsServiceLayers'] = "DELETE FROM [sSchemaVm4ms].wmsservice_ms_layer WHERE wmsservice_id=[wmsservice_id] AND ms_layer_id IN ([idList])";
+$aSql['getWmsServiceLayersSource'] = "SELECT wmsservice_ms_layer.wmsservice_id, ms_layer.name, source.name as source FROM [sSchemaVm4ms].wmsservice_ms_layer LEFT JOIN [sSchemaVm4ms].ms_layer ON ms_layer.ms_layer_id = wmsservice_ms_layer.ms_layer_id LEFT JOIN [sSchemaVm4ms].source ON source.source_id = ms_layer.source_id WHERE wmsservice_id = [wmsservice_id]";
+$aSql['getPrivateLayersSource'] = "SELECT ms_layer.name, source.name as source FROM [sSchemaVm4ms].ms_layer LEFT JOIN [sSchemaVm4ms].source ON source.source_id = ms_layer.source_id LEFT JOIN [sSchemaVm4ms].connection ON connection.connection_id = ms_layer.connection_id WHERE connection.private = true";
+// vMap services
+$aSql['getVmapCalquesFromVM4MSService'] = "SELECT layer_id, name, layer_list FROM s_vmap.layer WHERE service_id IN (SELECT service_id FROM s_vmap.service where service_vm4ms=TRUE AND name IN ([serviceIdList]))";
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/WebObject.class.inc b/vas/rest/ws/vm4ms/WebObject.class.inc
new file mode 100755
index 00000000..9efa3d88
--- /dev/null
+++ b/vas/rest/ws/vm4ms/WebObject.class.inc
@@ -0,0 +1,133 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file WebObject.class.inc
+ * \class WebObject
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the WebObject php class
+ *
+ * This class defines operation for one web object
+ * 
+ */
+class WebObject extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("web_id", "name", "definition");
+    }
+
+    /**
+     * @SWG\Get(path="/webobjects/{web_id}", 
+     *   tags={"WebObjects"},
+     *   summary="Get web object",
+     *   description="Request to get web object by id",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="web_id",
+     *     in="path",
+     *     description="web id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/webobjects")
+     *     )
+     *  )
+     */
+
+    /**
+     * get informations about web object
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        $this->aFields = $this->getFields($this->aProperties['schema_vm4ms'], 'web', 'web_id');
+    }
+
+    /**
+     * delete a web object
+     */
+    function DELETE() {
+        require $this->sRessourcesFile;
+
+        $bServiceExists = false;
+
+        // Vérifie qu'il y ait aucune couche associée
+        if ($this->areWmsServicesAssociated()) {
+            $bServiceExists = true;
+            $this->oError = new VitisError(1, 'ERROR_WMSSERVICE_ASSOCIATED');
+            $this->oConnection->oError = new VitisError(1, 'ERROR_WMSSERVICE_ASSOCIATED');
+        }
+
+        if (!$bServiceExists) {
+            $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'web', 'web_id', $this->aValues['my_vitis_id'], 'string');
+            if ($this->oConnection->oBd->enErreur()) {
+                $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+            } else {
+                $this->aFields['web_id'] = $this->aValues['my_vitis_id'];
+            }
+        }
+    }
+
+    /**
+     * Return true if a wmsservice is associated
+     * @return boolean
+     */
+    function areWmsServicesAssociated() {
+        require_once 'WmsServices.class.inc';
+
+        $aGetWmsServicesPath = Array('vm4ms', 'wmsservices');
+
+        $this->aValues['my_vitis_id'] = trim($this->aValues['my_vitis_id'], '"');
+        $this->aValues['my_vitis_id'] = trim($this->aValues['my_vitis_id'], "'");
+
+        // Récupère l'id du service vMap
+        $aGetWmsServicesValues = Array(
+            'token' => $this->aValues['token'],
+            'filter' => '{"relation": "AND", "operators": [{"column": "web_id", "compare_operator": "=", "value": ' . $this->aValues['my_vitis_id'] . '}]}',
+            'vitis_version' => $this->aValues['vitis_version'],
+            'id' => 'wmsservices',
+            'output' => $this->aValues['output'],
+            'sEncoding' => $this->aValues['sEncoding'],
+            'sSourceEncoding' => $this->aValues['sSourceEncoding'],
+            'xslstylesheet' => $this->aValues['xslstylesheet'],
+            'module' => 'vm4ms'
+        );
+        $oWmsServices = new WmsServices($aGetWmsServicesPath, $aGetWmsServicesValues, $this->aProperties);
+        $oWmsServices->GET();
+
+        if (count($oWmsServices->aObjects) > 0) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/WebObjects.class.inc b/vas/rest/ws/vm4ms/WebObjects.class.inc
new file mode 100755
index 00000000..1a8bcf7b
--- /dev/null
+++ b/vas/rest/ws/vm4ms/WebObjects.class.inc
@@ -0,0 +1,306 @@
+<?php
+
+/**
+ * \file WebObjects.class.inc
+ * \class WebObjects
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the WebObjects php class
+ *
+ * This class defines Rest Api to Vmap4MapServer WebObjects
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'WebObject.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+
+class WebObjects extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/webobjects",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/webobjects")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="WebObjects",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("web_id", "name", "definition");
+    }
+
+    /**
+     * @SWG\Get(path="/webobjects",
+     *   tags={"WebObjects"},
+     *   summary="Get web object",
+     *   description="Request to get web object",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/webobjects")
+     *     )
+     *  )
+     */
+
+    /**
+     * get WebObjects
+     * @return  WebObjects
+     */
+    function GET() {
+        $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'web', 'web_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Post(path="/webobjects",
+     *   tags={"WebObjects"},
+     *   summary="Add web object",
+     *   description="Request to add a web object",
+     *   operationId="POST",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="formData",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="name",
+     *     in="formData",
+     *     description="name",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="definition",
+     *     in="formData",
+     *     description="definition",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/webobjects")
+     *   )
+     *  )
+     * )
+     */
+
+    /**
+     * insert web object
+     * @return array containing the status and the message
+     */
+    function POST() {
+        $aReturn = $this->genericPost($this->aProperties['schema_vm4ms'], 'web', $this->aProperties['schema_vm4ms'] . '.seq_common', 'web_id');
+        if ($aReturn['sStatus'] == 1) {
+            $aXmlRacineAttribute['status'] = 1;
+            $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            $oWebObject = new WebObject($this->aPath, $this->aValues, $this->aProperties, $this->oConnection);
+            $oWebObject->GET();
+        } else {
+            $sMessage = $aReturn['sMessage'];
+        }
+        return $sMessage;
+    }
+
+    /**
+     * @SWG\Put(path="/webobjects/{web_id}",
+     *   tags={"WebObjects"},
+     *   summary="Update WebObject",
+     *   description="Request to update web object",
+     *   operationId="PUT",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   consumes= { "multipart/form-data"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="web_id",
+     *     in="path",
+     *     description="web id",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="name",
+     *     in="query",
+     *     description="name",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="definition",
+     *     in="query",
+     *     description="definition",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/webobjects")
+     *     ),
+     * 
+     *  )
+     */
+
+    /**
+     * modify web object
+     * @return array containing the status and the message
+     */
+    function PUT() {
+        $aReturn = $this->genericPut($this->aProperties['schema_vm4ms'], 'web', 'web_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Delete(path="/webobjects/",
+     *   tags={"WebObjects"},
+     *   summary="delete WebObject",
+     *   description="Request to delete WebObject",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="idList",
+     *     in="query",
+     *     description="id of the web objects",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/webobjects")
+     *     )
+     *  )
+     */
+    /**
+     * @SWG\Delete(path="/webobjects/{web_id}",
+     *   tags={"WebObjects"},
+     *   summary="delete WebObject",
+     *   description="Request to delete WebObject",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="web_id",
+     *     in="path",
+     *     description="id of the web object",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/webobjects")
+     *     )
+     *  )
+     */
+
+    /**
+     * delete web object
+     * @return id of web object deleted or error object if a web object is not deleted
+     */
+    function DELETE() {
+        $aReturn = $this->genericDelete($this->aProperties['schema_vm4ms'], 'web', 'web_id');
+        return $aReturn['sMessage'];
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/WmsService.class.inc b/vas/rest/ws/vm4ms/WmsService.class.inc
new file mode 100755
index 00000000..329050d2
--- /dev/null
+++ b/vas/rest/ws/vm4ms/WmsService.class.inc
@@ -0,0 +1,86 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file WmsService.class.inc
+ * \class WmsService
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the WmsService php class
+ *
+ * This class defines operation for one wms service
+ * 
+ */
+class WmsService extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("wmsservice_id", "description", "definition", "web_id", "web_name");
+    }
+
+    /**
+     * @SWG\Get(path="/wmsservices/{wmsservice_id}",
+     *   tags={"WmsServices"},
+     *   summary="Get Wms Service",
+     *   description="Request to get wms service by id",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="wmsservice_id",
+     *     in="path",
+     *     description="wmsservice id",
+     *     required=true,
+     *     type="string",
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/wmsservices")
+     *     )
+     *  )
+     */
+
+    /**
+     * get informations about wms service
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        $this->aFields = $this->getFields($this->aProperties['schema_vm4ms'], 'v_wms_service', 'wmsservice_id');
+    }
+
+    /**
+     * delete a wms service
+     */
+    function DELETE() {
+        require $this->sRessourcesFile;
+        $this->oConnection->oBd->delete($this->aProperties['schema_vm4ms'], 'wmsservice', 'wmsservice_id', $this->aValues['my_vitis_id'], 'text');
+        if ($this->oConnection->oBd->enErreur()) {
+            $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+        } else {
+            $this->aFields['wmsservice_id'] = $this->aValues['my_vitis_id'];
+        }
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/WmsServiceLayer.class.inc b/vas/rest/ws/vm4ms/WmsServiceLayer.class.inc
new file mode 100755
index 00000000..4337a790
--- /dev/null
+++ b/vas/rest/ws/vm4ms/WmsServiceLayer.class.inc
@@ -0,0 +1,51 @@
+<?php
+
+require_once 'Vmap4MapServer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+
+/**
+ * \file WmsServiceLayer.class.inc
+ * \class WmsServiceLayer
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the WmsServiceLayer php class
+ *
+ * This class defines operation for one  wms service layer
+ * 
+ */
+class WmsServiceLayer extends Vmap4MapServer {
+
+    public $oError;
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layer_id", "name", "title", "active", "wmsservice_id", "opacity");
+    }
+
+    /**
+     * get informations about wms service layer
+     */
+    function GET() {
+        require $this->sRessourcesFile;
+        $this->aFields = $this->getFields($this->aProperties['schema_vm4ms'], 'v_wms_service_ms_layer', 'wmsservice_id');
+    }
+
+    /**
+     * delete a wms service layer
+     */
+    function DELETE() {
+        
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/WmsServiceLayers.class.inc b/vas/rest/ws/vm4ms/WmsServiceLayers.class.inc
new file mode 100755
index 00000000..39cb12c1
--- /dev/null
+++ b/vas/rest/ws/vm4ms/WmsServiceLayers.class.inc
@@ -0,0 +1,290 @@
+<?php
+
+/**
+ * \file WmsServiceLayers.class.inc
+ * \class WmsServiceLayers
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the WmsServiceLayers php class
+ *
+ * This class defines Rest Api to Vmap WmsServiceLayers
+ * 
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'WmsServiceLayer.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+require_once 'WmsServices.class.inc';
+
+class WmsServiceLayers extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/wmsservicelayers",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/wmsservicelayers")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="WmsServiceLayers",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("ms_layer_id", "name", "title", "active", "wmsservice_id", "opacity");
+    }
+
+    /**
+     * @SWG\Get(path="/wmsservicelayers",
+     *   tags={"WmsServiceLayers"},
+     *   summary="Get  wms service layers",
+     *   description="Request to get wms service layers",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Porperties Response",
+     *         @SWG\Schema(ref="#/definitions/wmsservicelayers")
+     *     )
+     *  )
+     */
+
+    /**
+     * get  wms service layers
+     * @return WmsServiceLayers
+     */
+    function GET() {
+        $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'v_wms_service_ms_layer', 'wmsservice_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Put(path="/wmsservicelayers",
+     *   tags={"WmsServiceLayers"},
+     *   summary="Update wms service layers",
+     *   description="Request to update the layers of a wms service",
+     *   operationId="PUT",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="wmsservice_id",
+     *     in="path",
+     *     description="Id of the wms service",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="wmsservice_ms_layers",
+     *     in="query",
+     *     description="Layers of the wms service",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Properties Response",
+     *         @SWG\Schema(ref="#/definitions/wmsservicelayers")
+     *     ),
+     * 
+     *  )
+     */
+
+    /**
+     * modify layers of wms service
+     * @return array containing the status and the message
+     */
+    function PUT() {
+        require $this->sRessourcesFile;
+        // Couches à rattacher à la carte ?
+        if (!empty($this->aValues['wmsservice_ms_layers'])) {
+            $aLayers = explode('|', $this->aValues['wmsservice_ms_layers']);
+            foreach ($aLayers as $iLayerId) {
+                $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+                $aParams['ms_layer_id'] = array('value' => $iLayerId, 'type' => 'number');
+                $aParams['wmsservice_id'] = array('value' => $this->aValues["my_vitis_id"], 'type' => 'string');
+                $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['insertWmsServiceLayers'], $aParams);
+                if ($this->oConnection->oBd->enErreur()) {
+                    $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+                    $oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+                    $aXmlRacineAttribute['status'] = 0;
+                    $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+                } else {
+                    $aXmlRacineAttribute['status'] = 1;
+                    $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+                }
+            }
+            // Création du fichier .map du flux WMS.
+            $aValues = array('token' => session_id(), 'wmsservice_id' => $this->aValues["my_vitis_id"], 'my_vitis_id' => $this->aValues["my_vitis_id"], 'type' => 'prod', 'creation' => true, 'sEncoding' => $this->aValues['sEncoding'], 'sSourceEncoding' => $this->aValues['sSourceEncoding'], 'output' => $this->aValues['output']);
+            $aPath = array('vm4ms', 'wmsservices', $this->aValues["my_vitis_id"]);
+            $oWmsServices = new WmsServices($this->aPath, $aValues, $this->aProperties, $this->oConnection);
+            $oWmsServices->GET();
+            if ($this->oConnection->oBd->enErreur()) {
+                $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+                $oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+                $aXmlRacineAttribute['status'] = 0;
+                $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+                return $sMessage;
+            }
+            $oWmsServices->createMapFile();
+        }
+        return $sMessage;
+    }
+
+    /**
+     * @SWG\Delete(path="/wmsservicelayers/{wmsservice_id}",
+     *   tags={"WmsServiceLayers"},
+     *   summary="Delete  wms service layers",
+     *   description="Request to delete layers of a wms service",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="wmsservice_id",
+     *     in="path",
+     *     description="id of the wms service",
+     *     required=true,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="idList",
+     *     in="query",
+     *     description="id of the wms service layers",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/wmsservicelayers")
+     *     )
+     *  )
+     */
+
+    /**
+     * delete wms service layers
+     * @return id of wms service layer deleted or error object if a wms service layer is not deleted
+     */
+    function DELETE() {
+        require $this->sRessourcesFile;
+        // Couches à supprimer ?
+        if (!empty($this->aValues['idList'])) {
+            $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+            $aParams['wmsservice_id'] = array('value' => $this->aValues["my_vitis_id"], 'type' => 'string');
+            $aParamsName = array();
+            foreach (explode('|', $this->aValues['idList']) as $iIndex => $iId) {
+                $sParamName = 'id_layer_' . $iIndex;
+                $aParamsName[] = ':' . $sParamName;
+                $aParams[$sParamName] = array('value' => $iId, 'type' => 'number');
+            }
+            $aSql['deleteWmsServiceLayers'] = str_replace('[idList]', implode(',', $aParamsName), $aSql['deleteWmsServiceLayers']);
+            $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['deleteWmsServiceLayers'], $aParams);
+            if ($this->oConnection->oBd->enErreur()) {
+                $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+                $oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+                $aXmlRacineAttribute['status'] = 0;
+                $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            } else {
+                $aXmlRacineAttribute['status'] = 1;
+                $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            }
+            // Création du fichier .map du flux WMS.
+            $aValues = array('token' => session_id(), 'wmsservice_id' => $this->aValues["my_vitis_id"], 'my_vitis_id' => $this->aValues["my_vitis_id"], 'type' => 'prod', 'creation' => true);
+            $aPath = array('vm4ms', 'wmsservices', $this->aValues["my_vitis_id"]);
+            $oWmsServices = new WmsServices($this->aPath, $aValues, $this->aProperties, $this->oConnection);
+            $oWmsServices->GET();
+            if ($this->oConnection->oBd->enErreur()) {
+                $this->oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+                $oError = new VitisError(1, $this->oConnection->oBd->getBDMessage());
+                $aXmlRacineAttribute['status'] = 0;
+                $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+                return $sMessage;
+            }
+            $oWmsServices->createMapFile();
+        }
+        return $sMessage;
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/vas/rest/ws/vm4ms/WmsServices.class.inc b/vas/rest/ws/vm4ms/WmsServices.class.inc
new file mode 100755
index 00000000..67a9da19
--- /dev/null
+++ b/vas/rest/ws/vm4ms/WmsServices.class.inc
@@ -0,0 +1,576 @@
+<?php
+
+/**
+ * \file WmsServices.class.inc
+ * \class WmsServices
+ *
+ * \author Armand Bahi <armand.bahi@veremes.com>.
+ *
+ * \brief This file contains the WmsServices php class
+ *
+ * This class defines Rest Api to Vmap4MapServer WmsServices
+ *
+ */
+require_once 'Vmap4MapServer.class.inc';
+require_once 'WmsService.class.inc';
+require_once __DIR__ . '/../../class/vitis_lib/Connection.class.inc';
+require_once __DIR__ . '/../../class/vmlib/BdDataAccess.inc';
+require_once 'Vm4msMetadataAccess.class.inc';
+
+class WmsServices extends Vmap4MapServer {
+    /**
+     * @SWG\Definition(
+     *   definition="/wmsservices",
+     *   allOf={
+     *     @SWG\Schema(ref="#/definitions/wmsservices")
+     *   }
+     * )
+     * * @SWG\Tag(
+     *   name="WmsServices",
+     *   description=""
+     * )
+     */
+
+    /**
+     * construct
+     * @param type $aPath url of the request
+     * @param type $aValues parameters of the request
+     * @param type $properties properties
+     * @param type $bShortcut false to reinit variables
+     * @param type $oConnection connection object
+     */
+    function __construct($aPath, $aValues, $properties, $bShortcut = false, $oConnection = false) {
+        parent::__construct($aPath, $aValues, $properties, $bShortcut, $oConnection);
+        $this->aSelectedFields = Array("wmsservice_id", "description", "definition", "web_id", "web_name");
+    }
+
+    /**
+     * @SWG\Get(path="/wmsservices",
+     *   tags={"WmsServices"},
+     *   summary="Get Wms Services",
+     *   description="Request to get Wms Services",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="order_by",
+     *     in="query",
+     *     description="list of ordering fields",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="sort_order",
+     *     in="query",
+     *     description="sort order",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="limit",
+     *     in="query",
+     *     description="number of element",
+     *     required=false,
+     *     type="integer",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="offset",
+     *     in="query",
+     *     description="index of first element",
+     *     required=false,
+     *     type="string",
+     *     format="int32"
+     *   ),
+     * @SWG\Parameter(
+     *     name="attributs",
+     *     in="query",
+     *     description="list of attributs",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="filter",
+     *     in="query",
+     *     description="filter results",
+     *     required=false,
+     *     type="string"
+     *   ),
+     * @SWG\Parameter(
+     *     name="distinct",
+     *     in="query",
+     *     description="delete duplicates",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/wmsservices")
+     *     )
+     *  )
+     */
+    /**
+     * @SWG\Get(path="/wmsservices/{wmsservice_id}/MapFile",
+     *   tags={"WmsServices"},
+     *   summary="Get wms service map file",
+     *   description="Request to get the map file of a wms service by id",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="wmsservice_id",
+     *     in="path",
+     *     description="wmsservice_id",
+     *     required=true,
+     *     type="string",
+     *   ),
+     *  @SWG\Parameter(
+     *     name="type",
+     *     in="query",
+     *     description="Type of map file",
+     *     required=true,
+     *     type="array",
+     *         @SWG\Items(type="string"),
+     *         collectionFormat="multi",
+     *         default="prod",
+     *         enum={"prod", "test"}
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/wmsservices")
+     *     )
+     *  )
+     */
+    /**
+     * @SWG\Get(path="/wmsservices/{wmsservice_id}/MapServerLog",
+     *   tags={"WmsServices"},
+     *   summary="Get mapserver log of wms service test",
+     *   description="Request to get the content of the mapserver log for the test of the wms service",
+     *   operationId="GET",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="wmsservice_id",
+     *     in="path",
+     *     description="wmsservice_id",
+     *     required=true,
+     *     type="string",
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/wmsservices")
+     *     )
+     *  )
+     */
+
+    /**
+     * get WmsServices
+     * @return  WmsServices
+     */
+    function GET() {
+        if (in_array('vm4ms_admin', $this->oConnection->aPrivileges)) {
+            $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'v_wms_service', 'wmsservice_id');
+            $sMessage = $aReturn['sMessage'];
+        }
+        if (!empty($this->aPath[3])) {
+            if ($this->aPath[3] == "MapFile")
+                $sMessage = $this->getMapFile();
+            else if ($this->aPath[3] == "MapServerLog")
+                $sMessage = $this->getMapServerLog();
+        }
+        return $sMessage;
+    }
+
+    /**
+     * Création d'un fichier ".map" pour le flux wms avec MapServer.
+     */
+    function createMapFile() {
+        require $this->sRessourcesFile;
+        //$oBd = $this->oConnection->oBd;
+        // Login et mdp.
+        $oBd = new BD($this->aProperties["owner_login"], $this->aProperties["owner_pass"], $this->aProperties["database"], $this->aProperties["server"], $this->aProperties["port"], $this->aProperties["sgbd"], $this->aProperties["page_encoding"]);
+        if ($oBd->erreurRencontree) {
+            $oError = new VitisError(1, $oBd->sMessage);
+            $aXmlRacineAttribute['status'] = 0;
+            $sMessage = $oError->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+            $bXMLError = true;
+            writeToErrorLog('Error: ' . $oBd->sMessage . ' -> ' . __FUNCTION__ . '(' . $this->aValues['my_vitis_id'] . ')' . ' in ' . __FILE__ . ' on line ' . __LINE__);
+        } else {
+            $sLogin = '';
+            $sPassword = '';
+            if (!empty($this->aValues['user_login']) && !empty($this->aValues['user_password'])) {
+                $sLogin = $this->aValues['user_login'];
+                $sPassword = $this->aValues['user_password'];
+            }
+            // Création du fichier ".map".
+            $oVm4msMetadataAccess = new Vm4msMetadataAccess($oBd, $sLogin, $sPassword, session_id(), $this->aProperties);
+            if ($this->aValues['type'] == 'prod')
+                $sMapFile = $oVm4msMetadataAccess->saveWmsServiceMapFile($this->aValues['my_vitis_id'], $this->aValues['token']);
+            else
+                $sMapFile = $oVm4msMetadataAccess->saveWmsServiceTestMapFile($this->aValues['my_vitis_id']);
+        }
+    }
+
+    /**
+     * Retourne les infos du fichier ".map" du flux.
+     */
+    function getMapFile() {
+        if (!empty($this->aObjects[0]->aFields)) {
+            require $this->sRessourcesFile;
+            $sWmsServiceId = $this->aObjects[0]->aFields['wmsservice_id'];
+            // Supprime les accents et caractères spéciaux.
+            $sWmsServiceId = htmlentities($sWmsServiceId, ENT_NOQUOTES, 'UTF-8');
+            $sWmsServiceId = preg_replace('#&([A-za-z])(?:acute|cedil|caron|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $sWmsServiceId);
+            $sWmsServiceId = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $sWmsServiceId); // pour les ligatures e.g. '&oelig;'
+            $sWmsServiceId = preg_replace('#&[^;]+;#', '', $sWmsServiceId); // supprime les autres caractères
+            // Nom du fichier ".map".
+            $sMapFileHash = hash('sha256', $this->aValues['token']);
+            $this->aObjects[0]->aFields['map_file_hash'] = $sMapFileHash;
+            if ($this->aValues['my_vitis_id'] == $this->aProperties['private_wms_service']) {
+                $sProdDir = 'wms_private';
+                $sMapFileName = $sMapFileHash . '.map';
+            } else {
+                $sProdDir = 'wms_public';
+                $sMapFileName = $sMapFileHash . '_' . $sWmsServiceId . '.map';
+            }
+            // Chemin du fichier.
+            if ($this->aValues['type'] == 'prod')
+                $this->aObjects[0]->aFields['map_file'] = $this->aProperties["map_dir"] . '/' . $sProdDir . '/' . $sMapFileName;
+            else
+                $this->aObjects[0]->aFields['map_file'] = $this->aProperties["map_dir"] . '/wms_test/' . $sMapFileName;
+            // Contenu du fichier ".map".
+            if (file_exists($this->aObjects[0]->aFields['map_file']))
+                $this->aObjects[0]->aFields['map_file_content'] = file_get_contents($this->aObjects[0]->aFields['map_file']);
+            // Source des couches du flux de test.
+            $aParams['sSchemaVm4ms'] = array('value' => $this->aProperties['schema_vm4ms'], 'type' => 'schema_name');
+            $aParams['wmsservice_id'] = array('value' => $sWmsServiceId, 'type' => 'string');
+            $oPDOresult = $this->oConnection->oBd->executeWithParams($aSql['getWmsServiceLayersSource'], $aParams);
+            if (!$this->oConnection->oBd->erreurRencontree) {
+                $aLayersSource = array();
+                while ($aLayer = $this->oConnection->oBd->ligneSuivante($oPDOresult))
+                    $aLayersSource[$aLayer['name']] = $aLayer['source'];
+                $this->aObjects[0]->aFields['layers_sources'] = $aLayersSource;
+            }
+        }
+        $aXmlRacineAttribute['status'] = 1;
+        if (isset($this->aValues['sEncoding'])) {
+            $sEncoding = $this->aValues['sEncoding'];
+        } else {
+            $sEncoding = null;
+        }if (isset($this->aValues['sSourceEncoding'])) {
+            $sSourceEncoding = $this->aValues['sSourceEncoding'];
+        } else {
+            $sSourceEncoding = null;
+        }if (isset($this->aValues['output'])) {
+            $output = $this->aValues['output'];
+        } else {
+            $output = null;
+        }
+        $sMessage = $this->asDocument('', 'vitis', $sEncoding, True, $aXmlRacineAttribute, $sSourceEncoding, $output);
+        return $sMessage;
+    }
+
+    /**
+     * Retourne le contenu du fichier de log de MapServer pour le test du flux WMS.
+     */
+    function getMapServerLog() {
+        if ($this->aObjects[0]->aFields['wmsservice_id'] == $this->aProperties['private_wms_service'])
+            $sMsLogFile = $this->aProperties['ms_log_dir'] . '/test/' . hash('sha256', session_id()) . '.log';
+        else
+            $sMsLogFile = $this->aProperties['ms_log_dir'] . '/test/' . hash('sha256', session_id()) . '_' . $this->aObjects[0]->aFields['wmsservice_id'] . '.log';
+        if (file_exists($sMsLogFile))
+            $this->aObjects[0]->aFields['log_file_content'] = utf8_encode(file_get_contents($sMsLogFile));
+        $aXmlRacineAttribute['status'] = 1;
+        if (isset($this->aValues['sEncoding'])) {
+            $sEncoding = $this->aValues['sEncoding'];
+        } else {
+            $sEncoding = null;
+        }if (isset($this->aValues['sSourceEncoding'])) {
+            $sSourceEncoding = $this->aValues['sSourceEncoding'];
+        } else {
+            $sSourceEncoding = null;
+        }if (isset($this->aValues['output'])) {
+            $output = $this->aValues['output'];
+        } else {
+            $output = null;
+        }
+        $sMessage = $this->asDocument('', 'vitis', $sEncoding, True, $aXmlRacineAttribute, $sSourceEncoding, $output);
+        return $sMessage;
+    }
+
+    /**
+     * @SWG\Post(path="/wmsservices",
+     *   tags={"WmsServices"},
+     *   summary="Add wms service",
+     *   description="Request to add a wms service",
+     *   operationId="POST",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="formData",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="wmsservice_id",
+     *     in="formData",
+     *     description="wms service id",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="description",
+     *     in="formData",
+     *     description="description",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="definition",
+     *     in="formData",
+     *     description="definition",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="web_id",
+     *     in="formData",
+     *     description="web object id",
+     *     required=false,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/wmsservices")
+     *   )
+     *  )
+     * )
+     */
+    /**
+     * @SWG\Post(path="/wmsservices/MapFile",
+     *   tags={"WmsServices"},
+     *   summary="Create wms service map file",
+     *   description="Request to create the map file of a wms service by id",
+     *   operationId="POST",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="wmsservice_id",
+     *     in="formData",
+     *     description="wmsservice_id",
+     *     required=true,
+     *     type="string",
+     *   ),
+     *  @SWG\Parameter(
+     *     name="type",
+     *     in="query",
+     *     description="Type of map file",
+     *     required=true,
+     *     type="array",
+     *         @SWG\Items(type="string"),
+     *         collectionFormat="multi",
+     *         default="prod",
+     *         enum={"prod", "test"}
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/wmsservices")
+     *     )
+     *  )
+     */
+
+    /**
+     * insert wms service
+     * @return array containing the status and the message
+     */
+    function POST() {
+        // Création d'un flux WMS ou d'un fichier ".map".
+        if (!empty($this->aPath[2])) {
+            if ($this->aPath[2] == "MapFile") {
+                $this->aValues['my_vitis_id'] = $this->aValues['wmsservice_id'];
+                $aReturn['sStatus'] = 1;
+                if (in_array('vm4ms_admin', $this->oConnection->aPrivileges)) {
+                    $aReturn = $this->genericGet($this->aProperties['schema_vm4ms'], 'v_wms_service', 'wmsservice_id');
+                    $sMessage = $aReturn['sMessage'];
+                }
+                if ($aReturn['sStatus'] == 1) {
+                    $this->createMapFile();
+                    $sMessage = $this->getMapFile();
+                }
+            }
+        } else {
+            $aReturn = $this->genericPost($this->aProperties['schema_vm4ms'], 'wmsservice', false, 'wmsservice_id');
+            if ($aReturn['sStatus'] == 1) {
+                $aXmlRacineAttribute['status'] = 1;
+                $sMessage = $this->asDocument('', 'vitis', $this->aValues['sEncoding'], True, $aXmlRacineAttribute, $this->aValues['sSourceEncoding'], $this->aValues['output']);
+                $oWmsService = new WmsService($this->aPath, $this->aValues, $this->aProperties, $this->oConnection);
+                $oWmsService->GET();
+            } else {
+                $sMessage = $aReturn['sMessage'];
+            }
+        }
+        return $sMessage;
+    }
+
+    /**
+     * @SWG\Put(path="/wmsservices/{wmsservice_id}",
+     *   tags={"WmsServices"},
+     *   summary="Update WmsService",
+     *   description="Request to update wms service",
+     *   operationId="PUT",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   consumes= { "multipart/form-data"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="wmsservice_id",
+     *     in="path",
+     *     description="wms service id",
+     *     required=true,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="description",
+     *     in="query",
+     *     description="description",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="definition",
+     *     in="query",
+     *     description="definition",
+     *     required=false,
+     *     type="string"
+     *   ),
+     *   @SWG\Parameter(
+     *     name="web_id",
+     *     in="query",
+     *     description="web object id",
+     *     required=false,
+     *     type="integer",
+     *     format = "int32"
+     *   ),
+     *   @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/wmsservices")
+     *     ),
+     *
+     *  )
+     */
+
+    /**
+     * modify wms service
+     * @return array containing the status and the message
+     */
+    function PUT() {
+        $aReturn = $this->genericPut($this->aProperties['schema_vm4ms'], 'wmsservice', 'wmsservice_id');
+        return $aReturn['sMessage'];
+    }
+
+    /**
+     * @SWG\Delete(path="/wmsservices/",
+     *   tags={"WmsServices"},
+     *   summary="delete WmsService",
+     *   description="Request to delete WmsService",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="idList",
+     *     in="query",
+     *     description="id of the wms services",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/wmsservices")
+     *     )
+     *  )
+     */
+    /**
+     * @SWG\Delete(path="/wmsservices/{wmsservice_id}",
+     *   tags={"WmsServices"},
+     *   summary="delete WmsService",
+     *   description="Request to delete WmsService",
+     *   operationId="DELETE",
+     *   produces={"application/xml", "application/json", "application/x-vm-json"},
+     *   @SWG\Parameter(
+     *     name="token",
+     *     in="query",
+     *     description="user token",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * * @SWG\Parameter(
+     *     name="wmsservice_id",
+     *     in="path",
+     *     description="id of the wms service",
+     *     required=true,
+     *     type="string"
+     *   ),
+     * @SWG\Response(
+     *         response=200,
+     *         description="Poprerties Response",
+     *         @SWG\Schema(ref="#/definitions/wmsservices")
+     *     )
+     *  )
+     */
+
+    /**
+     * delete wms service
+     * @return id of wms service deleted or error object if a wms service is not deleted
+     */
+    function DELETE() {
+        $aReturn = $this->genericDelete($this->aProperties['schema_vm4ms'], 'wmsservice', 'wmsservice_id');
+        return $aReturn['sMessage'];
+    }
+
+}
+
+?>
diff --git a/vas/rest/ws/vm4ms/overview.phtml b/vas/rest/ws/vm4ms/overview.phtml
new file mode 100755
index 00000000..69502a5f
--- /dev/null
+++ b/vas/rest/ws/vm4ms/overview.phtml
@@ -0,0 +1,24 @@
+<?php
+/**
+ * @SWG\Swagger(
+ *      basePath="/[service_alias]/vm4ms",
+ *     	host="[server]",
+ *    	schemes={"[protocol]"},
+ *     	produces={  
+ *          "application/json",
+            "application/xml",
+            "text/html"
+ * 		},
+ *     @SWG\Info(
+ *         version="1.0.0",
+ *         title="vMap4MapServer Test Rest",
+ *         description="All features to access server operation for vMap4MapServer",
+ *     )
+ * )
+ */
+?>
+
+<h1 class="titleOverview">Service vMap4MapServer</h1>
+<p>
+	<a class="linkOverview" href="javascript:sService='vm4ms';LoadApi()">vMap4MapServer :</a> this is the most comprehensive service which should be used as a preference when developing applications communicating with vMap4MapServer. Those services allow you to administrate vMap4MapServer applications.
+</p>
\ No newline at end of file
-- 
GitLab