We will use this sample to demonstrate the capabilities of WSO2 Web Services Application Server, highlighting the ease of integration of quality of service modules. In the context of this scenario, the use of security and reliable messaging is emphasized on.
The Commodity Quote sample demonstrates the interactions between a simple Web service client & and a CommodityQuote service. This service provides information of chemical agents in d-block of the periodic table.
The following section describes the service in detail.
In this sample, the client queries the CommodityQuote service for the available chemical elements (symbols). Using one of these symbols, the client gets stock quotes from the CommodityQuote service.
Note: attributes of Stock Quote -name, symbol, selling price, high price, low price
Commodity quote sample is in WSO2WSAS_HOME/samples/CommodityQuote. This sample emulates a simple "stock trader", where you can get the stock symbols and the stock quote for a particular stock symbol. In this case the stocks are elements in the periodic table, and stock symbols are the corresponding chemical element symbol.
To build the samples you need the Apache Ant build tool.
cd WSO2WSAS_HOME\samples\CommodityQuote
ant
Buildfile: build.xml clean: init: [mkdir] Created dir: C:\wso2wsas-2.0\samples\CommodityQuote\temp [mkdir] Created dir: C:\wso2wsas-2.0\samples\CommodityQuote\temp\classes [some lines deleted here] build-all: [echo] Copying the created aar files in to the repository [copy] Copying 1 file to C:\wso2wsas-2.0\repository\services BUILD SUCCESSFUL Total time: 11 seconds
The build automatically copies the .aar file containing the service into the repository.
(See Administrator’s Guide on how to sign into the Management Console and to navigate through it.)
On MS Windows:
run-client.bat [ -qos (rm|secure|securerm)] [ -e CommodityQuoteServiceURL]
On Unix/Linux:
run-client.sh [ -qos (rm|secure|securerm)] [ -e CommodityQuoteServiceURL]
Terms used:
In addition to that mail transport can also be used. In mail transport there should be two mail addresses to identify the client and server. Those are the EPRs needed to communicate. A mail server should be used in this case and two accounts should be created (A mail server like JAMES can be used for this purpose). One should correspond to WSO2 WSAS and the other one should correspond to the client. In addition to that Client's axis2.xml and server's axis2.xml should be configured to do SMTP and pop according to the mail server used. Here the EPR should be given as "mail:<mail id corresponds to the server>@localhost/services/CommodityQuote". More details will be discussed later in this document.
Note: Some of the scenarios listed above need provision for unlimited security jurisdiction. This will basically be couple of Jar files, which will be available at Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files. Download jce_policy-x_y_z.zip (relevant to your JDK version) and extract the jar files local_policy.jar and US_export_policy.jar to $JAVA_HOME/jre/lib/security.
From CommodityQuote directory type:
$ sh run-client.sh
You should see:
STARTING COMMODITY QUOTE SAMPLE CLIENT ============================= Sample will be invoked using following parameters .. CommodityQuoteService Endpoint reference : http://127.0.0.1:9762/services/CommodityQuote Please select your operation... --------------------------------- (1) getQuote (2) getSymbols (3) Exit :
From CommodityQuote directory type:
$ sh run-client.sh -qos secure
STARTING COMMODITY QUOTE SAMPLE CLIENT ============================= Enter security scenario [1 - 10]... {select a value between 1 to 10}
STARTING COMMODITY QUOTE SAMPLE CLIENT ============================= Enter security scenario [1 - 10]... 1 Client will be tuned to work on security scenario : 1 Please enter your username : client Please enter your password : testing Sample will be invoked using following parameters .. CommodityQuoteService Endpoint reference : https://127.0.0.1:9443/services/CommodityQuote Quality of Service : secure Please select your operation... --------------------------------- (1) getQuote (2) getSymbols (3) Exit :2 ...Getting symbols... Results ------- mn tm zn cf au yb mo pd po ra rf v uuu ds rb as u sr rh fr ar se ti no w zr sm ni al mg la hs cd nd y si rn gd uub ce i bi ge cs kr mt s tb be lr bh he sb sn uuh hf sc hg br ta pm k cl p pr ac th ru tc cr ha tl in ag b os f ga fe am dy ba pb ne ir pu c h te es np uuq sg ca fm cu pt pa eu ho o er md bk lu na cm at nb db re li co n xe
STARTING COMMODITY QUOTE SAMPLE CLIENT ============================= Enter security scenario [1 - 10]... 2 Client will be tuned to work on security scenario : 2 In this demonstration, client will use client.jks and server should use service.jks. Sample will be invoked using following parameters .. CommodityQuoteService Endpoint reference : http://127.0.0.1:9762/services/CommodityQuote Quality of Service : secure Please select your operation... --------------------------------- (1) getQuote (2) getSymbols (3) Exit :1 ...Getting Quote... Please enter the symbol:xe Results ------- Name :xe Symbol :Xenon High value :0.0 Low value :0.0 Price :24.0 Please select your operation... --------------------------------- (1) getQuote (2) getSymbols (3) Exit :
From CommodityQuote directory type:
$ sh run-client.sh -qos rm -e http://127.0.0.1:9762/services/CommodityQuote or $ sh run-client.sh -qos rm
STARTING COMMODITY QUOTE SAMPLE CLIENT ============================= Sample will be invoked using following parameters .. CommodityQuoteService Endpoint reference : http://127.0.0.1:9762/services/CommodityQuote Quality of Service : rm Please select your operation... --------------------------------- (1) getQuote (2) getSymbols (3) Exit :
From CommodityQuote directory type:
$ sh run-client.sh -qos securerm
As you will be able to see, with the rm option, the time to receive the response for the very first request will be comparatively larger. This is due to the control messages that are sent initially, in order to establish the reliable messaging channel.
Try playing around with the above options and see how it works for yourself!
© 2007 WSO2 Inc.