Hi All, I am accessing an unprotected WFS in a Grails project from
OpenLayers with goovy HTTPBuilder. It works as expected, but it seems
every time sending a WFS request to Geoserver JSESSIONID has to be
provided. And here comes my problem: To obtain a JSESSIONID I have to
send a request to a resource which requires authentication first (chose
'geoserver/rest'). Works - if the username and password are known. Does
anybody know a better way to get a JSESSIONID?
For all who are interested in the code:
def http = new HTTPBuilder("http://127.0.0.1:8080")
//accessing REST-Service to obtain JSESSIONID
http.auth.basic 'admin','geoserver'
http.get(path: '/geoserver/rest')
//building and sending the WFS-Request
http.headers.'Content-Type'="application/xml; charset=UTF-8"
http.headers.'Accept-Encoding'= 'gzip,deflate'
http.headers.'Cookie'="JSESSIONID=${
http.client.cookieStore.cookies.grep{it.name=='JSESSIONID'}.value[0]}"
String xmlString = new StreamingMarkupBuilder().bind(){mkp.yield
request.XML}
def wfsResponse = http.post(path:'/geoserver/wfs',body:xmlString)
//dealing with response
def featureCollection = new StreamingMarkupBuilder().bind(){mkp.yield
wfsResponse}
render featureCollection.toString()
Regards
Sven
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users