About
This article offers some guidelines and pointers on how to use Metro Web Services library to connect to VIP Products. Please don't deploy the source code in this page as it is in your production environment without understanding the limiations and security issues.
What is Metro?
Metro is a web service libary. A stable version (possibly old version) is distributed along with Oracle's JDK versions. It can also be downloaded from https://metro.java.net/. You can find links to both user guide and reference here.
Pre-requisites
For the demo purposes, I will not be relying on the latest and greatest version of Metro that is available in the Metro web site. I will be making use of the distribution that comes as a part of standard JDK. This minimizes the external dependencies.
This demo depends on JDK 1.7 or above. All the samples in the attachment were tried in 1.7.0_51.
Please download the vip-metro-sample.zip (attached with this page). Unzip it and import the contents in your favorite IDE. I developed and tested my project in IntelliJ. You can easily import the project in Eclipse as well.
Compiling the WSDLs and XSDs
After importing the attached source, go under the extras/scripts directory. You will find a script called compile-wsdl.sh. You should run this script to compile the WSDLs/XSDs that are located under extras/wsdls.
Customizing the TestClient
There is a TestClient.java file in the project that explains how to use Metro as a client. Please look for the FIXME statements in that file and enter the correct value for those parameters. Once you have customized them, you can run the TestClient.java file.
A quick walk-through of the code
The TestClient first creates an SSLContextFactory. Either you can create the SSLContextFactory programmatically, or you can use a mechanism like Spring application context.
After SSLContextFactory is created, an SSLContext is created from the factory. Then it is used while communicating with the VIP User Services.
Pros and cons
The most important adavantage is that you can use as many key stores as you want within the same program. You can create different factory instances for each key store.
There is no external dependency (like Axis 2). It is fairly straight forward and easy to follow the code.
You have to package the WSDL/XSD files along with the program (may be inside your jar file). Typically Axis 2 doesn't require the original WSDLs/XSDs during run time.
Disclaimer
This program is for illustrative purposes only. Please test thouroughly for correctness and performance before you use this code in your production environement.