Developing Tuxedo SALT SCA Python Components

<Do not delete this text because it is a placeholder for the generated list of "main" topics when run in a browser>


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:

Time to Complete

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:


Software Requirements

The following is a list of software requirements:


Before starting this tutorial, you should have performed the following in the order specified:

. Installed Python: Installed to /home/vmuser/python2.5.5
. Installed Apache: Installed to /home/vmuser/apache1
. 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
. Installed Oracle Tuxedo 11gR1 (instructions): Installed to /home/vmuser/tuxedo/tuxedo11g
. Installed Oracle SALT 11gR1 (instructions): Installed to /home/vmuser/tuxedo/tuxedo11g

Develop and Run Tuxedo SALT SCA Python Components

To set the lab environment up, perform the following steps. For our environment, we created a user called vmuser, and this user's home directory was used to install the products and lab files. You can either create a user called vmuser as well, and reuse the same paths as the exercise uses, or you can go your own route and be sure to modify the paths and environment touch points in your system. This tutorial will not specify where these changes need to take place as it assumes you are following the instructions verbatim.

Set up Environment

. Extract installation files:

  • Unzip the file to /home/vmuser/handson/uBikePython, which will create the folder structure for the lab files.

The uBikePython folder contains all the files needed to perform this exercise.

The table below describes the purpose of each file:

Main directory ($APPDIR): /home/vmuser/handson/uBikePython. This contains all the Tuxedo related files.
This file contains the Tuxedo configuration to run the SCA Python component and SALT servers.
This file is the root SCA composite configuration for the uBike SCA Python component.
The file that sets the environment to develop and run this exercise.
Folder that contains the bike store application components. This will contain the SCA composite and components you will develop.
Service Component Definition Language (SCDL) source for this composite.
This file contains the Python code that provides the bike store code that is exposed as an SCA-based Web Service.
This file contains the Python code responsible for purchasing a bike from the bike store.
This file contains the Python code responsible for validating credit card information.
This file contains the code that actually verifies the credit card information. It is written in C and will be called by as a Tuxedo service as part of this lab.
This file contains the database initialization code used for this lab.


. Modify and Run

  • Edit the file and make sure the variable settings are correct. If you installed everything to the same directory structure this example uses, then it should be correct by default.
  • Open a new terminal. Click the K menu button, and then select the System/Terminal menu choice.
  • Navigate to the lab directory:

    cd handson/uBikePython

  • Set up the environment using the script:

       . ./



Review Composite for Reference:

Click this snippet file to review the python.server.composite contents for reference while doing these labs..



Start Apache HTTP Server :

Start the Apache HTTP server using the script. You may ignore the warning printed above due to the self-contained environment.



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.


Desigining the Interfaces for Python Services

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.

. Open Text Editor :

  • Open the Kate editor by selecting K Menu>Utilities>Editors>Kate:



Enter Code for Python storeMain Interface :

  • Select File>New to create a new text file.
  • Copy and paste this code into the file.

Your code should resemble the following:



Save File in Correct Location :

  • Select the File>Save as… menu option.
  • Navigate to /home/vmuser/handson/uBikePython
  • Save the file as components.mif. The case is important.

Keep the source editor open for the next tasks in this lab.



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.

  • Copy and paste this code into the file after the storeMain service interface and save the file.

You may keep the source editor open for the next tasks in this lab.



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.

To load the interfaces, issue the following command from $APPDIR (/home/vmuser/handson/uBikePython):

tmloadrepos -i components.mif meta.repos

The interfaces have been created and loaded.


Developing the Python Components

With these steps, you will see what it takes to develop actual business code for the SALT SCA container.

. Examine and Repair uBike Implementation Code:

  • The component source implementation needs to be provided in a source file that follows a convention based on the contents of the SCDL.

From the following SCDL snippet found in $APPDIR/python.server/python.server.composite the implementation source code is written in a file named 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:

  • Open the source file in Kate:

  • Examine the code. This component reads the bike inventory from a database and returns it as an HTML table. The storeMain function of this component is designed to search this inventory according to a search criteria, in this case bike color. This code is incomplete and returns all bikes from the inventory. When a color is passed by the interface, use the color variable to qualify the query. When the value of the color variable is 'NONE', you may use the original query to return the complete list. This code uses the cx_Oracle library. You may use a bound variable or simply dynamically construct a string corresponding to the query you want to execute. You may comapre your code at any time with the solution to see how to code this.

Now you are ready to test your Python coomponent.


Testing the Python Services using a Web Browser

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.


Boot the Application :

Run the following command to boot the Tuxedo application:

tmboot -y



Test Application:

Open a Web browser and type in the following address:


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.



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.


Invoking a Tuxedo Service

. Modify file to call Tuxedo service:

Edit the $APPDIR/python.server/ 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.


. 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 ‘./’ and ‘tmshutdown -y -
’ to shutdown the HTTP and Tuxedo SCA servers.



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.