Wednesday, July 20, 2011

Geoserver : Implementing a RESTful Service

I was following this tutorial
http://docs.geoserver.org/stable/en/developer/programming-guide/rest-ser...

to add a rest service endpoint to geoserver 2.1.1 and hit a few snags:
1. must modify restconfig applicationContext.xml
and
add the "hello" bean
and
routes mapping
(by "modify" i mean re-build the module, and the web/app module)

2. "txt" extension does not map to any MediaType, hence if we try
http://localhost:8080/geoserver/rest/hello.txt
we will get HTTP Error 500.

3. therefore we use hello.json, so we have to add
formats.add(new StringFormat( MediaType.APPLICATION_JSON ));
into HelloResource.java

4. we can go to
http://localhost:8080/geoserver/rest/hello.json
and now can successfully get the json file