/CurrencyConversionWebService

Assignment work for Web Services course

Primary LanguageJava

CurrencyConversionWebService

Assignment work for the Web Services course.

A complete client and sample service package that uses web services to perform arbitrary currency conversion. The client contains a file handler for reading records from a file (e.g. an invoice file) to be converted to other currencies.

Includes 3 Eclipse projects

  1. Currency Converter Web Service – A sample POJO web service based on Apache Axis2, that can be accessed by the client.

Provides the following services:

  • Get the list of supported currencies
  • Convert a value from one currency to another
  • Convert a list of values from one currency to another
  • Convert a value from one currency to every other currency supported

The service can be accessed by both SOAP and REST techniques (i.e. direct HTTP request bindings provided).

  1. Currency Converter Client – A full fledged client that peruses the above web service to perform the currency conversion. It generates alternate versions of the supplied invoice file in all the other supported currencies (so far AUD, USD and EUR).

Both SOAP and REST versions of the client program are provided. The REST client also generates encrypted versions of the output invoice files.

  1. Currency Converter Client Live – A version of the previous client program that connects to a live web service on Cloanto.com.

Both SOAP and REST versions of the client program are provided. The REST client also generates encrypted versions of the output invoice files.

Instructions for Execution

  1. For the Web Service:

Either deploy the .AAR file from the build directory into your Axis2, or Run build.xml (customize your server information for Axis2) to generate your .AAR archive. Next, upload the archive to Axis2.

  1. For the Client:

Change the contents of the invoice.txt file as needed, or, provide the invoice file path as a command line parameter to the program mentioned below. Change the web service url in build.properties and in config.properties if needed. Execute the class client.InvoiceConverterSOAP or client.InvoiceConverterREST as Java applications depending on whether you'd like to use SOAP or REST protocols. Observe the new invoice files generated by the class.

  1. For the Live Client:

Make sure you are connected to the Internet. Change the contents of the invoice.txt file as needed, or, provide the invoice file path as a command line parameter to the program mentioned below. Observe the new invoice files generated by the class.

Structure of the File

The invoice file is assumed to have the following structure:

  1. The first line, called the directive, mentions the name of the currency somewhere (anywhere!).
  2. The subsequent lines are csv records with arbitrary fields, such as names, except the last field being the monetary amounts.

Output

The client program reads the invoice file and generates new files with converted currencies. For example, if the invoice file contains values in AUD, the client will generate invoice_USD.txt and invoice_EUR.txt files as output, which will contain the converted amounts at the right places.

Encryption

The REST clients also generate an encrypted version of the output files with the name invoice_USD_encrypted.txt for example.

Encryption uses the DES algorithm. If required, the encryption key generated during this process can be saved in invoice_USD_encrypted_key.txt file for later decryption by setting the appropriate configuration parameter as described in the next section. Information for the algorithm has been sourced from the Java2s Tutorial on Security.

Other features

The clients are configurable via the config.properties file, which helps reduce "hard codes" in the program.

Additionally, verbose outputs can be turned on by setting the debug mode to on (true).

The list of parameters available are:

debugging: set to true to enable verbose output (default: false) invoice.file.name: name of the invoice file. It is used as a prefix for all generated output files (default: invoice) invoice.file.extension: extension of invoice file. The same extension is used by all generated output files (default: txt) invoice.file.encrypted.suffix: suffix added to all encrypted output files (default: encrypted) invoice.file.encrypted.storeKey: set to true to save the cipher key into a file for later decryption (default: false) service.url.soap: URL for the web service's SOAP binding interface (default: http://localhost:8080/axis2/services/CurrencyConversionService) service.url.rest: URL for the web service's REST binding interface (default: http://localhost:8080/axis2/services/CurrencyConversionService)