Overview

This document is meant to serve as a guide for exploring the interoperability of the Apache Stonehenge project. This document will walk the developer through the process of configuring the different modules to consume business services and order processing services on different frameworks.

This document assumes an environment based on a single Windows 2008 Server running all the components of the Stonehenge project. In a real world environment this application would most likely be distributed across multiple servers. Throughout this document we will refer to the services using their localhost:{port number} addresses; if your configuration is distributed over several machines, or differs otherwise, please change the localhost designation to the proper machine/host name.

Prerequisites

In order to perform the tasks in this guide, you will need to have the different components installed. Please make sure that you completed the guides on the StoneHenge wiki.

Service Configuration Overview

.NET/PHP/WSAS Configuration

The .NET, PHP and WSAS Services are managed through the StockTradeDB database. After you run the .NET Setup or the PHP database scripts you will have four new tables (DbConfig, ClientToBs, BsToOps, and Service), which are used to configure the services for .NET/PHP/WSAS.

Before you change the ClientToBs and BsToOps configuration open the Service tables and verify that the endpoint addresses are accurate for your environment. For this walk-through you will need to have the following endpoints.

Service Name

Default Value

DOTNET_BS

http://localhost:9000/TradeBusinessService

DOTNET_OPS

http://localhost:8000/TradeOrderProcessor

DOTNET_OPSSEC

http://localhost:8000/TradeOrderProcessor/sec

JAVA_BS

http://localhost:9763/services/TradeServiceWsas

JAVA_OPS

http://localhost:9763/services/OrderProcessor

JAVA_OPSSEC

http://localhost:9763/services/OrderProcessorMsec

PHP_BS

http://localhost:8080/php_stocktrader/business_service/business_svc.php

PHP_OPS

http://localhost:8080/php_stocktrader/order_processor/order_processor_svc.php

PHP_OPSSEC

http://localhost:8080/php_stocktrader/order_processor/order_processor_svc_msec.php

In the above service names BS stands for Business Service, OPS stands for Order Processing Service, and OPSSEC stands for Order Processing Service with Secure messaging. Throughout the remainder of this document the abbreviations BS and OPS will refer to the Business Service and Order Processing Service respectively. OPS will be used to refer to OPS or OPSSEC depending on your configuration.

In this edition of the interop guide WSAS is the only JAVA implementation and the two terms may be used interchangeably.

To configure the .NET Client and Business Service

  1. Open http:/localhost/trade after running the services
  2. Click to the Config tab on the header of the page
  3. Select the BS and OPS you want the .NET client to work with, from the dropdown lists
  4. Click the 'SET' button

To configure the PHP Client

  1. Open the ClientToBS table
  2. Locate the PHP_CLIENT row
  3. Change the BS value to the corresponding BS service name from the table above.

To configure the PHP Business Service

  1. Open the BsToOps Table
  2. Locate the PHP_BS row
  3. Change the OPS value to the corresponding OPS or OPSSEC service name from above.

To configure the WSAS Business Service

  1. Open the BsToOps Table
  2. Locate the JAVA_BS row
  3. Change the OPS value to the corresponding OPS or OPSSEC service name from above.

In addition to the Business Service and the Order Processing Service, both the PHP and the .NET StockTrader websites have a Configuration Service. This configuration service is used to pull the data from the database and determine which services to use in real-time.

The .NET Configuration Service is setup and built with the other .NET services, as a console app. When you run RunServices.bat you should notice the Configuration Service console appears first, with a short test for the .NET configuration. The test should display the current configuration present in the database. If the test shows up as green, the Configuration Service is able to connect to the database and retrieve configuration information accurately. If it shows up as red, then either the Configuration Service has not compiled correctly (open up ConfigServiceSolution and rebuild this) or it is unable to find the required information from the database (check that you have completed Step 3 of the .NET Installation Guide and that the database contains the configuration tables mentioned above, with rows in CLIENTTOBS for DOTNET_CLIENT and in BSTOOPS for DOTNET_BS).The configuration for the .NET client is all accessed from the front-end through the Configuration tab in the user interface.

To setup the PHP Configuration Service you will need to ensure that the resources\conf\database_config.xml file has the proper database connection information. Additionally, you will need to set the configuration service endpoint address under the Config tab of the PHP website. The default is http://localhost:8080/php_stocktrader/config_service/config_svc.php. For more information on setting up the PHP configuration see the install guide in the Prerequisites section.

Interop Walk-through

Now that you are familiar with the configuration for the different services we are going to walk through the different configurations. Since all the services are communicating with the same database you will be able place an order in the .NET StockTrader website then sell the same order from the PHP website.

Getting Started

In order to get started you should open and run all the services. Please follow these steps to start all the services and websites.

  1. Start the .NET Services
    1. %dotnet_root%\RunServices.bat (be sure to Run as Administrator)
  2. Start the WSAS server
    1. Windows: %wsas_server_root%\bin\wso2server.bat (be sure to Run as Administrator)
    2. Linux/Unix: %wsas_server_root%\bin\wso2server.sh
  3. Open the .NET StockTrader website
    1. http://localhost/trade
  4. Open the PHP StockTrader website
    1. http://localhost:8080/php_stocktrader/trader_client/
  5. Open SQL Management Studio and connect to the StockTraderDB.

If you have trouble running any of these services or websites please refer back to the installation guides in the Prerequisite section before continuing.

