In this tutorial, you learn how to configure all the components required to call an Oracle Tuxedo SCA Python component, using the Oracle Service Architecture Leveraging Tuxedo (SALT) product.
After completing this course, you should be able to:
Approximately 2 hours including product download and installation time.
Oracle SALT enables developers and administrators to expose Tuxedo Python services as Web services and SCA components.
This OBE guides you through constructing an application that demonstrates calling Tuxedo SCA Python components using the SALT SOAP server gateway. The back end bike store for the uBike application is written in Python.
In this tutorial, you begin by configuring the SALT environment to expose uBike Python services as Web services that can be called by any SCA-compliant code, and test that your Web services are working using a Web browser.
Here are the different sections of this hands-on exercise:
Your company has a pre-existing bike store application, called uBike, that is implemented using Python. The company is investigating how to leverage this IT investment to work within their overall SOA strategy without making major and expensive changes. The company has decided to use Oracle SALT to expose their existing uBike Python code as Web services in an SCA container that can be easily consumed by SCA-compliant applications. This strategy integrates existing technologies to enable the application server tier to freely use Python services with very little change.
Using a Web browser, users select a bike from a list and may perform a purchase simulation. Upon purchase, a Credit Card transaction is simulated, and if it proceeds correctly the bike is no longer in the inventory.
The diagram below displays the high-level architecture of the solution:
The following is a list of software requirements:
Before starting this tutorial, you should have performed the following in the order specified:
1. | Installed Python: Installed to /home/vmuser/python2.5.5 |
---|---|
2. | Installed Apache: Installed to /home/vmuser/apache1 |
3. | Installed Oracle XE 10g Universal Database, or other supported Oracle database for Tuxedo 11gR1. The Oracle XE database was chosen for its smaller footprint. Installed to /usr/lib/oracle/xe/app/oracle/product/10.2.0 |
4. | Installed Oracle Tuxedo 11gR1 (instructions): Installed to /home/vmuser/tuxedo/tuxedo11g |
5. | Installed Oracle SALT 11gR1 (instructions): Installed to /home/vmuser/tuxedo/tuxedo11g |
1. |
Extract installation files:
The uBikePython folder contains all the files needed to perform this exercise. The table below describes the purpose of each file:
|
||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2. | Modify and Run setenv.sh:
cd handson/uBikePython
. ./setenv.sh
|
||||||||||||||||||||||||
3. |
Review Composite for Reference: Click this snippet file to review the python.server.composite contents for reference while doing these labs..
|
||||||||||||||||||||||||
4. |
Start Apache HTTP Server : Start the Apache HTTP server using the startHTTP.sh script. You may ignore the warning printed above due to the self-contained environment.
|
||||||||||||||||||||||||
5. |
Populate Database: Populate the database using the ubike.ddl script using the following command: sqlplus oracle/oracle @ubike.ddl You are now ready to perform the steps outlined in this lab guide.
|
In these steps we will see how to write interfaces for our Python components. The Python language does not define interfaces, rather objects, functions and parameters are discovered at runtime. In Tuxedo, and SCA, components do require interfaces. This is achieved using the Tuxedo Metadata Repository.
1. |
Open Text Editor :
|
---|---|
2. |
Enter Code for Python storeMain Interface :
Your code should resemble the following:
|
3. |
Save File in Correct Location :
Keep the source editor open for the next tasks in this lab.
|
4. |
Enter Code for Python Credit Card and Buy Interfaces: This Metadata Repository input file can actually contain more than one interface. We also need one for the Credit Card operation and one for the buy operation.
You may keep the source editor open for the next tasks in this lab.
|
5. |
Load the Interfaces: This step prepares the interfaces in a format that allows Tuxedo to retrieve interfaces
quickly. The TMMETADATA system process is responsible for holding interfaces in
memory, allowing applications that need them to access them rapidly. tmloadrepos -i components.mif meta.repos The interfaces have been created and loaded.
|
With these steps, you will see what it takes to develop actual business code for the SALT SCA container.
1. |
Examine and Repair uBike Implementation Code:
From the following SCDL snippet found in $APPDIR/python.server/python.server.composite the implementation source code is written in a file named bikestore.py. The name is not mandatory, just make sure they match.
For convenience this file and the related code is already provided in the /home/vmuser/handson/uBikePython/python.server directory:
Now you are ready to test your Python coomponent.
|
---|
Once the code is complete, you may start the Tuxedo application. The code is parsed and interpreted when the HTTP server invokes it via SCA.
1. |
Boot the Application : Run the following command to boot the Tuxedo application: tmboot -y
|
---|---|
2. |
Test Application: Open a Web browser and type in the following address: http://localhost:1080/bikestore.py This is the main page of the application. From here you can narrow down the list of bikes by selecting a color, and buy one of the bikes listed. This lab is successful when you select a bike color and the service only returns the bikes of that color.
|
3. |
Buy Bike Test: Click the Buy button next to a bike to buy that bike. This takes you to a page where you can purchase that particular bike. It asks you to enter credit card information: You should enter something in both Name on card and Card number fields. If you click Go ahead, the result will be a 'Transaction denied' page. In the next part, we will see how to invoke an existing Tuxedo service that will change this.
|
1. |
Modify CC.py file to call Tuxedo service:
Edit the $APPDIR/python.server/CC.py file: Insert the following code after the # Call Tuxedo Credit Card verification service comment If the call fails for any reason the code will throw and exception and not perform the next step which is to mark the bike sold in the database. Do not forget to remove the return “Transaction denied” call.
|
---|---|
2. | Test Application:
Shutdown then reboot the Tuxedo application by entering the following commands: tmshutdown -s SCAHOST tmboot -s SCAHOST Then perform the test again in the previous step. This time the result should be “Transaction accepted”, and the corresponding bike will no longer be listed in the inventory query. The related Tuxedo server message can be found in /home/vmuser/handson/uBikePython/stdout. Once completing the exercise, Navigate to the lab directory
/home/vmuser/handson/uBikePython to execute ‘./stopHTTP.sh’ and ‘tmshutdown -y -
|
Congratulations! You have successfully completed this OBE tutorial.
Oracle SALT exposes Python services as Web services and SCA components, and is a bidirectional gateway to and from Tuxedo applications. This enables SCA-compliant applications to call SCA Python components as part of an Enterprise SOA application. Now you can implement your own solutions that use these technologies together.
In this tutorial, you should have learned how to:
Check back on OTN for more OBE tutorials that build on this example to demonstrate other Tuxedo product integration examples.