Thursday, May 7, 2015

Create Restful Web Service In JDeveloper 11g

You can easy create Restful web service in JDeveloper 12c because it become built in.

But in JDdeveloper 11g  you can easy create JAX WS because it is built in, but Restful WS not built in JDev 11g so, if you want to create Restful WS in JDev 11g follow this steps:

I used JDeveloper (11.1.2.4.0) for this sample application

1- From Jdveloper create new custom application (e.g RestfulApplication).
2- In the Project ---> Properties -- Libraries And Classpath ---> Add JAR/Directory andd add those jars (you can get those jars from the attached application):

- asm-3.1.jar
- jersey-core-1.18.jar
- jersey-server-1.18.jar
- jersey-servlet-1.18.jar


3- Create new class (e.g RestClass.java) and add a simple function (sayHello) will take String and return the "Hello: ".



4- Over class name add this notation @Path("hello")
5- Over the sayHello method add this notation  @GET
6- Before function parameter add this notation @Encoded @QueryParam("myName") 



8- You will find a warning icon in the @Path notation select it then select "Configure web.xml for jersey JAX-RS Web Service"




9- The Warning will gone and a new web.xml file will created.



10- Right click on the web service --> Test Web Service.


11- Result:




You can download the sample application (JDeveloper 11.1.2.4.0) from this URL:



If you want to know how to call this web service programmatically you can check this post



5 comments: