I have a Java Webapplication using jersey rest which gets deployed on a local tomcat server. This application is developed and tested within eclipse IDE.
Now in aptana IDE I have a AngularJS webapp which should connecct (using REST) to the jersey webapplication.
What steps do I have to make to establish the connection? Out of the box its not running because of the different contexts.
My current angularJS call:
WinesApp.factory('Wine', function ($resource) {
return $resource('/WinesApp/rest/wines/:wineId', {}, {
update: {method:'PUT'},
query: {method:'GET', isArray:false}
});
});
Which should become somethign like:
WinesApp.factory('Wine', function ($resource) {
return $resource('http://localhost:port/WinesApp/rest/wines/:wineId', {port:':8080'}, {
update: {method:'PUT'},
query: {method:'GET', isArray:false}
});
});
Greets Marc
For CORS to work you need to send the appropriate headers from the server: for Jersey, see for exmaple Java/Jersey: A CORS-Compliant REST API. Then you simply call it from JavaScript like you wrote (while not strictly RESTful, it's easier to restrict your API to use GET and POST requests only, no PUT and DELETE). Finally, the curl command line utility comes in handy to test the server.