This page details the steps necessary to create a client, using eclipse, that is able to communicate with the holiday web service.
1. Create a new project using eclipse
2. Go to Run Configurations
- a. Under Java Applications -> main tab
- i. Set main class to: org.apache.axis.wsdl.WSDL2Java
- ii. Set Project to whatever project you created
- iii. Set name to whatever name you want.
- b. Under Java Applications -> arguments tab
- i. Set Program Arguments to: http://localhost:8080/holidayWebService/services/holiday?wsdl -o src (The url location for the wsdl)
- c. Under Java Applications -> classpath tab
- i. Add in latest jars for:
- activation.jar
- axis.jar
- commons-discovery.jar
- commons-logging.jar
- commons-net.jar
- jaxrpc.jar
- jaxrpc-api.jar
- mail.jar
- saaj.jar
- wsdl4j.jar
- (also add these jars to the buildpath, these jars are available in the misint -> holidayWebService repository in the HolidayServiceClient Project)
- i. Add in latest jars for:
NOTE: When creating a client for the test server it is required that you add the test site's certificate to the keystore as described here,
and then run the project with arguments (In Eclipse these should be added to the VM arguments of your project's run
configuration):
-Djavax.net.ssl.trustStore=/path/to/keystore
-Djavax.net.ssl.trustStorePassword=changeit (default password is changeit)
3. Ensure the web service is running, and then run the project. This should generate the necessary files for creating a client.
PKIX path building error:
IF there is a PKIX path building failed: SunCertPathBuilderException the web services security certificate has not been added to Java's cacerts file (file of trusted websites). This is required as our test servers are using a self-signed certificate which is not viewed as a valid certificate by Java.
Adding the certificate can be done as described here.
This could also be because you are not running the project with the arguments:
-Djavax.net.ssl.trustStore=/path/to/keystore
-Djavax.net.ssl.trustStorePassword=changeit (default password is changeit)
4. Create a main method
/**
* Simple sample of main method, it queries the web service for the closest observed holiday to January 1st, 2012.
*/
public static void main(String[] args) throws MalformedURLException
{
HolidayService service = new HolidayServiceLocator();
Calendar newYears = Calendar.getInstance();
// Error with grails calendar. If hour is above 12 then the day will be wrong, so set hours, minutes, seconds to zero to be on safe side.
newYears.set(Calendar.getInstance().get(Calendar.YEAR), Calendar.JANUARY, 1, 0, 0, 0);
try
{
Holiday closest = service.getHolidayServicePort().getClosestHoliday(newYears, true, true);
String name = closest.getDescription();
assert("New Year's Day".equals(name));
}
catch (Exception e)
{
System.out.println(e.toString());
}
}The Holiday Web Service has support for two different modes of communication.
The first way is through the REST architecture. The holiday application supports the RESTful scheme and allows parameters for the web methods to be passed in through the url. An example of this, is if you wanted to get the closest holiday to 2012-01-10 you would query the service by going to the url: https://www.test.hawaii.edu/its/ws/holiday/rest/closest?date=2012-01-10
The second way is through the use of a WSDL. A client application can be quickly setup by using wsdl2java which utilizes the wsdl that is setup by the holiday application.