//$wmcDocSession = Mapbender::session()->get("mb_wmc");
$wmcDocSession = false;
if (Mapbender::session()->get("mb_wmc")) {
    $wmc_filename = Mapbender::session()->get("mb_wmc");
    $wmcDocSession = file_get_contents($wmc_filename);
}
try {
    $loadFromSession = new ElementVar($app, "loadwmc", "loadFromSession");
    if ($wmcDocSession && $loadFromSession->value === "1") {
        //check if session contains a wmc,
        //otherwise create a new wmc from application
        $e = new mb_notice("trying to load session WMC...");
        if (!$wmc->createFromXml($wmcDocSession)) {
            $e = new mb_notice("loading session WMC failed.");
            $e = new mb_notice("creating wmc from app: " . $app);
            $wmc->createFromApplication($app);
        }
    } else {
        $e = new mb_notice("loading from session WMC disabled in loadwmc or no session WMC set.");
        $e = new mb_notice("creating wmc from app: " . $app);
        $wmc->createFromApplication($app);
    }
} catch (Exception $e) {
    $e = new mb_notice("creating wmc from app: " . $app);
    $wmc->createFromApplication($app);
}
//
// create new WMC with services from GET API
//
$wmcGetApi = WmcFactory::createFromXml($wmc->toXml());
$options = array();