Placing an order on the .NET Stack

  1. From the http://localhost/trade website click Login from the top menu.
  2. Enter the StockTrader credentials of:
    1. username = uid:0
    2. password = xxx
  3. Click Login. This will authenticate you using the BS.
  4. Click Quotes/Trade from the top menu. This will pull a list of available stocks from the BS
  5. Click the Buy link next to one of the stocks
  6. Enter 111 for the number of shares and click Buy
  7. Under the default configuration the .NET website does the following
    1. Sends a message to the .NET BS to buy a stock.
    2. The BS creates a record in the database for the order with a status of open
    3. The BS then sends an asynchronous call to the OPS.
    4. At which point the page is returned with a message stating that the trade has been submitted for processing.
  8. In the background the Order Processing Service performs its processing of the order, when it has completed it updates the order in the database to closed. The closed orders will be shown to the customer the next time they request a page from the StockTrader website. Lets view the closed orders from our PHP StockTrader website

Viewing a closed order from PHP Stack

  1. Open the http://localhost:8080/php_stocktrader/trader_client/ page
  2. Click the Login button on the top menu
  3. Enter the StockTrader credentials of:
    1. username = uid:0
    2. password = xxx
  4. When you login the PHP website will authenticate you using the BS.
  5. After you have logged in you will be taken to the Accounts page, where you should be greeted with a Trade Alert, stating that your order placed in the .NET StrockTrader website has completed.

Creating an order with .NET using the PHP BS and OPS

  1. Switch back to the .NET StockTrader website
  2. Click on the Config tab from the top menu
  3. From the dropdown list for Business Services, select 'PHP_BS'
  4. From the dropdown list for Order Processing Services, select 'PHP_OPS'
  5. Click the 'SET' button
  6. Click the Quotes/Trade tab from the top menu.
  7. Click buy on one of the trades
  8. Enter a quantity of 112 for the number of shares and Click Buy
  9. You should now receive a submitted for processing message.
  10. Click the Account tab on the top menu
  11. If the PHP OPS has processed the order you should receive a Trade Alert.

Creating an order with PHP using the JAVA BS and OPS

  1. Open SQL Management studio.
  2. Connect to your StockTraderDB database.
  3. Open the ClientToBs table for editing (Right click -> Edit Top 200)
  4. Change the BS value for PHP_CLIENT to JAVA_BS
  5. Open the BsToOps table for edit
  6. Verify that the JAVA_BS is using the JAVA_OPS
  7. Click back to the PHP website
  8. Click the Quotes/Trade tab from the top menu
  9. Choose a stock and click Buy
  10. Enter a quantity of 113 for the number for shares
  11. Click Buy
  12. After the order has been submitted for processing click the Accounts tab to view the Accounts page
  13. If the WSAS BS processed your order you should receive a Trade Alert.

Selling a Trade with PHP using the .NET BS and OPS

  1. Again, without closing the PHP website, open SQL Management Studio
  2. Open the ClientToBs table
  3. This time edit the BS value of the PHP_CLIENT to DOTNET_BS
  4. Open the BsToOps table for edit
  5. Verify that the DOTNET_BS is using the DOTNET_OPS
  6. Click back to the PHP website
  7. Click the Portfolio tab from the top menu
  8. Find the order that we created with a quantity of 111 and choose Sell
  9. On the confirmation page click Sell

Selling a Trade with .NET using PHP BS and .NET OPS

  1. Switch back to the .NET Website
  2. Click on the Config tab from the top menu
  3. Verify that 'PHP_BS' is already selected from the Business Services dropdown menu
  4. From the dropdown list for Order Processing Services, select 'DOTNET_OPS'
  5. Click the 'SET' button
  6. Click the Portfolio tab from the top menu
  7. Find the order that we created with a quantity of 112 and choose Sell
  8. On the confirmation page click Sell

Selling a Trade with .NET using PHP BS and JAVA OPSSEC

  1. Click on the Config tab from the top menu of the .NET website
  2. Verify that 'PHP_BS' is already selected from the Business Services dropdown menu
  3. From the dropdown list for Order Processing Services, select 'JAVA_OPSSEC'
  4. Click the 'SET' button
  5. Click the Portfolio tab from the top menu
  6. Find the order that we created with a quantity of 113 and choose Sell
  7. On the confirmation page click Sell
  8. This order has just gone from the .NET website, to the PHP BS webservice, which updated the database with the order, then using an encrypted message channel sent the order to the WSAS OPS to process the order. After the order was processed the WSAS service updated the order in the database to closed.
  9. If you click the Accounts page, the .NET website will call back to the PHP BS and check for any closed orders, if any are found you should receive a trade alert.

Selling a Trade with PHP using the .NET BS and JAVA OPSSEC

  1. Open SQL Management Studio
  2. Open the ClientToBs table
  3. Ensure that the PHP_CLIENT is configured to use the DOTNET_BS
  4. Open the BsToOps table for edit
  5. Edit the OPS value for DOTNET_BS to be JAVA_OPSSEC
  6. Open the PHP Website
  7. Click the Portfolio tab from the top menu
  8. Click Sell on the first order.
  9. Confirm the Sale
  10. This order will be processed by the .NET Business service using the JAVA Order Processor. Additionally the order was processed with an encrypted SOAP message .

Conclusion

The Stonehenge application provides, and this paper has documented, a full end-to-end service oriented application that allows for interoperability between different platforms.  With the implementation of the WS-* Standards, developers get the benefit of distributed applications and platforms, while retaining reliable and secure messages between systems. This opens the door for technologies to co-exist in today's enterprise environments.

The Stonehenge project hopes to continue to develop example applications that use the standards currently defined by the W3C and OASIS protocols. As always, the Apache Foundation encourages contributions. For more information about the project, please see our proposal at http://wiki.apache.org/incubator/StonehengeProposal.