Step 2. Create JAXB classes

Time to complete this step: 10 minutes

This step demonstrates the JAXB functionality in OEPE by creating JAXB classes from an XML Schema (XSD) file and using them in the Trouble Ticket System projects.

Review the XML Schema(XSD) structure

  1. Create a new folder xsd under the  TroubleTicketSystemServer\WebContent folder. 
  2. Copy the ticketSystem.xsd file from the lab resources to the TroubleTicketSystemServer\WebContent\xsd folder.
  3. Double-click the ticketSystem.xsd file to open with the WTP  XML Schema Editor

  4. The ProductType is a complex type representing the product details like ID, product code, name, and description.

  5. The ProductResultType  is a complex type that has list of products.

  6. The TechnicianType  is a complex type for technician details like ID, password, name and email.

  7. The  TicketType is a complex type that represents a ticket being submitted with details like ID, the product for which it has been submitted, customer details, ticket title, description, date of submission, and ticket state. It also describes the technician details, if its assigned. It holds information about every event being performed on the ticket using TicketHistoryType

  8. The  TicketHistoryType is a complex type describing an event being performed on a ticket, for example, a ticket being assigned or closed. 

  9. The  TicketStateType is a simple type with a restriction that only accepts string of value either NEW or OPEN or ASSIGNED or FIXED or CAN_NOT_FIXED. 

  10. The  TicketResultType  is a complex type for showing a list of tickets. 

  11. The  faultInfo is an element for submitting error detail messages.



Generate JAXB classes based on the XSD 

  1. Right-click the ticketSystem.xsd file and choose WebLogic Web Services > Generate JAXB Types...

  2. If you want to keep the generated ANT script then choose the option Keep generated Ant script. Click Next.

  3. Choose the option Include source code in JAR and click Finish.

  4. The JAR file ticketSystem.xsd.jar is created in the TroubleTicketSystemServer\WebContent\WEB-INF\lib folder.
  5. If you like, you can double click on the  ticketSystem.xsd.jar to view the contents in WinZip in a file explorer window. The Java classes, which are annotated with JAXB annotations, are generated for each type defined in the XML schema.


Click the arrow below to navigate through the tutorial: