Reusing Existing * Java EE Applications from Oracle SOA Suite Guido Schmutz Technology Manager, Oracle ACE Director for FMW & SOA Trivadis AG, Switzerland
Abstract You have a lot of existing Java EE applications. Part of these applications and their logic have a potential to be reused in an SOA. But what is the best practice for reusing such Java EE applications? This session will show different approaches available with SOA Suite 11g in the SCA assembly model as well as with the Oracle Service Bus to reuse existing Java EE artifacts.
Guido Schmutz Working for Trivadis for more than 14 years Oracle ACE Director for Fusion Middleware and SOA Co-Author of different books Consultant, Trainer Software Architect for Java, Oracle, SOA and EDA Member of Trivadis Architecture Board Technology Manager @ Trivadis More than 20 years of software development experience Contact: guido.schmutz@trivadis.com Blog: http://guidoschmutz.wordpress.com Twitter: gschmutz
Trivadis Facts & Figures 11 Trivadis locations with more than 550 employees Financially independent and sustainably profitable Key figures 2010 Revenue CHF 101 / EUR 73 mio. ~180 employees Services for more than 700 clients in over 1 800 projects Over 170 Service Level Agreements More than 5'000 training participants Research and development budget: CHF 5.0 / EUR 3.6 mio ~350 employees ~20 employees
Agenda Introduction What kind of Java EE architectures can we find today? Service Enabling on the Java Layer Service Enabling on the Oracle Service Bus Service Enabling in Oracle SOA Suite Best Practices and Summary
SOA Suite 11g Product-Architecture BPA Suite BPMN EPK UML BPM Suite BPMN Application Integration Architecture (AIA) Foundation Pack Process Integration Pack (PIP) SOA Suite BPEL Business Rule Human Workflow Mediator Spring CEP Oracle Service Bus (OSB) Adapter WebLogic Suite
Customer Create and Submit Order Process Payment Notify User Copy to S3 Customer Download Video SOA Suite 11g Product-Architecture BPA Shared BPMN Model BPMN 2.0, BPEL Rich End User Interaction Web based customization Business View Workspace Process Portal (WC spaces) MS Office BPM Studio (with Business and IT views) B2B BPEL BPMN Human Workflow (+AMX, AG, Orgn) Unified Runtime Business Rules Mediator Process Composer Spring BAM Process Analytics Proc Cubes Optimized binding Common JCA-based connectivity infrastructure Oracle Service Bus Policy Manager EM console +BPMN Screens Repository
Integration Blueprint http://www.packtpub.com/article/trivadis-integration-architecture-blueprint
Principles of Service-Orientation
Contract-First Web Service Design Important for serviceorientation is the standardizing and decoupling of the technical contract of each service Service-oriented design therefore should be based on a contract first approach avoid the use of autogeneration tools Source: Thomas Erl, Principles of Service Design
SOA vs. WOA SOAP-based Services REST Service
Simple Use Case Customer Service Interface in Java Customer and Address DTO
Agenda Introduction What kind of Java EE architectures can we find today? Service Enabling on the Java Layer Service Enabling on the Oracle Service Bus Service Enabling in Oracle SOA Suite Best Practices and Summary
Kind of Java EE architectures Web Applications Servlet, JSP, JSF, POJO With XML over HTTP pre RESTful Spring Applications with/without Messaging POJO, Fat-Client, Client/Server, N-Tier Spring JMS, Spring Integration, Apache Camel EJB (3) Applications with/without Messaging Session Bean, Entity Bean Message Driven Bean (MDB)
Web Applications Servlet, JSP, POJO XML over HTTP HTML over HTTP
Java EE Applications and Messaging Session Bean, Entity Bean, Message Driven Bean, POJO RMI/IIOP RMI/IIOP HTML over HTTP JMS Messaging
Spring Applications and Messaging Spring POJO, JMS Message Listener, Remoting through Exporters XML over HTTP HTML over HTTP Spring JMS Abstraction
Agenda Introduction What kind of Java EE architectures can we find today? Service Enabling on the Java Layer Service Enabling on the Oracle Service Bus Service Enabling in Oracle SOA Suite Best Practices and Summary
Service Enabling Java EE Application Using JAX-WS for SOAP- and JAX-RS for RESTful- WebServices SOAP REST HTML over HTTP XML over HTTP
2 Types of Web Services in Java EE 6 SOAP-based Web Services Provided by JAX-WS aka. Big Web Services (Java EE 6 Tutorial) RESTful Web Services Provided by JAX-RS
JAX-WS for Web Services Since Java EE 5, JAX-WS (JSR 224) the preferred technology to write SOAP web services Prior was JAX-RPC 1.0 (JSR 101) has been pruned in Java EE 6, meaning that it is proposed to be removed from Java EE 7. JAX-WS 2.2 defines a set of APIs and annotations that allow you to build and consume web services with Java depends on other specifications such as Java Architecture for XML Binding (JAXB).
JAX-WS for Web Services Web services rely on the configuration by exception paradigm (like most of new Java EE specs) Only one annotation is needed to turn a POJO into a web service The class must be annotated with @WebService or the XML equivalent in a deployment descriptor. To turn a web service into an EJB endpoint, the class has to be annotated with @Stateless
JAX-WS for Web Services Code First (bottom-up) => contract-last write the Java classes and the data POJOs representing the service (operations and data types) Use JAX-WS to generate the WSDL and XML schema types. often referred to as Java-to-WSDL WSDL First (top-down) => contract-first Create WSDL and XML schemas manually Use JAX-WS tools to generate the Java interface and the data POJOs Implement the generated Java interface through a Java class often referred to as WSDL-to-Java
JAX-WS - Code First Determines XSD Determines WSDL
JAX-WS - Code First WSDL and XSD generated
JAX-WS Code First
JAX-WS WSDL First
JAX-WS WSDL First
JAX-WS WSDL First JAX-WS Annotations JAXB Annotations EJB Annotations Transformation
JAX-WS WSDL First
JAX-WS - Conclusion Code First Easy to get with just a few annotations No control / minimal control over WSDL / XSD No Contract-First design Difficult to govern Do not let your consumers access it directly Apply Legacy Wrapper pattern (i.e. on OSB) WSDL First Full control over WSDL / XSD More work Additional transformation layer needed, might already have DB-to-Entity (JPA) Entity-to-DTO (Java)
JAX-RS for RESTful Services relies heavily on annotations, similar to JAX-WS to specify URI mappings, HTTP headers, content-types and resources POJO-based HTTP-centric Format Independence Container Independence
JAX-RS for RESTful Services POJO with JAXB Annotations Session Bean or POJO with JAX-RS
JAX-RS for RESTful Services
Service Enabling Spring Application Using Spring WS for SOAP- and Spring Web for Restful-WebServices SOAP SOAP REST XML over HTTP HTML over HTTP
Spring-WS Spring-WS is a part of Spring focused on creating documentdriven Web Services Supports only contract-first SOAP service development Based on Spring itself and its concepts, like dependency injection Key features Powerful mappings XML API support (DOM, SAX, StAX, JDOM) Flexible XML Marshalling (JAXB 1 and 2, Castor, XMLBeans, XStream) Supports WS-Security (integrates with Spring Security) Build by Maven
Service Enabling Web Applications Using Spring WS for SOAP- and Spring Web for Restful-WebServices SOAP SOAP REST HTML over HTTP XML over HTTP
Agenda Introduction What kind of Java EE architectures can we find today? Service Enabling on the Java Layer Service Enabling on the Oracle Service Bus Service Enabling in Oracle SOA Suite Best Practices and Summary
Service Enabling on Oracle Service Bus With Web Services in Java Calling SOAP Web Services through HTTP transport Calling Restful WebServices through HTTP Transport Without Web Services in Java EJB Transport In same transaction Using HTTP Transport to talk to XML over HTTP Using JMS transport to send message to MDB With WS interface Integrate directly with the underlying database Custom Transport/JCA Screen scraping, i.e. reuse existing HTML
OSB HTTP Transport to wrap JAX-WS Code First service Problem Want to offer a contract-first SOAP-based Web Service to consumers and not the JAX-WS service Solution Use OSB HTTP Transport to wrap the JAX-WS Code-First service Provide it as a contract-first SOAP web service on OSB Transform from/to canonical model SOAP Webservice
OSB HTTP Transport to wrap JAX- WS Code First service Proxy Service Business Service with HTTP Transport XQuery Transformation Transformation
OSB HTTP Transport to wrap JAX-RS service Problem Want to make a REST Web Service available on the OSB as a contractfirst SOAP-based Web Service Solution Use the OSB HTTP Transport to invoke REST Web Service Provide it as a contract-first SOAP web service on OSB REST Webservice
OSB EJB Transport to call EJB Problem Want to use an EJB session bean directly without having to service enable it first Solution Use OSB EJB Transport to access the existing EJB session bean Provide it as a contract-first SOAP web service on OSB RMI / IIOP Transaction propagation
OSB EJB Transport to call EJB Proxy Service Business Service with EJB Transport
OSB HTTP Transport to call XML / HTTP functionality Problem Want to make an XML over HTTP functionality available as a contract-first style Web Service Solution Use OSB HTTP Transport to call the XML over HTTP service transform the information to/from the service contract Provide it as a contract-first SOAP web service on OSB XML over HTTP
OSB JMS transport to send message to Queue/Topic Problem want to send a message in to a Queue/Topic consumed by an existing application (i.e. MDB) Solution Use the OSB JMS Transport to enqueue message offer that operation as a service to potential consumers (i.e. SOAP-based WS) JMS Enqueue
OSB JMS transport to consume message from Queue/Topic Problem want to consume a message from a Queue/Topic which is sent/published by an existing application Solution Use OSB JMS Transport to dequeue message inform interested application(s) by calling a service (i.e. SOAP-based WS) JMS Dequeue
OSB and DB Adapter for requestdriven access to information Problem Want to directly access data from DB of an existing Java application Solution Use the DB Adapter on the OSB to implement CRUD DB operations Provide it as a contract-first SOAP web service on OSB SQL
OSB and DB Adapter for eventdriven notification of changes Problem Want to have an event-driven push of a message, when something changes in an existing system and inform interested systems Solution Use the DB Adapter to poll a DB table for changes use OSB to send notification messages to interested parties (subscribers) SQL polling
HTTP Transport to reuse existing HTML user interface (screen scraping) Problem Only interface available is a Web application with an HTML user interface. Want to reuse that and make it available as a Web Service? Solution Use OSB HTTP Transport to invoke the HTML interface extract the data out of the presentation logic (HTML) Provide it as a contract-first SOAP web service on OSB HTML over HTTP
Agenda Introduction What kind of Java EE architectures can we find today? Service Enabling on the Java Layer Service Enabling on the Oracle Service Bus Service Enabling in Oracle SOA Suite Best Practices and Summary
Service Enabling on Oracle SOA Suite Similar integration as on OSB EJB Adapter Web Service Adapter to invoke an existing Web Service Socket Adapter JMS adapter to send message to MDB SCA specific integration of Java using Spring component (if available as library) Java Callout in Mediator SDO Service Reuse OSB service through SOA-Direct transport
Using SOA-Direct adapter to invoke an OSB service Problem Want to reuse an OSB services efficiently from a SOA Suite component Solution use SOA Direct adapter call OSB service Use it from any other component within the SCA composite SOA Direct
Using the SCA Spring component Problem Want to reuse Java code based on a Java archive (JAR) Solution Use the SCA Spring Component within an SCA composite to invoke a Spring application from any other SCA component Use it from any other component within the SCA composite
Using the SCA Spring component
Agenda Introduction What kind of Java EE architectures can we find today? Service Enabling on the Java Layer Service Enabling on the Oracle Service Bus Service Enabling in Oracle SOA Suite Best Practices and Summary
Summary Never publish a contract-last service contract directly to consumers Hide it by putting an OSB or Mediator service in between Use a contract-first approach on the interface of the OSB / Mediator service OSB provides an easy intermediary layer for service-enabling existing Java EE EJB applications With additional benefit of advanced mediator features like Throttling, Service Pooling, Transformation, Validation, Enrichment, Split/Join Use the OSB EJB transport to integrate EJB Transaction can be propagated to the EJB layer
My other sessions @ Kscope11 Fault Handling in Oracle SOA Suite 11g, Wednesday 8:30 9:30 Room 203C Best Practices for Designing and Building the Services of a SOA, Wednesday 9:45 10:45 Room 203C
Reusing Existing Java EE Applications from Oracle SOA Suite Please Fill Out Your Evaluations Guido Schmutz Technology Manager, Oracle ACE Director for FMW & SOA Trivadis AG, Switzerland Feedback-URL: http://ezsession.com/kscope