BBuuiillddiinngg SSeerrvviiccee-- OOrriieenntteedd AArrcchhiitteeccttuurreess wwiitthh JJaavvaa TTeecchhnnoollooggyy

DDeecceemmbbeerr 55 -- 66,, 22000077 PPoorrttllaanndd && SSeeaattttllee

Tom Barrett SOA/BI Technical Specialist SCJP, SCJD, SCWCD, SCEA – Dallas [email protected] Agenda

• Registration/Appetizer - Beverage Buffet (4:00 - 4:15) • SOA Defined (4:15 - 4:30) • SOA Technologies (4:30 – 5:30) • Integration Framework: Business Integration (JBI) (5:30 – 6:15) • Open Source Implementation: Open ESB (6:15 – 6:45) • Wrap-up / Resources (6:45 - 7:00)

2 Agenda

• Registration/Appetizer - Beverage Buffet (4:00 - 4:15) • SOA Defined (4:15 – 4:30) > What's the problem? > What is SOA? > How is it being implemented? • SOA Technologies (4:30 – 5:30) • Integration Framework: Java Business Integration (JBI) (5:30 – 6:15) • Open Source Implementation: Open ESB (6:15 – 6:45) • Wrap-up / Resources (6:45 - 7:00)

3 What's the Problem? Accidental Architecture

Credit Card Mortgage

Balance Fraud Credit Credit Balance Interest Check Detection Check Check Check Calc

Customer Back- Partner Partner Back- Customer Data End Credit Credit End Data System Data Data System 4 What's the Problem? Services-Oriented Architecture

Auto Mutual Loans Bill Pay Stocks Funds Composite Applications

Credit Card Mortgage Reusable Services Payment Trade Credit Fraud Access Interest Balance Customer Execution Management Check Detection Service Check Data Service Service Calc Service

Internet Increased Agility

Partner Credit Data Back-End System Back-End System Customer Data

5 What's the Problem? IT is Limiting the Business

• Inflexibility of IT Infrastructure • Complexity of Integration Projects • Integration Costs • Time to Market • Limited Partnering Flexibility

6 Agenda

• Registration/Appetizer - Beverage Buffet (4:00 - 4:15) • SOA Defined (4:15 – 4:30) > What's the problem? > What is SOA? > How is it being implemented? • SOA Technologies (4:30 – 5:30) • Integration Framework: Java Business Integration (JBI) (5:30 – 6:15) • Open Source Implementation: Open ESB (6:15 – 6:45) • Wrap-up / Resources (6:45 - 7:00)

7 What is SOA? Wikipedia Definition • Evolution of distributed computing and modular programming • Build applications out of software services that are: > Relatively large-grained (like: Fraud Detection, Payment Management, Trade Execution) > Intrinsically unassociated units of functionality (no embedded calls to other services) • Protocols are defined which describe how services can “talk” to each other • Relies on a business process expert to sequence services (orchestrate) to meet business needs

http://en.wikipedia.org/wiki/Service-oriented_architecture 8 What is SOA? Sun Definition • Track-tested architectural style for building applications using services available in a network (“The Network is the Computer”) • Promotes loose-coupling between software components • Service implements a well-defined business functionality • Implementation is shielded by a public interface definition (signature / contract) • Services form building blocks of SOA applications • Composite applications can be built by aggregating services • Open standards have emerged to support web services implementation

http://java.sun.com/developer/technicalArticles/WebServices/soa/ 9 What's is SOA? Catalyst • Business: “SOA is a catalyst for business transformation enabling your business to thrive on change ... SOA is a technology-based embodiment of your business” • IT: “IT must change its primary operating mode from delivering applications to a mode of delivering strategic business flexibility...”

10 Agenda

• Registration/Appetizer - Beverage Buffet (4:00 - 4:15) • SOA Defined (4:15 – 4:30) > What's the problem? > What is SOA? > How is it being implemented? • SOA Technologies (4:30 – 5:30) • Integration Framework: Java Business Integration (JBI) (5:30 – 6:15) • Open Source Implementation: Open ESB (6:15 – 6:45) • Wrap-up / Resources (6:45 - 7:00)

