- Create a new web project Publisher
- Create a new java bean class domain.Address with properties street, number, postalCode, City
- Create a new java bean class domain.Publisher with properties id, name, address
- Make sure JAXB can convert this bean from/to XML
- Create a new Soap WebService service.PublisherService. Do not wrap the service in a SessionBean (it will work as a servlet)
- We will not save the data to a database. To store the publishers in memory, add this attribute to PublisherService
- Add a webservice method create(String name,Address address) to the PublisherService
- In the method create a new Publisher. For the id, take the size of the publisherDao + 1.
-
Add the Publisher to the publisherDao map. Use its id as the key in the map.
-
Add a webservice method querySingle(int id). It should return the publisher with this id.
-
Add a webservice method QueryAll. It should return all publishers
-
Test and correct any errors
- Make sure a SOAP Fault is returned when creating a publisher with invalid parameters
-
Advanced (Optional)
- Customize the Fault to add a detail child element with one
or more reasons explaining why the creation failed.
<detail> <canNotCreatePublisher > <reason>No address</reason> <reason>No name</reason> <canNotCreatePublisher> </detail>
Note: the canNotCreatePublisher element may contain some extra namespace information.
- Make an ErrorInfo bean class that contains a list of reasons. Make sure objects of the class can be transferred from/to XML using JAXB
- Make a CreateException class that inherits from Exception. The class should have an attribute
private ErrorInfo faultInfo; - Add accessor methods for the attribute and a constructor with the attribute as an argument
- Add an @WebFault annotation to the CreateException class
- In the create webservice check for the validity of the parameters. If there are invalid parameters throw a CreateException with an error message for each invalid parameter.
- Customize the Fault to add a detail child element with one
or more reasons explaining why the creation failed.
private static Map<Integer,Publisher> publisherDao = new HashMap<Integer,Publisher>();
No comments:
Post a Comment