Tuesday, May 4, 2010

Create Java WebService using JDeveloper 10g

The Sample WebService will return Credit Rating of the customer if the customer Id is Valid else it will give response as Invalid Customer Id

1) Open JDeveloper, Create New Application and Project as shown below

2) Create a Java Class, Right Click on Project->New->General->JavaClass

4) Enter Class Name as CreditRating and Package name as com.ws

5) Write a Method called getCreditRating inside the class CreditRating class. the method should accept customer id and return a CreditRating of the customer.

6) Compile your Project, After Successful Compilation, Right Click your Project->Business Tier-> Web Services-> Java Web Service

7) Click OK, Select J2ee 1.4 (JAX-RPC) Web Service and click OK

8) You will be prompted to welcome page of Creating Java WebService Wizard, Click Next

9) In Step1, Enter WebService Name and Select the CreditRating Class as Component to Publish and click Next

10) Click Next, In Step 5 Select the Checkbox of getCreditRating Method in the List of Availbale Methods.

11) Click Finish to generate Java Web Service, Make Sure no errors will occur this time.

Once You Successfully generate the Java Web Service, You need to deploy it and Test the working of the Web Service in SOA_Suite(Oracle Application Server).

Step1: Start Oracle SOA Suite,

Step 2: Follow the below steps for getting connection of your application server in Jdeveloper 10g.

a) Go to Connections Tab, Right Click New Application Server Connection, Enter Connection Name as SOA_Suite,

b) Enter Username and Password of the Application Server in my case its oc4jadmin.

c) Enter the values for hostname and opmn port.

d) Test the Connection, make sure you will get Success message.

Step 3: Deploy your Java Web Service to Oracle Application Server to test it.

a) Right Click the webservice.deploy->deployto->SOA_Suite

b) Once the Deployment is Successful, Login Oracle Application Server Control, to check your Web Service is Deployed.

Step 4: Test your Web Service:

a) Select your Web Service and Click on Test Web Service .