Step 1 – Create your Application Workspace – base it on the Generic Application template:



From the Jersey download documentation page this requires you to download 3 files:
jersey-server.jar
jersey-core.jar
asm.jar
Alternatively you can use the Jersey bundle, implying you need to download:
jersey-bundle.jar
asm.jar
We'll assume you've downloaded the 3 JARs for the rest of this blog.
Step 3 – locate the JDev Application Workspace on the filesystem, create a subdirectory "lib" and copy the 3 downloaded JARs into this directory:


public class MySimplePojo {Step 6 – add the @Path annotation to the class and add the appropriate import:
public String helloRESTWebServices() {
return "helloRESTWebServices";
}
}
import javax.ws.rs.Path;Step 7 – Note the orange squiggly line under the @Path annotation. Click on the Path keyword, then select the light globe in the left margin. It will show the option "Configure web.xml for Jersey JAX-RS web services" which when selected will configure the project correctly to run the web service once deployed:
@Path("myRESTWebService")
public class MySimplePojo {
public String helloRESTWebServices() {
return "helloRESTWebServices";
}
}


import javax.ws.rs.GET;Step 9 – Save all
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@Path("myRESTWebService")
public class MySimplePojo {
@GET
@Produces("plain/text")
public String helloRESTWebServices() {
return "helloRESTWebServices";
}
}
Step 10 – Right click the POJO in the Application Navigator and select Test Web Service:


In all seriousness step 9 wasn't even much of a step, but "Express REST Web Services in Oracle's JDeveloper in 9 easy steps" doesn't have much of a ring to it.
With Thanks
With my thanks to Gerard Davison for his assistance on sorting out the library details for this post.
2 comments:
Great post ... Indeed its very easy :)
Thanks a lot
superb :)
Post a Comment