Title: Implementation Case with Java tools and experiences
1Implementation - Case with Java (tools and
experiences)
- Heikki Pakkala, THL
- WP1.8 TG3.1 EuroFIR Web Services
- 3rd Meeting, Florence 2009
2Implementation - Case with Java
- What the Web Services are supposed to do?
- Our Solution stack
- Our Starting points
- From WSDLs to Web Services
- Web Service FCDB
- From FCDB into Java Persistence API (JPA)
- Working with the XML files
- The work flow from request to response
- Some thoughts of test driven development
- How to design for change?
3The big picture
4Implementation with Java solution stack
- (Windows) Tomcat MySQL Java (J2EE)
- Why Java why not?
- Java EE Web Services Technologies (Metro stack)
- Java API for XML-Based Web Services (JAX-WS)
- Java Architecture for XML Binding (JAXB)
- Java Persistence API (JPA), implementation with
Hibernate - Tools
- Eclipse (Myeclipse)
- SoapUI
5Implementation with Java starting points
- Experience with Java still many new things
(like e.g. Web services) - Things can be done with very different ways
- This is not how-to-make-it manual
- Our principles
- Do not reinvent the wheel use frameworks
- Design for change isolate potential change
- Test driven development
6Basic tool Eclipse (Myeclipse)
7Starting with the WSDLs
- WSDLs ? creation of Web Services stubs with
MyEclipse tools - A large set of generated classes
- Creating a common service dispatcher
- Delegation
- authentication
- errors
8FCDB for the Web services 1/3
- FCDB designed specially for Web services
- FCD will be loaded from the production FCDB (new
releases) - Only those entities and fields needed
- FCD translated against TA and FDTP (naming, data
types) - Search intensive structure heavy indexed
- Structures supporting our needs (like e.g.
LanguaL search) - Nothing very special but this structure would
not fit to our FCD storing needs - Some surrogates added to make our life easier
with the Hibernate
9FCDB for the Web services 2/3
10FCDB for the Web services 3/3
- Think ahead the things that you will need!
- Tree traversing is not for SQL
- LanguaL NT (linked with food)
- LanguaL BT search uses tree
- LanguaL tree is created when loading the FCD
- All branches are multiplied for all foods
- This set is SQL compatible
11Java Persistence API (JPA) for FDQL Hibernate
implementation
12JPA Hibernate in action
- OR mapping
- Reverse engineer from Web Service FCDB
- A large set of generated classes
- Database Communication always via Hibernate
- Let Hibernate do all database operations (get the
food and Hibernate will find the rest connected
with it lazy or eager) - HQL or SQL available
13JAXB working with XML files 1/2
14JAXB working with XML files 2/2
- We need the XML schema first
- Bind the XML schema with a JAXB compiler
- A large set of generated classes
- Generate your XML object tree
- Fill it with data
- Marshall it to XML document
- Or
- Generate your XML object tree
- Link it with a document
- Validate document
- Unmarshal data from document to your XML object
tree
- Available XML schemata for FDQL, FDTP, MDTP
- also usable for parameters, term lists etc (do
your own XML schemata)
15Main actions from request to response
- SOAP request receiving
- authentication
- FDQL parsing to XML object (create unmarshall)
- Delegation to the right Web Service and creating
it - Web Service
- FDQL interpretation (possible or not, search
plan) - FDQL translation (mapping with Hibernate objects)
- Query execution to FDQL with Hibernate objects
(HQL, SQL) - Getting the results with Hibernate objects
- Creating the FDTP/MDTP object tree
- Fill the tree from Hibernate objects
- Marshall it to XML document (FDTP or MDTP)
- Put the FDTP or MDTP into SOAP envelope
- Send SOAP response
16Test driven development
- Iteration
- Test cases
- Unit testing
- Writing the test cases sometimes challenging
- Rerun test patterns after changes
17Testing the whole Web Service - soapUI
- Write your own request and see what comes out
- Write test requests
- Mock-up response for development of eSearch
18Design for change ?
- Isolate changing elements interfaces
- Production FCDB and Web Service FCDB
- JPA Hibernate
- WSDLs
- FDQL
- XML schemata
- Actions inside Web Services
- FDTP and MDTP
- SOAP
- Separate generated code (large amount of
generated classes from WSDL, Hibernate and XML
schemata) from written code
19Summary
- What the Web Services are supposed to do?
- Our Solution stack
- Our Starting points
- From WSDLs to Web Services
- Web Service FCDB
- From FCDB into Java Persistence API (JPA)
- Working with the XML files
- The work flow from request to response
- Some thoughts of test driven development
- How to design for change?
- Thank you for your patience!