BPELExercise_RestaurantFinder

advertisement
Vakgroep Informatietechnologie
Design of Distributed Software 2008-2009
Lab Session III: Java Web Services and BPEL
Group:
Group members:
Your group ID
for this lab session:
-
Exercise: The Restaurant Finder
In this exercise you will have to compose a new service out of 2 existing Web Services by using BPEL.
The goal is the find a restaurant that has an outside terrace or not depending on the weather conditions.
If the average temperature is equal or above 17 degrees and the chance of precipitation is lower
than 30 percent, we want a restaurant that has an outside terrace. Otherwise, we want a restaurant
without an outside terrace. This flow is illustrated below. The BPEL has to return the name and the
address of the closest restaurant that qualifies our needs (namely it has an outside terrace or not
depending on the weather).
The inputs for your composite service are the zip code, latitude, longitude, maxDistance (all these inputvariable are int-values). The output is the name and address of the restaurant (See last task).
There are 2 Web Services available which can be used to complete this task:
The first Web Service is located at
http://chaos164.test.atlantis.ugent.be:8080/WeatherService/WeatherService?wsdl
This Web Service gives information about the weather conditions in a certain zip code. It contains six
methods:
- getMaxTemperature(int zipcode): returns the maximum temperature that will be reached today
in this zip code area.
- getMinTemperature(int zipcode): returns the minimum temperature that will be reached today in
this zip code area.
- chanceOfPrecipitation(int zipcode): returns the chance (percentage) of today in this zip code
area.
- getWindStrength(int zipcode): returns the strength of the wind (bft) today in this zip code area.
- getWindDirection(int zipcode): returns the direction of the wind today in this zip code area.
- isCloudy(int zipcode): returns whether it will be cloudy today in this zip code area.
Design of Distributed Software (website: http://minerva.ugent.be, e-mail: ods@atlantis.ugent.be)
Vakgroep Informatietechnologie - Gaston Crommenlaan 8, bus 201, B - 9050 Gent - www.intec.UGent.be
The second Web Service is located at:
http://chaos164.test.atlantis.ugent.be:8080/RestaurantService/RestaurantFinderService?wsdl
This Web Service gives information about the restaurants in a certain area. It contains the method
findRestaurants that takes 4 parameters: the zip code, the latitude and the longitude of your current
location, and the maximal distance (in meter) to the restaurant. The method returns all the restaurants
that are within this maximal distance from your current location and that are in the given zip code. The
order of the returned restaurants is: from the closest one, to the furthest.
Each restaurant contains information about its location, about the food it serves and if it has an outside
terrace or not.
Questions:

TASK:
(1) Create a new BPEL Module “RestaurantLocator”.
Create a new WSDL document (RestaurantLocatorWSDL) in this project that will serve as client
partner link. Specify the input and output parameters of the WSDL and write them below:
Input or Output?
Message part name (parameter name)
Element or Type
(2) First create BPEL file RestaurantLocatorBPEL. Drag the WSDL on the BPEL to create a client
partner link. Create the necessary Receive node and connect with the partner link.
(3) Create two partner links for the other 2 Web Services.
To do this add an external wsdl document to the BPEL project.
http://chaos164.test.atlantis.ugent.be:8080/WeatherService/WeatherService?wsdl
http://chaos164.test.atlantis.ugent.be:8080/RestaurantService/RestaurantFinderService?wsdl
(4) Now create a construction that checks for the second condition “average temperature must be
higher or equal to 17 degrees”.
1) a) Which method(s) are you going to call?
b) Which construct(s) will you use for this?
2) a) Which construct(s) are you going to use for to check the condition?
b) Write down the XPath-expression that you used to express this condition.
Answers:
1) a)
b)
2) a)
b)
Design of Distributed Software 2008-2009 – Lab Session III: Java Web Services and BPEL
2/3
(5) Now create a construction that checks for the first condition “chance of precipitation must be lower
than 30%”. Make sure that this construction is INSIDE the previous construction.
Answer the following questions:
1) a) Which method(s) are you going to call?
b) Which construct(s) will you use for this?
2) a) Which construct(s) are you going to use for to check the condition?
b) Write down the condition (XPath-expression) that you used to express this condition.
Answers:
1) a)
b)
2) a)
b)
(6) Create a new boolean variable named outsideTerrace. Assign the right value to this variable
wherever needed (by using Logical False and Logical True in the Mapper tab). You can use this
variable before you call the restaurant finder service.
(7) Call the findRestaurants method outside (and below) all these constructions.
Which construct(s) will you use for this?
Answer:
(8) We now have all the restaurants within a certain distance from our location (and within the indicated
zip code). We now have to filter these restaurants according to the value stored in outsideTerrace.
1) Create a new variable FilteredRestaurants that has the same type as the return value of the
findRestaurants function.
2) Use an Assign function and a Predicate to filter the restaurants from the response and put
the remaining once in the newly created variable.
3) Which predicate did you use?
Answer:
(9) Now create Assign en Reply constructs that take the first entry out of the filtered list and return this
as output of the BPEL.
(10) Create a Composite Application for this BPEL Module and deploy it.
(11) Create a new Test Case in the Composite Application with the following input:
Latitude: 51 Longitude: 4 Zipcode: your groupnumber Maximum Distance: 5000 meter
Run the testcase!

ANSWER - Have you found the restaurant? Write the name and address of the restaurant
below and show it to an assistant.
The name of the restaurant is:
The address (streetname + number) of the restaurant is:
Design of Distributed Software 2008-2009 – Lab Session III: Java Web Services and BPEL
3/3
Download