Michael Cochez

Assistant Professor at Vrije Universiteit Amsterdam

Web Service Clients

Goal

To know basics of consuming a web service using JAX-WS

Prerequisites:

Task

This assignment contains a programming part and several reflective questions.

In the task you are required to make a simple secretary application which will communicate with web services using the WSDL/SOAP standards.

The WSDL files of the services are located at http://ub1.ad.jyu.fi/people?wsdl and http://ub1.ad.jyu.fi/courses?wsdl. You can open these addresses with your browser to take a look at them. Each WSDL file defines only one service. In a more realistic setting there would be multiple services per WSDL descriptor.

Note: the teacher decided to go with the ‘people’ and ‘courses’ services after all.

The first ‘people’ service defines a service from which you can search for people in the registry. Currently the data in the database is as follows (exactly this data):

ID         First name         Surname     Email    
id1 John Doe jd@jd.com
id2 Peter Caine pc@pc.com
id3 Mary Smith ms@ms.com

The method in the ‘courses’ service defines a way of creating a new course in the system. It returns the ID of the created course. Your task is to make a Java application which is able to communicate with both services.

Your first application must work from the command line and use System.in for input. First, you need to use the wsimport tools to create helper classes which will interact with the published web services. Create the helper classes in the package fi.jyu.it.ties456.week38.services.people and fi.jyu.it.ties456.week38.services.courses (see -p option of wsimport)

Then you can write the application in the class fi.jyu.it.ties456.week38.Main, which needs to have a main method. In the application menu there must be three options : “quit”, “search” and “create”.

  • “quit” quits the application.
  • “search” asks for a search string, performs the search method on the people registry and prints the results. Then the application starts over asking the option from the user.
  • “create” asks all needed input parameters (course name, teacher id (which is assumed to be from the person search), number of credits and a short description). Then the course registration method on the courses web service is called and the application prints the returned course ID. Then the application starts over asking the option from the user.

The second application is a web interface with the same functionality. To implement this, you have to use the Vaadin framework (see https://vaadin.com/home). The website has extensive information about the framework which is based on Google Web Toolkit. Install the eclipse or Netbeans plugin for automatic library management and easy debugging.

The following reflective questions must be answered by each group and the answers must be placed in the readme.md file in the repository.

  • Most REST services do not use WSDL and SOAP. What could be reasons for this?
  • SOAP and WSDL use XML, would it be better if they would use something more modern like JSON?
  • How did you handle errors and how should it be done? Imagine that your application is running on a production server.

Returning the task###

The finished project(s) must be uploaded to the git repository which will be made by the teacher. The repository should contain a short readme.md file which should be formatted using markdown. Also add the answers to the questions to the readme file.

Hints:

  1. Use Eclipse IDE for Java EE Developers from http://www.eclipse.org/downloads/.
  2. Make first the command line app and then the website stuff.
  3. The services will not run anymore after 30 September 2014.
  4. If you want to see an XML file in a “nice form”, open it in your web browser. Most modern web browsers are able to display XML files in a relatively readable form.
  5. Use tools available on the Internet (e.g. WSDL testers, validators, visualizers etc.).
  6. To get some result from the people search service, use search strings that are substrings of strings stored in the database (e.g. “Jo”, “Cai”, “ary”)