This is the second example that demonstrates the ease of integrating security and reliable messaging to the WSO2 Application Server.
It demonstrates trading interactions between a stock exchange, trader (stock broker) and a client (shareholder). A shareholder who needs to buy and sell shares, should first become a client of that particular trader. A trader can register his client (the shareholder) in the stock exchange. Once registered, the shareholder uses his Central Depository System (CDS) account to buy and sell.
The following section describes the services offered by each party involved.
1. Client creates an account with a trader and receives a user ID. The Trader registers the Client with the stock exchange using client information.
2. The Client obtains a CDS account using which he is allowed to trade. The Client can only buy and sell shares on the market through the Trader who registered him/her.
3. The Trader places the client's buying and selling orders in the stock exchange.
4. The trader also registers feed targets to the Exchange.
5. To access any of the services from the stock exchange, the Trader needs to first login to the Exchange using the Trader's username and password.
6. The Clients get stock quotes (company name, symbol, selling price, high, low), and portfolio information from the Trader. He also deposits money in his account through the Trader.
7. The User (shareholder) can directly gain market information such as total traded shares, average price, and average size of trade from the stock exchange.
8. Trader provides market data updates to the stock exchange.
In summary the services are as follows:
1. Services offered by Stock Exchange to Trader
2. Services offered by Stock Exchange to Client
3. Services offered by Trader to Client
4. Services offered by Trader to Stock Exchange
Note: Attributes of Stock Quote are name, symbol, selling price, high price and low price
Find the "CommodityQuote" sample discussed here in <AS_HOME>/samples/Trader directory. You need Apache Ant to build the sample.
The steps are as follows:
2. In a command prompt, switch to the Trader directory.
For example, cd AS_HOME\samples\Trader
3. From there, type ant.
4. The build resumes and should be completed successfully and a message will be shown accordingly.
5. The build automatically copies the .aar file containing the service into the repository. If you go to Deployed Services in the Application Serve Management Console, you will see the ExchangeTrader, ExchangeClient, TraderClient and TraderExchange services deployed.
If you don't see the services deployed, wait for a while for the deployment engine of Axis2 to pick up the newly added .aar. Then refresh/reload the page.
6. To see the sample services in action, you can use the following syntax on the command prompt.
You can find the run-client.bat and run-client.sh files in the <AS_HOME>/samples/Trader directory.
TraderService URL is the End Point Reference (EPR) of the TraderClient. This can be obtained from the Management Console.
Go to the "Deployed Services" window and click on the service "TraderClient". This will open up its dashboard, where you can find its endpoints. (under services column) > End Points. For this sample the default URLs for the standalone distribution and the embeddable version are as follows:
The same for ExchangeService, according to this example is as follows:
If rm, secure or securerm is to be used, the following modules should be engaged. This can be done by selecting the Engage Module option from the Service Information page for the services listed in the management console.
The options shown above are illustrated using the following samples.
From the "Trader" directory, type the following command.
You should see the following:
Follow the same steps for ExchangeClient service. Then go to <AS_HOME>/samples/Trader directory and type: ./run-client.sh -qos secureYou would see a prompt asking for the username and password before listing the operations available as follows:
Similarly, you can explore the options available in the Trader client and see how it works for yourself.
Trader service internally calls the Stock exchange services. Since the internally-used stubs try to use the configuration of the container by default, engaging QoS on the Stock Exchange service will break the trader sample. Therefore, for the trader sample to run properly, QoS should not be engaged on the Stock Exchange service.
The WSDL files of the services can be found in: <AS_HOME>\samples\Trader\wsdl