Deploying a Web Service on Oracle Application Server 10g
Deploying a Web Service on Oracle Application Server
10g
This tutorial describes how to deploy a Web Services application
to Oracle Application Server 10g and how to publish Web Services to
UDDI registry.
Approximately 30 minutes
This tutorial covers the following topics:
Place the cursor over this icon to load and view all
the screenshots for this tutorial. (Caution: Because this action loads all screenshots
simultaneously, response time may be slow depending on your Internet connection.)
Note: Alternatively, you can
place the cursor over each individual icon in the following steps to load and
view only the screenshot associated with that step.
Before starting this tutorial, you should:
| 1. |
Have access to a machine with Microsoft Windows
2000 operating system and Service Pack 3 or above. |
| 2. |
Install Oralce Application Server 10g Infrastructure. |
| 3. |
Install Oralce Application Server 10g Portal
and Wireless. |
| 4. |
Initialize and configure UDDI Registry by pinging the UDDI Inquiry servlet
end point. Open a browser window and enter the following URL:
http://<hostname>:<domain>:<HTTP listen port>/uddi/inquiry
Note: The HTTP listen port is typically 80 for windows installation.
The OracleAS UDDI Registry page is displayed. You should see the message:
"Welcome! Your registry is now up and running."
|
| 5. |
Install Oracle database 10g. The Oracle
database must have a schema called scott.
|
| 6. |
Unzip the webservices.zip file into
your working directory E:\wkdir.
|
| 7. |
Download and install Ant
which is a program used to compile and run java applications. For this
OBE, Ant version 1.6.2 is used.
Note: As suggested in the Ant install you should create
an environment variable called ANT_HOME
set it to the directory in which you installed Ant, and add the ANT_HOME\bin
directory to your PATH.
Open a command prompt and issue the following commands:
Note: While executing the commands, you might have to change the
folder names as per your installation folders.
set ANT_HOME=E:\apache-ant-1.6.2-bin\apache-ant-1.6.2
set PATH=%PATH%;%ANT_HOME%\bin

|
| 8. |
Set the environment variable called ORACLE_HOME
to the directory in which you installed the database. Include ORACLE_HOME\bin
in the PATH.
set ORACLE_HOME=E:\oracle\product\10.1.0\db_1
set PATH=%PATH%;%ORACLE_HOME%\bin
|
| 9. |
Make sure your database service is running. Connect to the scott
schema and execute the script create.sql.
cd E:\wkdir\webservices\server\sql
sqlplus scott/tiger
@create
This will create the necessary objects you will need to run your plsql
Web Service.

|
| 10. |
Add JAVA_HOME to
your environment variables and set it to ORACLE_HOME\jdk.
Include JAVA_HOME\bin
in the PATH.
set JAVA_HOME=%ORACLE_HOME%\jdk
set PATH=%PATH%;%JAVA_HOME%\bin

|
| 11. |
Add J2EE_HOME to
your environment variables and set it to <oracleas_portalhome>\j2ee\home.
set J2EE_HOME=E:\portal_home\j2ee\home
Note: Use the same command prompt throughout the OBE because all
the environment variables are set.
|
Back to Topic List
OracleAS 10g Web Services provides a highly
scalable runtime infrastructure for developing, deploying and managing Web Services.
OracleAS 10g supports Stateless and Stateful Java classes, Stateless
Session Beans, and Stateless PL/SQL Stored Procedures as RPC style Web Services.
OracleAS 10g also supports Document Style Web Services (Stateless/Stateful
Java, JMS). The WebServicesAssembler
tool packages Java and PL/SQL Web Services as J2EE EAR files that can be deployed
on OracleAS 10g.
OracleAS 10g runtime automatically generates
endpoint home page for the Web Services during deployment. This home page provides
a central location, links, to access the following (i) the WSDL file; (ii) a
downloadable static Java client proxy; (iii) Java client proxy source; (vi)
a Web Services test page.
Oracle Enterprise Manager 10g has also been
enhanced to support deployment and management of newly exposed J2EE artifacts
as Web Services. OracleAS 10g UDDI registry is now fully complaint
UDDI v1 registry that provides the facility to publish, query and search a Web
Service.
Back to Topic List
The Web Services application illustrates how to use the 4
types of Web Services that can be build: Stateless Java, Stateless session EJB,
Stateless PL/SQL procedure.
The application includes the following files:
 |
server/ - web services server components
|
|
 |
sql/ - SQL scripts for the PL/SQL web service
|
|
|
- |
create.sql - main script (you will run this)
|
|
|
- |
createt.sql - script creating tables
|
|
|
- |
createp.sql - script creating package
|
|
|
- |
createb.sql - script create package body
|
|
|
- |
drop.sql - drop everything created
|
|
|
- |
insert.sql - inserts required data into the employees table
|
|
 |
