RESTFul Java Consumer Producer Example

RESTFul Java Consumer Producer Example

In this example you will see how to create simple RESTFul service which will produce data and also create consumer which will consume data from exposed service:

  • Project structure:

RESTFul Java Consumer Producer Example

  • pom.xml:

  • web.xml:

  • Model class: Student.java:

  • Service class: StudentService.java:

To run this service you can use any server. I used tomcat server and to run right click StudentService.java –> Run on server (If you server set up done in eclipse)

  • Test get method call: TestGetCall.java:

  • Test post call: TestPostCall.java:

Sample RESTFul consumer example which will consume date from outside:

  • CrunchTest.java:

  • Sample consumer if you wanted to consumer service behind the firewall proxy.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *