Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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
  • 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)

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 then most likely the web services security certificate has not been added to Java's cacerts file (file of trusted websites).
The solution is described in the below website.http://magicmonster.com/kb/prg/java/ssl/pkix_path_building_failed.html

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());
  }
}