wsejb/ - HelloEJB for the EJB web service
|
|
|
- |
META-INF/
|
|
|
|
- ejb-jar.xml - EJB deployment descriptor
|
|
|
- |
HelloEJB.java - HelloEJB remote interface
|
|
|
- |
HelloEJBHome.java - HelloEJB home interface
|
|
|
- |
HelloEJBBean.java - HelloEJB bean implementation
|
|
 |
wsweb/ - Web Components
|
|
|
- |
WEB-INF/
|
|
|
|
- classes/
|
|
|
|
- Hello.java - stateless Java web service interface
- HelloImpl.java - stateless Java web service implementation
- Count.java - stateful Java web service interface
- CountImpl.java - stateful Java web service implementation
- CompanyInterface.java - PL/SQL web service interface
|
|
 |
config.xml - config file used by the WebServices Assembler tool
|
|
 |
build.xml - build file used by Ant for server components
|
 |
client/ - web services client components
|
|
 |
HelloClient.java - stateless java web service client
|
|
 |
CountClient.java - stateful java web service client
|
|
 |
EJBWSClient.java - EJB web service client
|
|
 |
PLSQLClient.java - PLSQL web service client
|
|
 |
build.xml - build file used by Ant for server components
|
 |
common.xml - common setup file for Ant
|
| 1. |
Examine HelloEJB
and find out how it is implemented.
|
| 2. |
Examine the classes located in E:\wkdir\webservices\server\wsweb\WEB-INF\classes
and understand how they are implemented.
|
| 3. |
Examine E:\wkdir\webservices\server\config.xml
and understand how it defines various types of Web Services (stateless
java, stateful java, stateless session EJB and stateless PL/SQL stored
procedure)
|
| 4. |
Database Setup: examine the SQL scripts located in
E:\wkdir\webservices\server\sql.
These scripts create database tables, package, types and procedures required
by the PL/SQL web service. The database objects have already been created
for you in the scott/tiger schema.
|
| 5. |
The Web Services application has already been built for you. You should
be able to find the EAR file in E:\wkdir\webservices\server\build
(wsapp.ear).
|
| 6. |
If you need to recompile, run the ant
tool from E:\wkdir\webservices\server
to build the Web Services application. Ant will perform the following:
 |
Build the EJB Module |
| |
 |
Compile the Hello EJB classes |
| |
 |
Package the EJB Jar file |
 |
Build the JAR file for PL/SQL web service |
| |
 |
Use JPublisher to generate Java and SQLJ files representing the
database packages, types and procedures |
| |
 |
Use SQLJ Precompiler to translate generated SQLJ files to Java |
| |
 |
Compile all generated java classes |
| |
 |
Package java classes into a JAR file (representing the PL/SQL package) |
 |
Compile the java classes for stateless and stateful
java Web Services (interfaces and implementations) |
 |
Call the WebServicesAssembler tool to build the web
module, generate the web.xml descriptor that defines servlet entry
points for different types of Web Services. Package everything into
an EAR file |
|
| 7. |
Use a compression tool (e.g. winzip) to examine the content of the generated
wsapp.ear file.
Take a close look at the wsapp_web.war\WEB-INF\web.xml
file generated by WebServicesAssembler, understand how it defines the
servlet entry points for the following types of Web Services and identify
the components that implement each type of Web Service.
 |
Stateless java class |
 |
Stateful java class |
 |
Stateless session EJB |
 |
Stateless PL/SQL stored procedure |
|
Back to Topic List
| Oracle Application Server 10g provides a Universal
Discovery Description and Integration (UDDI) Web Services registry known
as Oracle Application Server UDDI Registry (OracleAS UDDI Registry). With
OracleAS UDDI Registry, Web you can publish Web Services for use by Web
Services consumers (application programmers). Web Services consumers can
use the UDDI inquiry interface to discover published Web Services and can
use those services in their applications for a particular enterprise process.
In this section, you will learn how to browse the UDDI Registry. |
| 1. |
Open your browser and enter the following URL: http://<hostname>.<domainname>:1810/.
Note: The administration port number is automatically assigned
during installation of Oracle AS 10g and may be different for your
installation. When prompted for user name and password, enter ias_admin
and the password you specified when installing the application server,
for example welcome1.

|
| 2. |
You will see the OracleAS Farm page that lists the application server
instances on your machine. Click on the link for the portal instance to
go to Portal Home page.

When prompted for user name and password, enter ias_admin
and the password you specified when installing the application server.
|
| 3. |
You will see the Enterprise Manager 10g Application Server
Control Console for Portal.

In the System Components table click the OC4J_Portal link.

|
| 4. |
The Home page is the initial administration page for
the portal OC4J instance, and provides status and performance information.
The Applications page provides a list of applications
that have been deployed to the container and information on their usage
and performance. The Administration page provides links
to view and modify configuration information.

