930 likes | 947 Views
Learn how to develop, deploy, and manage web services using JDeveloper and Oracle Application Server. This tutorial will guide you through the process step-by-step.
E N D
Developing, Deploying and Managing Web Services Using JDeveloper and Oracle Application Server Nisha Stephen CIS764 – Enterprise Databases Kansas State University
Before starting this tutorial, you should have the following prerequisites:1) Have installed the JDeveloper 10g (10.1.3).2) Have started JDeveloper by double-clicking <JDEV_HOME>\jdeveloper.exe. If you receive a message asking if you want to migrate from a previous version, click No.
Start Oracle Application Server Containers for J2EE (OC4J) by double-clicking <JDEV_HOME>\jdev\bin\start_oc4j.bat.
Watch the resulting command window and wait until you see the message 'Oracle Containers for J2EE 10g (10.1.3.0.0) initialized'. Then you can minimize the window, but do not close it.
Creating the Java ClassJDeveloper enables you to use an existing web service or to create one with Java or PL/SQL.In this tutorial tutorial,you create a web service that is based on a Java class.In the Application Navigator, right-click the Applications node and select New Application from the context menu.
Click Next when the “Create Application Server Connection” page is displayed
In the Authentication step, Enter the username as oc4jadmin and the password as welcome1
Click Test Connection to get a success in the Status box. Click Next
The connection has been established and we get a oc4jconn Application Server
Click the Application Navigator and right click the New Application
Enter the Application Name as JavaWebService and select No Template[All Technologies] and click Next
From the Catagories, select General and from Items select Java Classand click OK
Enter the Name as GetDates and the Package as datespackage and click OK
In the editor, create a method getDate() that uses java.util.Calendar to return the date and time.public Calendar getDate() { return Calendar.getInstance(); }
Because the code refers to a class that is not yet available to this package, you are prompted to import the class. Press [Alt]+[Enter] to import the suggested class java.util.Calendar
In the editor, create a second method getDateHence() that uses java.util.GregorianCalendar to add a user-defined number of days, specified as the int parameter daysHence, to today's date. Add the following code below the getDate() method. public Calendar getDateHence( int daysHence) { GregorianCalendar myCalendar = new GregorianCalendar(); myCalendar.add(GregorianCalendar.DATE, daysHence); return myCalendar; }
Pressing [Alt]+[Enter] when prompted will import java.util.GregorianCalendar:
The log should show successful compilation. In the Message- Log editor
Creating a Web Service on the Java Class.Right-click the GetDates project and select New from the context menu
Click the Bussiness Tier in the Catagories to expand it and click on the Web Services option. On the right side click on the Java Web Service and click OK
Enter GetDatesWS for the Web Service Name. Select datespackage.GetDates from the Component To Publish dropdown list. Select the Generate annotations into class check box. Click Next.
On the Specify Custom DataType Serializers page of the wizard, click Next.
On the Methods page of the wizard, select the check boxes next to both methods from the Available Methods list and click Finish.
Scroll to the bottom of the WSDL file and copy the URL defined in the soap:address node.
If the file is still open, click the GetDates.java tab at the top of the editor, or reopen the GetDates.java file by double-clicking it in the Application Navigator: (JavaWebService > GetDates > Application Sources > datespackage > GetDates.java).
Exploring the WSDL EditorIf the file is still open, click the GetDatesWS.wsdl tab at the top of the editor, or reopen the GetDatesWS.wsdl file by double-clicking it in the Application Navigator: (JavaWebService > GetDates > Web Content > WEB-INF\wsdl > GetDatesWS.wsdl). Click the Design tab at the bottom of the editor to view the visual editor. In the Services column, select the GetDatesWSSoapHttpPort node.
Expand the getDateHence binding node, and select the input node.
Observe how the GetDatesWS_getDateHence message is connected to getDateHence operation which is in turn connected to the input node of the getDateHence binding
The getDateHence operation would be in turn connected to the input node of the getDateHence binding.
Deploying and Testing the Web Service In the Application Navigator, expand the Resources node. Right-click WebServices.deploy, and select Deploy to > oc4jconn from the context menu.