To know basics of consuming a web service using JAX-WS
- Learn what a WSDL file is. There is no need to know every detail, just the big picture. In practical use you will learn the details which you need. http://en.wikipedia.org/wiki/WSDL
- Learn the idea behind the wsimport tool : http://www.mkyong.com/webservices/jax-ws/jax-ws-wsimport-tool-example/
- Basically: wsimport converts a WSDL file to Java classes.
- Full documentation about the tool from http://jax-ws.java.net/jax-ws-ea3/docs/wsimport.html
- To communicate with the WSDL services SOAP messages will be used. Most of this will be hidden to you because of the use of wsimport. However, it might be useful to have an idea what happens behind the scenes. Therefore, if you are interested, you could read http://www.w3schools.com/webservices/. Read the parts about Web Services, SOAP and WSDL. Knowledge about RDF is not needed in this course.
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):
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.
- Use Eclipse IDE for Java EE Developers from http://www.eclipse.org/downloads/.
- Make first the command line app and then the website stuff.
- The services will not run anymore after 30 September 2014.
- 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.
- Use tools available on the Internet (e.g. WSDL testers, validators, visualizers etc.).
- 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”)