11 How is SOA Being Implemented? Enterprise Service Bus (ESB) “An ESB is a Web-services-capable middleware infrastructure that supports intelligent program-to-program communication and mediates the relationships among loosely-coupled (SOA) and uncoupled (event-driven) business components.”

- Roy Schulte

Service-Oriented Architecture Event-Driven Architecture 12 How is SOA Being Implemented? ESB Characteristics

• Typically implemented within one enterprise • Serves as an enterprise architecture where business services are developed with SOA in mind • Supports web services standards • Scales to enterprise-class performance • Fosters service and protocol pluggability • Provides development, deployment and management tools • Provides value-added technical services

13 How is SOA Being Implemented? ESB Value-Added Services

Resource Channel Adapters Adapters

Security Synchronization S e r rs Logging Correlation v e i c d i e v

Messaging C o Monitoring o Pr n

s e Alerting Communication u c i m v r e

Transactions Transformation r s Se Routing BPM Load Balancing BAM

14 How is SOA Being Implemented? Gartner Perspective

User Vendor Extensible Assemblies Suites Suites (Best of Breed) (Application Platform Suites) (Modules)

1990 2000 2010

Source: Gartner Inc., " The Battle for Platform Domination: Application Servers, SOA and Platforms Suites", Y. Natis, December 2006 15 How is SOA Being Implemented? Slowly and Cautiously Accidental Layered Rigid Extensible Silo-Oriented Service-Oriented

Access Process Service Resource

• Old approaches are deeply entrenched • SOA demands better linkages between IT and business units • Standards are still evolving • New technologies can be daunting 16 Agenda

• Registration/Appetizer - Beverage Buffet (4:00 - 4:15) • SOA Defined (4:15 – 4:30) • SOA Technologies (4:30 – 5:30) > Web Services for service delivery > Business Process Execution Language (BPEL) for orchestration • Integration Framework: Java Business Integration (JBI) (5:30 – 6:15) • Open Source Implementation: Open ESB (6:15 – 6:45) • Wrap-up / Resources (6:45 - 7:00)

17 SOA Technologies Web Services: Definition

• "A software system designed to support interoperable machine to machine interaction over a network." (W3C) • Clients and servers communicate using XML messages formatted ● SOAP (Simple Object Access Protocol): per the SOAP standard XML-based, message envelope format • WSDL description of the supported ● WSDL (Web Services Description Language): XML format for describing service interfaces. operations is available to the client Typically used to generate server and client code, and for configuration ● UDDI (Universal Description Discovery and Integration): protocol for publishing and discovering metadata about Web services

http://en.wikipedia.org/wiki/Web_services 18 SOA Technologies Web Services: WSDL – Interface Definition Language

> WSDL (Web Service Description Language) is a cornerstone for web services- based SOA implementations > W3C recommended standard way of defining an interface for web services > XML document describing network services as a set of endpoints > Endpoints are gateways for messages containing either document-oriented or procedure-oriented information > Endpoints described in abstract terms as operations which are bound to a concrete network protocol and message format

19 SOA Technologies Web Services: WSDL (Abstract vs. Concrete)

Abstract

Concrete

20 SOA Technologies Web Services: XSD Example

XML Schema Definition (XSD)

21 SOA Technologies Web Services: WSDL Example - Messages

● Describes messages used by the web service ● Provides the data elements used by operations

22 SOA Technologies Web Services: WSDL Example - Operations

● Describes operations that can be performed and the messages passed ● Specifies multiple message elements to define a one-way or round-trip operation

23 SOA Technologies Web Services: WSDL Example – On the Wire

● Shows concrete specifics of how the service is implemented on the wire ● Defines message format and protocol details for each operation ● Transport declares how SOAP message will be sent ● Style specifies format of SOAP message

24 SOA Technologies Web Services: WSDL Example - Location

● Declares the address for invoking the service ● Usually provides a URL for invoking via SOAP

25 SOA Technologies Web Services: SOAP Example

SOAP Messages

26 SOA Technologies Web Services: WSDL for Interface Design

