Geoportal.de MOBAC mapsource help needed

Started by Trullo Fetzer, November 12, 2013, 14:08:13

0 Members and 1 Guest are viewing this topic.

Trullo Fetzer

Hello to all Beanshell wizards.
I have the following problem. I try to access the German Geoportal with MOBAC, but that server is issuing 2 cookies. One for JSESSIONID and one for PHPSESSID. With the code below I only get the first cookie (JSESSIONID) successfully. I found some java code examples for storing cookies, but I don't know how to integrate this into the script. Any help would be appreciated. There are different approaches to get cookie values which I tried, but all of them only get the first cookie. Tahnks in advance.

name = "Geoportal DE";

tileType = "png"; // required; valid values: "jpg" "png" or "gif"

// Default size of each tile is 256x256 pixel
tileSize = 256; // optional
minZoom = 7;    // optional
maxZoom = 15;   // optional
//tileUpdate = TileUpdate.IfModifiedSince; // optional

//get authentication cookie

URL url = new URL("http://www.geoportal.de/DE/Geoportal/geoportal.html?lang=de");
httpConn = url.openConnection();
authHeader = httpConn.getHeaderField("Set-Cookie");
auth = authHeader.split(";")[0];

/**
This method is called for each tile: input parameters for this script: "zoom", "x" and "y"
**/
String getTileUrl( int zoom, int x, int y ) {
return "http://www.geoportal.de/viewer/proxy/open?url=http://arcgis.lpz.web/arcgis/rest/services/webatlasde/MapServer/WMTS/tile/1.0.0/webatlasde/default/nativeTileMatrixSet/"+zoom+"/"+x+"/"+y+".png";
}

/**
This method is called also for each tile (implementation optional)
It allows to set HTTP headers like "Referer" or cookies the server
wants to see.
**/
void addHeaders( java.net.HttpURLConnection conn) {
  conn.addRequestProperty("Cookie",auth);
  conn.addRequestProperty("Referer","http://www.geoportal.de/DE/Geoportal/geoportal.html?lang=de");
  conn.addRequestProperty("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0) Gecko/20100101 Firefox/4.0 Opera 12.16");
}
  •