Lab 9 - Java Web Services
INSTRUCTIONS FOR LAST YEAR'S LAB. THIS FILE NEEDS TO BE UPDATED
In this lab you'll implement a Java Web Service that provides a facade
for a stateless EJB Session Bean. More specifically the following
example
demonstrates:
-
Use of a stateless EJBean as a Backend Component for a web service
-
A Java web service that provides access to the backend component
-
Use of WebLogic server as the hosting application server, along with
ant
tools to facilitate the building and deployment of Java Web Services
Part 1. Deploy and run the code example. The source code is in /home/mark/pub/51024/myFirstWebService/myFirstWebService.tgz
. Change to your directory:
~/weblogic/weblogic700/samples/server/src/examples/webservices/basic
Then execute this command:
tar xzvf /home/mark/pub/51024/myFirstWebService/myFirstWebService.tgz
Setup:
cp
~matei/weblogic/weblogic700/samples/server/src/examples.properties
~/weblogic/weblogic700/samples/server/src
Then edit
weblogic/weblogic700/samples/server/src/examples.properties
and change all instances of "matei" with YOUR
login id.
Then, in EVERY shell window in which you will be working,
execute
the weblogic environment setup:
.
~/weblogic/weblogic700/samples/server/config/examples/setExamplesEnv.sh
Steps:
-
cd to the
~/weblogic/weblogic700/samples/server/src/examples/webservices/basic/myStatelessSession
directory
-
make sure you have your WebLogic server started
-
Examine the EJB session bean closely
-
Run the command: "ant all" in the directory
-
This will build the backend EJB Session Bean (this is essentially the
WebLogic
Trader example modified for use as a backend to a web service)
-
cd to the
~/weblogic/weblogic700/samples/server/src/examples/webservices/basic/my
FirstWebService directory
-
Examine the Client.java code carefully. This client will execute
and hit your web service once it's built and deployed
-
Examine the build.xml file carefully. Examine the <target
name="ear"
> section carefully. Notice that it calls the servicegen Ant
task.
Examine that task carefully
-
Execute "ant all" in the directory to create and deploy the web service
-
Once the service is created, open the following URL to validate the
deployment
of your web service:
http://localhost:7001/mywebservice/SampleEJBService
You should see a page describing the two methods available on the
service:
buy and sell
- In the MyFirstWebService directory, run the following command to
validate
execution: "ant run"
You should see several stock purchases and sales in the client window
as well as in the stdout of the server
Assignment: Wrap up your own Calculator Session bean created
in Lab 6/Assignment 4 as a backend to a webservice.
(If you are not planning on using Web Services for your final project
delivery, you may skip this assignment, as it is not required for your
grade. If, on the other hand, you are planning on implementing
with
Web Services, you will find this exercise useful).
Hints:
You will find WebLogic's
Programming WebLogic Web Services helpful in terms of details.
Perhaps the best strategy for the assignment would be to copy the
MyFirstWebService
directory over to ../CalculatorWebService and modify the Client and
build.xml
to hit your Calculator EJB.