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

1 comment:

  1. Hi,

    Do you need to build geoserver from source code to use/add a rest endpoint, or is there a precompiled version around? I am hearing 'rest is built in to geoserver 2.1.1', but I cannot for the life of me figure out how to use it! I don't have a /rest/ either. Would you be able to share some knowledge? Cheers, Tom tagiles@gmail.com

    ReplyDelete