|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Geoserver, Groovy and REST adviceHi,
I've made a few posts along these lines recently and now I've come to a new problem. I'm trying to create a REST client for configuring GeoServer using Groovy. Unfortunately I'm quite new to Groovy so that might be why I'm having trouble. I've got a createWorkspace method as follows:
def createWorkspace(def wsName, def geoserverUrl, def user, def pass){ // setup the restclient def rest = new RESTClient(geoserverUrl)
// do the authing rest.auth.basic user, pass // post it
def res = rest.post( path: "geoserver/rest/workspaces", requestContentType: XML,
body: "<workspace><name>${wsName}</name></workspace>" )
} This actually works in that it creates a workspace in geoserver, but it also throws up a number of exceptions because it fails to parse the result (shown below). I'm not wondering - is this GeoServers fault or is it a problem with my code? Has anybody had any experience with this?
Cheers, Jon Stack Trace: 04-Nov-2009 15:54:53 groovyx.net.http.ParserRegistry getContentType WARNING: Could not parse content-type header in response
java.lang.NullPointerException at groovyx.net.http.ParserRegistry.getContentType(ParserRegistry.java:153) at groovyx.net.http.HTTPBuilder.parseResponse(HTTPBuilder.java:510)
at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:460) at groovyx.net.http.RESTClient.post(RESTClient.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) at com.example.jon.GroovyTest.createWorkspace(GroovyTest.groovy:41)
at com.example.jon.GroovyTest$createWorkspace.callCurrent(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:163)
at com.example.jon.GroovyTest.run(GroovyTest.groovy:47) at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:256)
at groovy.lang.GroovyShell.run(GroovyShell.java:219) at groovy.lang.GroovyShell.run(GroovyShell.java:149)
at groovy.ui.GroovyMain.processOnce(GroovyMain.java:494) at groovy.ui.GroovyMain.run(GroovyMain.java:309)
at groovy.ui.GroovyMain.process(GroovyMain.java:295) at groovy.ui.GroovyMain.processArgs(GroovyMain.java:112)
at groovy.ui.GroovyMain.main(GroovyMain.java:93) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:108)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130) 04-Nov-2009 15:54:53 groovyx.net.http.HTTPBuilder doRequest WARNING: Error parsing 'null' response
java.lang.IllegalArgumentException: Could not parse content-type from response at groovyx.net.http.ParserRegistry.getContentType(ParserRegistry.java:157)
at groovyx.net.http.HTTPBuilder.parseResponse(HTTPBuilder.java:510) at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:460)
at groovyx.net.http.RESTClient.post(RESTClient.java:140) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source) at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at com.example.jon.GroovyTest.createWorkspace(GroovyTest.groovy:41) at com.example.jon.GroovyTest$createWorkspace.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:163) at com.example.jon.GroovyTest.run(GroovyTest.groovy:47)
at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:256) at groovy.lang.GroovyShell.run(GroovyShell.java:219)
at groovy.lang.GroovyShell.run(GroovyShell.java:149) at groovy.ui.GroovyMain.processOnce(GroovyMain.java:494)
at groovy.ui.GroovyMain.run(GroovyMain.java:309) at groovy.ui.GroovyMain.process(GroovyMain.java:295)
at groovy.ui.GroovyMain.processArgs(GroovyMain.java:112) at groovy.ui.GroovyMain.main(GroovyMain.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:108) at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Geoserver-users mailing list Geoserver-users@... https://lists.sourceforge.net/lists/listinfo/geoserver-users |
|
|
Re: Geoserver, Groovy and REST adviceHi,Well, the response to a request like that doesn't have a body or a content-type. Here's a sample session including response headers: $ curl -d'<workspace><name>dwins</name></workspace>' -H'Content-type: text/xml' http://admin:geoserver@localhost:8080/geoserver/rest/workspaces -D - HTTP/1.1 201 Created Date: Wed, 04 Nov 2009 16:19:11 GMT Location: http://localhost:8080/geoserver/rest/workspaces/dwins Server: Noelios-Restlet-Engine/1.0..8 Transfer-Encoding: chunked Does HTTPBuilder have some flag you can set to automatically follow redirects, and/or directly access the response rather than automatically parsing the result? -- David Winslow OpenGeo - http://opengeo.org/ ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Geoserver-users mailing list Geoserver-users@... https://lists.sourceforge.net/lists/listinfo/geoserver-users |
|
|
Re: Geoserver, Groovy and REST adviceHi, On 4 Nov 2009 16:19, "David Winslow" <dwinslow@...> wrote: On 11/04/2009 10:58 AM, Jon Britton wrote: Well, the response to a request like that doesn't have a body or a content-type. Here's a sample session including response headers: $ curl -d'<workspace><name>dwins</name></workspace>' -H'Content-type: text/xml' http://admin:geoserver@localhost:8080/geoserver/rest/workspaces -D - HTTP/1.1 201 Created Date: Wed, 04 Nov 2009 16:19:11 GMT Location: http://localhost:8080/geoserver/rest/workspaces/dwins Server: Noelios-Restlet-Engine/1.0..8 Transfer-Encoding: chunked Does HTTPBuilder have some flag you can set to automatically follow redirects, and/or directly access the response rather than automatically parsing the result? -- David Winslow OpenGeo - http://opengeo.org/ ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Geoserver-users mailing list Geoserver-users@... https://lists.sourceforge.net/lists/listinfo/geoserver-users |
|
|
Re: Geoserver, Groovy and REST advice
On 11/05/2009 03:36 AM, Jon Britton wrote:
Perhaps the REST API could accommodate clients like this one by adding some dummy content-type (text/plain?) to empty responses. I'll bring it up on the dev list. -- David Winslow OpenGeo - http://opengeo.org/ ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Geoserver-users mailing list Geoserver-users@... https://lists.sourceforge.net/lists/listinfo/geoserver-users |
|
|
Re: Geoserver, Groovy and REST adviceHi,
Just thought you might be interested in what's been going on with the Groovy people on this issue. It seems to me that this is all GeoServers fault for not returning a content-type header. There seem to be some debate on whether this is required by the REST spec?
Jon
2009/11/5 David Winslow <dwinslow@...>
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Geoserver-users mailing list Geoserver-users@... https://lists.sourceforge.net/lists/listinfo/geoserver-users |
| Free embeddable forum powered by Nabble | Forum Help |