7 September 2018

RD EE6 webservices module 10: lab cookbook

  1. Start from the BookOrderWSService.wsdl in the lab directory
    1. OR (Alternative):
      1. start from the order.wsdl you created in module 3
      2. modify the order ComplexType to match the exercise instruction
      3. modify the orderId SimpleType to String
  2. Generate java classes from the WSDL
    1. Create a src and class directory
    2. run wsimport in the location where you have created these folders. wsimport should
      1. generate all classes in the service package
      2. put generated .class files in the class directory
      3. put generated  .java files in the src directory
  3. Create a new Java Web Application project called bookOrder
  4. Copy the wsimport files to your project
    1. copy the src/service directory to the src directory of your project
    2. Move the bookOrder class to a newly created package domain
    3. Make a new directory wsdl in the WEB-INF directory (WEB-INF is under Web Pages) and copy the WSDL you obtained in step 1 here.
  5.  Add constructors to domain.Orders
    1. add a constructor that takes all attributes as parameters
    2. add a constructor without parameters
  6. Implement the BookOrderService interface in a class BookOderWS
  7. Add these extra attributes
    • endpointInterface
    • wsdlLocation = "WEB-INF/wsdl/BookOrderWSService.wsdl"
    • serviceName
    • portName
    • targetNamespace
  8. Add a static Map to BookOrderWS , which will act as a datastore: 
    1. private static Map<String,Order> orderDao = new HashMap<String,Order>();
      
    2. add a static block to the class in which you add some test data to orderDao. Use the orderID from the Order also as a key in the Map.
  9. Implement the orderBook method.
  10. Test and correct until everything works

No comments:

Post a Comment