|
| 5. |
Click the Administration tab.

|
| 6. |
Click UDDI Registry under Related Links.

|
| 7. |
OracleAS UDDI Registry supports the following standard taxonomies for
classifying tModels, businessEntities, and businessServices:
- North American Industry Classification System (NAICS)
This is a classification system for each industry and corresponding
code.
- United Nations Standard Products and Services Codes (UNSPSC)
This is the first coding system to classify both products and services
for use
throughout the global marketplace.
- ISO 3166 Geographic Taxonomy
This a list of all countries and their subdivisions.
Click North American Industry Classification System (NAICS).

|
| 8. |
NAICS taxonomy in turn has many categories. These categories and the
respective codes are listed in a table. You can click on the category
names to view the sub-categories. To see the Web Services published under
a particular category you must select the category and click View Services.
In this OBE, you will publish the Web Services to Wholesale Trade category.

|
Back to Topic List
Perform the following steps to create the DataSource :
| 1. |
Click OC4J: OC4J_Portal in the breadcrumbs to return to the portal
OC4J home.

|
|
2.
|
To add or modify a data source click the Administration
tab.

|
| 3. |
In the Administration tab page, scroll down and click
Data Sources.

|
| 4. |
In the Data Sources page, select the OracleDS radio button and
click Edit.

|
| 5. |
In the Edit Data Source page, modify fields
of the OracleDS Data Source to identify your
database. Use the data source username of scott
and password tiger. Then scroll down and click
Apply. This data source will be used by the PL/SQL web service.


|
| 6. |
Click Yes on the confirmation page to restart the OC4J server.

|
| 7. |
A progress page displays while the portal OC4J is being restarted, followed
by a confirmation page when the home OC4J instance has been restarted.
In the confirmation page click OK.


|
Back to Topic List
| 1. |
You are returned to the data source page. Click the OC4J: OC4J_Portal
link in the breadcrumbs to go to the OC4J instance configuration page.

Go to the Applications page.
|
| 2. |
Click Deploy EAR File to launch the deployment wizard, which will
guide you through the steps required to deploy an application.

|
| 3. |
In the Deploy Application page, click Browse...,
to select the wsapp.ear
from the E:\wkdir\webservices\server\build
directory as the EAR file to deploy. Enter wsapp
as the application name. Click Continue.

|
| 4. |
In the Deploy Application: URL Mapping for Web Modules
page, check that /wsapp
is specified as the URL Mapping for the application. Click Next.

|
| 5. |
In the Deploy Application: Resource Reference Mappings
page, enter jdbc/OracleDS as the JNDI Location, this maps the jdbc/wsDS
data source (used by the PL/SQL Web Service) to the jdbc/OracleDS
defined in a previous step. Click Next.

|
| 6. |
Oracle Application Server 10g provides a JAAS user provider
that can be used for J2EE application security management. This is the
default Oracle Application Server 10g user manager service,
also known as JAZN. In the Deploy Application: User Manager
page, accept the default setting Use JAZN XML User Manager. Click
Next.

|
| 7. |
You will see that the application has three Web Services. However, none
of the Web Services are published yet. Select the first Web Service and
click Publish.

|
| 8. |
In the Service Details section enter the Name as count,
Code as 42(this is the code for the Wholesale category under NAICS
Classification). In the TModel Details section enter the Name as Count
and Code as 42. Click OK.

|
| 9. |
You can see that the Web Service is published. Similarly, publish the
next two Web Services.

|
| 10. |
After publishing all the Web Services, click Next.

|
| 11. |
In the Deploy Application: Review page, check the deployment
information summary (source/target, resource mappings, etc.). Also note
that the application contains three Web Services modules. Click Deploy
to deploy the application to Oracle Application Server 10g.

|
| 12. |
The Processing: Deploy page is displayed.

Click OK in the confirmation page.

|
| 13. |
After clicking OK in the confirmation page the Applications
page of the OC4J instance is displayed. You should see wsapp in
the list of Deployed Applications.

Select wsapp from the list of deployed applications.

|
| 14. |
In the Application: wsapp page select the wsapp_web
entry from the list of Web Modules.

|
| 15. |
Scroll down to look at the Servlets/JSPs section. Click Mapping
under Properties.

|
| 16. |
In the Mappings page you see the Servlet URL mappings
for each of the Web services. Click Back button of the browser
to return to Application: wsapp page.

|
| 17. |
Click Environment under Properties to examine the Data
Source JNDI mapping you defined upon deployment.

Click Back button of the browser to return to Application:
wsapp page.

|
| 18. |
Click Advanced Properties to see how the data source is mapped
in the orion-web.xml file.


|
Back to Topic List
| 1. |
Click OC4J: OC4J_Portal in the breadcrumbs to return to the OC4J
Home page.