• Point my IDE at the service endpoint (http://localhost:8080/CalculateLoanPayment/CalculatePaymentServiceService?wsdl) • Tool automatically generates required client code to send and receive a SOAP message using the endpoint • Use the generated client component: > Provide it the inputs that the WSDL specified > Execute it > Use the delivered output specified in the WSDL

27 SOA Technologies Web Services: Interoperability

WS-I Basic Profile • Specification from the Web Services Interoperability industry consortium (WS-I) • Provides interoperability guidance for SOAP, WSDL and UDDI • Version 1.0 appeared in 2004, 1.1 finalized in 2006 • Sample guidelines: > R1141 A MESSAGE MUST be sent using either HTTP/1.1 or HTTP/1.0. > R1140 A MESSAGE SHOULD be sent using HTTP/1.1. > R1132 A HTTP request MESSAGE MUST use the HTTP POST method. > R9980 An ENVELOPE MUST conform to the structure specified in SOAP 1.1 Section 4, "SOAP Envelope" > R1015 A RECEIVER MUST generate a fault if they encounter an envelope whose document element is not soap:Envelope.

28 SOA Technologies Web Services: Interoperability Web Services Interoperability Technologies (WSIT) • Web services interoperability effort to develop Java clients and service providers that interoperate with Microsoft .NET clients and service providers • Focuses on selected facets of WS-* to help customers that have large investments in both Java an .NET • Now offered as “Metro”: > JAX-WS reference implementation > WSIT

https://wsit-docs.dev.java.net/releases/m5/WSITTutorial.pdf 29 SOA Technologies Web Services: Demonstration Scenario • Build two web services: > DetermineRateService (EJB module) > CalculatePaymentService (web module) • Deploy modules to application server • View generated schema definitions and WSDLs • Test web services loanType (String) interestRate (String) DetermineRate Service interestRate (double) loanAmount (double) periodInYears (int) monthlyPayment (double) CalculatePayment Service 30 REST Definition

"Representational State Transfer is • REpresentational State Transfer intended to evoke an image of how a • Architectural style defining rules for well-designed Web application behaves: - A network of web pages (a virtual defining and addressing resources state-machine) - Where the user progresses through an • Each resource is uniquely application by selecting links (state addressable as a URI transitions) - Resulting in the next page (next state • Client/server, stateless and of the application) being transferred to cacheable the user and rendered for their use." - Roy Fielding • No protocol is assumed, but HTTP (REST inventor) is usually involved

http://en.wikipedia.org/wiki/REST http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm 31 REST Definition: Example - Parts Depot

• Get Parts List > Sends: http://www.parts-depot.com/parts > Receives: Each hyperlink traversal puts the application into a different state • Get Detailed Parts Data > Sends: http://www.parts-depot.com/parts/00345 > Receives: 00345 Widget-A This part is used within the frap assembly 0.10 10 Building Web Services the REST Way Roger L.Costello -- http://www.xfront.com/REST-Web-Services.html 32 REST Definition: Benefits

• Improves response times and server loading due to caching • Improves server scalability by reducing need to maintain state • Requires less client-side software because a browser can access any application and any resource • Doesn't depend on additional messaging frameworks atop HTTP • Provides equivalent functionality to alternatives (SOAP) • Does not utilize a separate resource discovery mechanism due to the use of hyperlinks in content

http://en.wikipedia.org/wiki/REST 33 SOA Technologies Web Services: REST Adoption

• “Over the past 2.5 years, the REST/SOAP call ratio to AWS (Amazon Web Services) has held pretty constant at 80/20.” http://www.jeff-barr.com/?p=96 (November 2004)

• “Q: Does Yahoo! plan to support SOAP? A: Not at this time. We may provide SOAP interfaces in the future, if there is significant demand. We believe REST has a lower barrier to entry, is easier to use than SOAP, and is entirely sufficient for these services.” http://developer.yahoo.com/faq/

34 SOA Technologies Web Services: Tim Bray on REST Adoption

http://www.tbray.org/ongoing/When/200x/2006/04/17/SOA-or-not

• What do you think we should do about SOA? > “Don't do anything. 'SOA' may have meant something once but it's just vendor b!ul#h%t now.” > Architects thought “web” made “web services” sound lightweight and too easy to set up > So, they got uncomfortable and made web services more “Enterprisey” > “Web” part is more important than “services” part so “SOA isn't the future, Web style is”

35 SOA Technologies Rest Tooling: A Little Awkward from Java public class Artist extends HttpServlet {

public enum SupportedOutputFormat {XML, JSON};

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String accept = request.getHeader("accept").toLowerCase(); See if accept header String acceptableTypes[] = accept.split(","); should be processed SupportedOutputFormat outputType = null; as XML or JSON for (String acceptableType: acceptableTypes) { if (acceptableType.contains("*/*") || acceptableType.contains("application/*") || acceptableType.contains("application/xml")) { (JavaScript Object outputType=SupportedOutputFormat.XML; Notation) break; } else if (acceptableType.contains("application/json")) { outputType=SupportedOutputFormat.JSON; break; } } if (outputType==null) response.sendError(415); Unsupported Media Type String path = request.getPathInfo(); String pathSegments[] = path.split("/"); Parse the pathInfo String artist = pathSegments[1]; if (pathSegments.length < 2 && pathSegments.length > 3) response.sendError(404); Not Found else if (pathSegments.length == 3 && pathSegments[2].equals("recordings")) { URL specifies “recordings” so if (outputType == SupportedOutputFormat.XML) writeRecordingsForArtistAsXml(response, artist); deliver recordings in response else writeRecordingsForArtistAsJson(response, artist); } else { if (outputType == SupportedOutputFormat.XML) writeArtistAsXml(response, artist); If not “recordings”, then deliver else writeArtistAsJson(response, artist); artist information is response } } private void writeRecordingsForArtistAsXml(HttpServletResponse response, String artist) { ... } private void writeRecordingsForArtistAsJson(HttpServletResponse response, String artist) { ... } private void writeArtistAsXml(HttpServletResponse response, String artist) { ... } private void writeArtistAsJson(HttpServletResponse response, String artist) { ... } } JSR 311:JAX-RS: The Java™ API forRESTful Web Services (TS-6411) Marc Hadley, Paul Sandoz, Roderico Cruz Java One 2007 http://blogs.sun.com/sandoz/resource/TS-6411.pdf 36 SOA Technologies Rest Tooling: A Better Way • Goals > High level expression > Declarative > Clear mapping to REST concepts > Generates the boilerplate code • Approach > JAX-RS: Java API for RESTful Web Services > JSR 311 (Draft April 2007) > Jersey is open source reference implementation

