Grails 2.3.0 RESTful Webservice... how do I expose?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails 2.3.0 RESTful Webservice... how do I expose?

webmediauk
Hey Guys,
So I have my app running nicely and it's very simple right now.
Before I move on I wanted to see how easy it was to open the app up as a RESTful web service and read the docs. As far as I can see I only need to do the following:

1) import grails.rest.* at the top of my domain class
2) @Resource(uri='/MYMODEL') add that annotation to my domain class
3) Restart and browse to /MYMODEL and I should get a list of models back in an xml format right?

At present I'm getting 404 errors for all the domain classes I'm trying this on.
Am I missing something vital?
Many Thanks
Barry
Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.3.0 RESTful Webservice... how do I expose?

Robert McIntosh
Mine looks like:

@Resource(uri='/api/customers', formats=['json', 'xml'])

I am not sure if the formats is required or not though. and uri shouldn't matter, but might cause issues if it is the same as another url mapping, like a controller, which is why I intentionally prefixed mine.

a simple 'get' call should invoke the equivalent of domin.list()



On Tue, Sep 17, 2013 at 9:19 AM, webmediauk <[hidden email]> wrote:
Hey Guys,
So I have my app running nicely and it's very simple right now.
Before I move on I wanted to see how easy it was to open the app up as a
RESTful web service and read the docs. As far as I can see I only need to do
the following:

1) import grails.rest.* at the top of my domain class
2) @Resource(uri='/MYMODEL') add that annotation to my domain class
3) Restart and browse to /MYMODEL and I should get a list of models back in
an xml format right?

At present I'm getting 404 errors for all the domain classes I'm trying this
on.
Am I missing something vital?
Many Thanks
Barry



--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-2-3-0-RESTful-Webservice-how-do-I-expose-tp4649252.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.3.0 RESTful Webservice... how do I expose?

webmediauk
Thanks for the reply Robert,
I've tried setting mine up just like yours and it still doesn't do anything?
I don't see any routing errors just a 404 from tomcat?
Any ideas?
Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.3.0 RESTful Webservice... how do I expose?

sukrit007
Have you specified the context parh of the application in your url

http://localhost:8080/[your-app-context-path]/MYMODEL

Also could you attach the application ? I can see if you are missing anything.