|
| 2. |
Click Administration to go to Administration page.

|
| 3. |
Click UDDI Registry under Related Links to browse UDDI Registry.

|
| 4. |
Recollect that you have published the Web Services to Wholesale Trade
category of NAICS taxonomy. Click North American Industry Classification
System (NAICS).

|
|
5.
|
You can see all the categories under NAICS classification. Select Wholesale
Trade Category and click View Services.

|
| 6. |
All the Web Services that you registered to this category are shown.

Click count Web Service.

|
| 7. |
You see the details that you specified while publishing the Web Service
to UDDI.

|
Back to Topic List
Now you are ready to test the application. Start by running
the application using the Oracle Web Cache port, typically 80, in the URL request.
Note: The Web Cache port may be different for your installation (To determine
the HTTP listen port for Web Cache, click the Ports tab in Enterprise Manager
10g Application Server Control Console and look for the HTTP Listen port
for the Web Cache component). We will run the application through Oracle Web
Cache. Perform the following steps:
| 1. |
Open a browser and enter the following URL to run the Web Services application
from the browser: http://<hostname>:80/wsapp/.
This page was generated by the Web Services Assembler. You should be able
to see four different types of Web Services: Stateless Java, Stateful
Java, Stateless session EJB, Stateless PL/SQL procedure.

Click on stateless Java web service - /wsapp/helloService to go
to the stateless Java Web Service page.

|
| 2. |
Optionally you can click on the Service Description link to view
the WSDL file for the Web Service. Examine the XML elements of
the WSDL document.
Click sayHello to test run the stateless Java web service.

|
| 3. |
Enter any string in the Value field and click Invoke.

|
| 4. |
You should be able to see the result SOAP message returned by the stateless
Java Web Service. Close this window when done.

|
| 5. |
Click Back button of the browser to return to the helloService
Web Service Home page.

|
| 6. |
Right click Proxy Jar and select Save Target As
to
download the proxy jar file generated by OC4J. Save it to E:\wkdir\webservices\client
directory as helloService.jar
(make sure you change the file extension to .jar). You will need this
jar file to build a standalone Web Service client application.


|
| 7. |
Go back to the Web Services Home page and click stateful Java web
service - /wsapp/countService.

|
| 8. |
Click count to test run the stateful webservice.

|
| 9. |
Click Invoke.

|
| 10. |
A new window is displayed containing the SOAP result returned by the
web service.

|
| 11. |
Reload (or refresh) the page. You should be able to see the counter increase,
as highlighted every time you reload the page. Close the window when done.


|
| 12. |
Save the generated Proxy Jar as countService.jar
in the E:\wkdir\webservices\client
directory.


Click Back button of the browser to return to the Web Services
Home page. Click on stateless session bean web service. The EJB
Web Service is very similar to the stateless Java web service except it
is implemented using a stateless session bean. Save the generated Proxy
Jar as ejbService.jar
in the E:\wkdir\webservices\client
directory. Since the steps are same, these steps are not included in the
OBE.
|
| 13. |
Return to the Web Services Home page and click stateless PLSQL web
service - /wsapp/plsqlService.

|
| 14. |
Click getemp in the Company Web Service Home page.

|
| 15. |
Enter 1234 in the Value field (employee id) and click Invoke.

|
| 16. |
You should be able to see the result SOAP message representing a row
in the EMPLOYEES table
returned by the PLSQL Web Service. Close the window when done.

Save the generated Proxy Jar as plsqlService.jar
in the E:\wkdir\webservices\client
directory.
|
Back to Topic List
| 1. |
Now you will build standalone Java applications to access the deployed
Web Services. Make sure the E:\wkdir\webservices\client
directory contains the following Web Services stub files (saved from the
Proxy Jar links):
 |
helloService.jar |
 |
countService.jar |
 |
ejbService.jar |
 |
plsqlService.jar |
Take a look at how these proxy classes are implemented. Examine the
client applications located in E:\wkdir\webservices\client
and see how they access the Web Services by calling the proxy classes.
Open a command prompt window and execute the following commands:
d:
cd E:\wkdir\webservices\client
ant

|
| 2. |
You can run all the client applications all at once:
ant RunAll
Or run them individually:
ant RunStateless
ant RunStateful
ant RunEJB
ant RunPLSQL

|
Back to Topic List
In this lesson, you've learned how to:
|
Browse the UDDI Registry
|
|
Deploy the Web Services application to Application Server 10g
and Publish Web Services to OracleAS UDDI Registry
|
|
Test the deployed Web Services application
|
 |
Build standalone Java clients, using Ant, to access the deployed
Web Services |
Back to Topic List
 |
To ask a question about this OBE tutorial, post a query on the OBE
Discussion Forum |
 |
To learn more about Web Services, click here. |
Place the cursor over this icon to hide all screenshots.
|