JSR 311:JAX-RS: The Java™ API forRESTful Web Services (TS-6411) Marc Hadley, Paul Sandoz, Roderico Cruz Java One 2007 http://blogs.sun.com/sandoz/resource/TS-6411.pdf 37 SOA Technologies Rest Tooling: Early Look at JAX-RS

@UriTemplate("/artists/{id}") @ProduceMime("application/xml") public class Artist { @HttpMethod InputStream getXml(@UriParam("id") String artist) { ... } @HttpMethod @ProduceMime("application/json") InputStream getJson(@UriParam("id") String artist) { ... } @HttpMethod @UriTemplate("recordings") InputStream getRecordingsXml(@UriParam("id") String artist) { ... } @HttpMethod @ProduceMime("application/json") @UriTemplate("recordings") InputStream getRecordingsJson(@UriParam("id") String artist) { ... } }

JSR 311:JAX-RS: The Java™ API forRESTful Web Services (TS-6411) Marc Hadley, Paul Sandoz, Roderico Cruz Java One 2007 http://blogs.sun.com/sandoz/resource/TS-6411.pdf 38 Agenda

• Registration/Appetizer - Beverage Buffet (4:00 - 4:15) • SOA Defined (4:15 – 4:30) • SOA Technologies (4:30 – 5:30) > Web Services for service delivery > Business Process Execution Language (BPEL) for orchestration • Integration Framework: Java Business Integration (JBI) (5:30 – 6:15) • Open Source Implementation: Open ESB (6:15 – 6:45) • Wrap-up / Resources (6:45 - 7:00)

