2011/05/02

jDeveloper: Create and deploy a Java Webservice

This tutorial shows how to create a simple Java Webservice using the Oracle jDeveloper 11g IDE. The attached code for the example connects to a database through JDBC and executes a SQL statement to insert a new row in a specific table.

Once the application has been configured, it will be deployed and tested in a Oracle Weblogic Server. We will execute the webservice through a web browser and check it by connecting to the database with a sqlplus console.

Step-by-step:
1) Create a generic java application and add the webservice component

2) Create a new java class and add some methods to publish. Here you have an example:
NOTE: Remember to adapt this code to your requirements.

public void InsertValue(String user, String value){
try{
//Example from http://studentsatoracle.blogspot.com
Connection con=null;
Class.forName("oracle.jdbc.driver.OracleDriver");

//Configure the jdbc connection: jdbc:oracle:thin:@host:port:SID,username,passwd
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:owcdb01", "DEV_WEBCENTER","welcome1");
Statement s = con.createStatement();
//Configure the SQL query as you want, the table must exists
s.execute("INSERT INTO DEV_WEBCENTER.uservalues (ID,USERNAME,INSERTDATE,VALUE) VALUES (DEV_WEBCENTER.uservalues_seq.nextval,'"+user+"',To_char(SYSDATE),"+value+")");
s.close();
con.close();
}catch(Exception e){
System.out.println("ERROR: "+e.getMessage());
}
}


3) Configure the webservice and publish the desired methods

4) Deploy the application. You can follow this guide to create a deployment profile: http://studentsatoracle.blogspot.com/2011/02/jdeveloper-how-to-deploy-application-to.html

5) Open a Weblogic Server console and test the application

Documentation:
Oracle's official documentation for jDeveloper 11g

Downloads:
Oracle jDeveloper 11g

Viewlet:
(Duration: 3 min.)

8 comments:

  1. The post describes steps to create and deploy Java web services. The given steps are easy to understand and perform. You can view the detail in the video. You just need to follow the given steps. You are doing excellent work. Thanks.

    ReplyDelete
  2. Cuando intento exponer el insert me dice null

    ReplyDelete
  3. Data not inserting into the table and I get the following XML...






    ReplyDelete
  4. we are the leading oracle fusion trainers in Hyderabad. we have our services online also.
    we have globally recognized the platform is http://www.erptree.com where people come and
    subscribe for various oracle related courses. we provide free instance access for our subscribers.
    for more details please visit our site erptree.com thank you.
    oracle fusion financials training
    oracle fusion financials online training
    oracle fusion Procurement training training
    oracle fusion procurement online training

    ReplyDelete
  5. Thank you for sharing such a nice and interesting blog with us.

    Oracle Fusion Financials Online Training

    ReplyDelete
  6. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well.

    oracle fusion scm online training

    ReplyDelete