39 Agenda

• Registration/Appetizer - Beverage Buffet (4:00 - 4:15) • SOA Defined (4:15 – 4:30) • SOA Technologies (4:30 – 5:30) > Web Services for service delivery > Business Process Execution Language (BPEL) for orchestration • Integration Framework: Java Business Integration (JBI) (5:30 – 6:15) • Open Source Implementation: Open ESB (6:15 – 6:45) • Wrap-up / Resources (6:45 - 7:00)

40 SOA Technologies BPEL: Definition • XML-based language for formally describing business processes and business integration • Extends web service interactions to support orchestration and long- running business transactions • History: > Inspired by IBM’s Web Services Flow Language (WSFL) and Microsoft’s XLANG > BPEL4WS (Business Process Execution Language for Web Services) was first conceived in July 2002 with the release of the BPEL4WS 1.0 specification, a joint effort by IBM, Microsoft and BEA > Evolved into WS-BPEL 2.0 in April 2007, as a standard now managed by OASIS (Organization for the Advancement of Structured Information Standards) • Prerequisites for personal success: > XML > WSDL > Programming experience

41 SOA Technologies BPEL: Example

Oh my, sorta scary

https://blueprints.dev.java.net/bpcatalog/ee5/soa/index.html 42 SOA Technologies BPEL: Example

Code folding makes this a little more approachable, still scary though

43 SOA Technologies BPEL: Example

When the purchase order service receives the client request, the following activities are performed: 1 Purchase order service provider assigns the price for the request 2 Purchase order service provider invokes the inventory service to check inventory status 3 Inventory service provider checks availability of an item 4 If the incoming purchase order's orderDescription value starts with OrderVal, then the order's status is available in the inventory Based on Business 5 Based on the result from the inventory Process Modeling service, the purchase order service Notation (BPMN) provider responds with the fulfilled purchase order Now we're talkin' ! 44 SOA Technologies BPEL: Example Receive

When the purchase order service receives the client request, the following activities are performed: 1 Purchase order service provider assigns the price for the request 2 Purchase order service provider invokes the inventory service to check inventory status 3 Inventory service provider checks availability of an item 4 If the incoming purchase order's orderDescription value starts with OrderVal, then the order's status is order service provider responds with the fulfilled purchase order 45 SOA Technologies BPEL: Example Assign

When the purchase order service receives the client request, the following activities are performed: 1 Purchase order service provider assigns the price for the request 2 Purchase order service provider 49.98 $purchaseOrderRequest.purchaseOrder/po:price invokes the inventory service to check inventory status $purchaseOrderRequest.purchaseOrder/po:orderId 3 Inventory service provider checks $inventoryServiceRequest.purchaseOrder/po:orderId availability of an item $purchaseOrderRequest.purchaseOrder/po:customerId 4 If the incoming purchase order's $inventoryServiceRequest.purchaseOrder/po:customerId orderDescription value starts with OrderVal, then the order's status is $purchaseOrderRequest.purchaseOrder/po:orderDescription $inventoryServiceRequest.purchaseOrder/po:orderDescription available in the inventory 5 Based on the result from the $purchaseOrderRequest.purchaseOrder/po:price $inventoryServiceRequest.purchaseOrder/po:price inventory service, the purchase order service provider responds with the fulfilled purchase order BPEL: Now we're talkin' 46 SOA Technologies BPEL: Example

When the purchase order Invoke service receives the client request, the following activities are performed: 1 Purchase order service provider assigns the price for the request 2 Purchase order service provider invokes the inventory service to check inventory status 3 Inventory service provider checks availability of an item 4 If the incoming purchase order's 5 Based on the result from the inventory service, the purchase order service provider responds with the fulfilled purchase order 47 SOA Technologies BPEL: Example $inventoryServiceReply.inventoryP art/inv:inventoryStatus Decision When the purchase order ... service receives the client 1 Purchase order service provider assigns the price for the request 2 Purchase order service provider ... invokes the inventory service to