Escolar Documentos
Profissional Documentos
Cultura Documentos
Martin Keen Roland Barcia Karl Bishop Edward Delio Rashmi Kaushik Matthew Perrins Doug Phillips Gregg Vay
ibm.com/redbooks
Web 1.0
Web 2.0
Web 2.0 changes the way in which businesses interact with their customers. Note the following information about Web 2.0: It is about consumable services, rich Internet applications, and simplified programming models. It builds contextual relationships and facilitates knowledge sharing. It is about people and the way they collaborate.
REST-style services are easy to access from code running in Web browsers (or any other client or server) and expose and leverage existing content. Leading practices in REST derive from using the Web as it was architected and intended to be used. Specifications of interest to REST are: HTTP, MIME, Media Types, and URI. For more information about REST, go to: http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm
RESTful SOA
A RESTful SOA (sometimes referred to as WOA or ROA) is an instance of SOA that uses concepts from the Web as the primary service architecture: Limits choices to more easily implement an SOA Primarily uses REST to represent and access services Encodes data as JSON or XML (including XML schemas like ATOM) Might use alternate approaches such as JSON-RPC when appropriate Supports Rich User Interfaces built using AJAX A REST-style architecture maintains SOA principles. It enables a component-centric model in which various server-side and client components can be reused in a scalable but simple way1.
Source: http://www.projectzer.org
Cruise reservations Weather conditions Traffic conditions City information (such as directions and areas of interest) JKHLE wants to develop a best-of-breed travel Web site. This Web site should offer easy-to-use services for customers and simplify the companys underlying business processes.
Web Browser
HTTP Server
JSP HTTP
HTTPS
EMail
HTTPS HTTPS SOAP
Struts Hotel
Messaging MQ
HTTP Server
Application Server
Java Application
Weather
This architecture presents the following technical challenges: Business policies are embedded in the business process. Changes to business policies require updates to the business process, which is slow, expensive, and error prone. As JKHLE continues to expand, this restriction becomes ever more important. Each business system operates in a silo, which causes significant problems when trying to realize a multiple-channel strategy for customers. Integrating third-party services into the overall solution is difficult. The inclusion of these third-party services is important, and helps to differentiate JKHLEs travel offerings from the companys competitors. Similarly, third-party companies are having difficulty integrating with JKHLEs services, limiting the use of JKHLEs travel services by external parties.
To-be architecture
To solve its business and technical challenges, JKHLE builds a new architecture using the principles of the Web 2.0 SOA scenario. Figure 3 on page 7 shows this architecture, along with places where a realization is used.
Consumer Channel
Business Domain
Restful Realization
Weather
HTTP JS,PNG, HTML
Web Browser
HTTP Server
WPS
HTTPS JSON
Hotel
ESB
Service Proxy
Messaging MQ
Integration
RESTful Realization
RESTful Realization
HTTP SOAP
Airline
3rd Parties
HTTPS SOAP
This to-be reference architecture offers the following advantages: Business logic and business policies are now separate entities, enabling the fast, simple, nondisruptive addition of variations into the process. Simplified development interfaces enable the JKHLE business process to more easily make calls to third-party services, and also make it easier for third party services to invoke JKHLEs services. New services and new channels can be quickly integrated into the architecture.
Client
Client Runtime Browser HTTP request (GET, POST, PUT, DELETE)
Server
RESTful Server HTTP response PAYLOAD(JSON,XML,ATOM,RSS) Stateless RESTful services. Returns resource state and supporting information (iscacheable, last-modified, links to related resources).
Stateful application. Session management, caching, sufficient state for services calls.
This solution pattern is used as follows: A client (typically a rich Internet application (RIA)) prepares a resource-based call to a RESTful server. The server returns a payload of JSON, XML, RSS or ATOM back to the client. This is consumed by the RIA or calling service. The client uses the GET, POST, PUT, or DELETE methods on XMLHttpRequest (XHR) calls to map to RESTful entity behaviors.
Product mappings
Figure 5 on page 9 shows the products used by JKHLE to implement the to-be reference architecture.
WebSphere sMash
WebSphere sMash
WebSphere DataPower
REST Provider
In the remaining sections of this paper, we provide more details about each realization and the products JKHLE used to implement each realization.
Consumer Channel
Business Domain
Web Browser
HTTP Server
WPS
HTTPS JSON
Hotel
ESB
Service Proxy
Messaging MQ
Integration
RESTful Realization
HTTPS SOAP
Airline
Cruise
3rd Parties
HTTPS SOAP
The following architectural considerations are relevant to the RESTful Service Creation realization: Data sources to create RESTful services (such as Web services, databases, and screen scraping) Java objects (such as Java beans, EJB 3 and JPA) Resource models map to back-end entities Security Governance
10
Design patterns
This section describes two design patterns for the RESTful Service Creation realization. The first design pattern in shown in Figure 7 on page 11.
Each resource has a URL GET POST Browser PUT DELETE Each operation is an HTTP method Other Services (SOAP, and others) RESTful Service Adapter
This design pattern describes the following information: Existing legacy data is converted into a RESTful service. Each resource has a URI/URL and these resources are exposed by using the REST entity patterns. A simplified entity naming convention can be used. For example GetOrderServices?ordernumber=12345 changes to /rest/orders/12345. Each operation offered by the RESTful service is an HTTP method. For example a resource with the URI /JKHLE/hotel/reserve can be invoked by using GET /JKHLE/hotel/reserve. The RESTful service is responsible for calling the application service. This application service could be connected to an enterprise service bus on another back-end service through an adapter. The second design pattern is shown in Figure 8 on page 12
11
Remote System HTTP(s) X150 HTTP(s) Browser HTTP(s) Provides Web 2.0 Security for existing RESTful/ Web 2.0 protocol endpoints. Provides security and transformation for non-Web 2.0 endpoints. HTTP(s) HTTP(s)
HTTP(s)
HTTP(s)
WebSphere Application Server Web 2.0 Feature Pack Java EE Application (EJB 3/Servlet) expose Java EE Artifact as RESTful ...
Other
Browser
This design pattern describes how the pattern is built: Build Java Enterprise Edition (Java EE) artifacts such as EJBs, servlets, or reuse existing Java EE artifacts. Use the WebSphere Application Server Feature Pack for Web 2.0 to expose these artifacts as JSON over HTTP or XML over HTTP entities. Use WebSphere DataPower in the DMZ to add additional Web 2.0 security services and transformations where necessary. Deliver the correct HTTP content based on the client. For example deliver JSON to Web browsers and XML, ATOM, and RSS to other clients.
12
Consumer Channel
Business Domain
Web Browser
HTTP Server
WPS
HTTPS JSON
Hotel
ESB
Service Proxy
Messaging MQ
Integration
RESTful Realization
HTTPS SOAP
Airline
Cruise
3rd Parties
HTTPS SOAP
Figure 9 Where JKHLE uses the Rendering and Consuming RESTful Services realization
The following architectural considerations are relevant to the Rendering and Consuming RESTful Services realization: Response payloads (such as XML, JSON, ATOM, and RSS) Governance for REST interface grouping Security (including HTTPS and SPNEGO)
13
Runtime considerations
The following products can be used to implement the Rendering and Consuming RESTful Services realization: WebSphere Application Server Feature Pack for Web 2.0 Exposes Java EE based artifacts through REST. WebSphere sMash Provides a development and runtime environment for creating Web 2.0 applications. Provides tight REST integration with Dojo widgets and Groovy or PHP scripting. WebSphere DataPower Provides a Web 2.0 application with support for REST-SOAP and JS inspection. The role that these products play and the design patterns for using these products in the Rendering and Consuming RESTful Services realization are described in this section.
14
Ajax Browser
JSON
Atom / RSS
Ajax Proxy
Web Remoting
Web Feeds
This design pattern enables connectivity with Ajax clients and mashups to external Web services, internal SOA services, and other Java EE assets. It extends enterprise data to customers and partners through Web feeds.
WebSphere sMash
WebSphere sMash enables developers to quickly build and execute agile, Web 2.0-based applications with PHP scripting, REST, and Dojo in an integrated runtime and tooling package. WebSphere sMash focuses on rapid time to market, ease of development and deployment, and convention over configuration. WebSphere sMash provides clean and simple REST interfaces. Each REST entity is defined by an event handler file, with unique functions that are mapped to the REST verbs. For example the REST verb POST is mapped to the event method onCreate() and has a sample URL of /resources/people. WebSphere sMash provides automatic transformation of response data to XML, JSON, and ATOM.
WebSphere DataPower
WebSphere DataPower is a family of specialized network appliances that help to integrate, simplify, secure, and accelerate SOA. WebSphere DataPower can be
15
used to support the Rendering and Consuming RESTful Services realization in a number ways: RESTful resource aggregation Scenario: A resource request spans multiple service implementations. The results of these calls have to be aggregated or assembled into a complex report. Solution: WebSphere DataPower acts as an intermediary that defines an aggregate resource URI. This intermediary fans out requests to providers and aggregates responses. Media type transformation Scenario: An existing provider implements a single media type, and clients require additional media types. Solution: WebSphere DataPower acts as an intermediary that transforms the Accept header in the request message, and transfers the entity body and Content-Type header in the response message. This solution exploits wire-speed transformation. REST / SOAP mediation Scenario: A provider supports REST but existing clients require SOAP. Solution: WebSphere DataPower acts as an intermediary that exposes SOAP. It transforms request messages from SOAP to REST, and transforms response messages from REST to SOAP. Version mediation Scenario: Consumers and providers evolve independently. The goal is to minimize the number of providers implementations. Solution: WebSphere DataPower acts as an intermediary that proxies multiple resource versions. Resource requests are cast to newer versions. Any necessary heading and entity transformation, enrichment, or filtering is also performed. Quality of service mediation Scenario: Consumers sign contracts that ration the use of resources. The usage contract must be monitored and enforced based on request rates and volume. Solution: WebSphere DataPower acts as an intermediary that monitors and enforces quality of service limits, throttling and shaping requests as necessary.
16
Consumer Channel
Business Domain
Restful Realization
Weather
HTTP JS,PNG, HTML
Web Browser
HTTP Server
WPS
HTTPS JSON
Hotel
ESB
HTTP SOAP
Service Proxy
Messaging MQ
Integration
Airline
3rd Parties
HTTPS SOAP
The following architectural considerations are relevant to the UI Composition and Communication realization: Stateless entities Frameworks (such as Dojo and JSF) Containers (such as portlets, iWdigets, and iViews) Governance Security (including HTTPS and single sign-on).
17
18
Designer Tools
Architecture DHTML + Mashups Realization Dojo + Mashups Eclipse, RAD, Widget Factory, Portlet Factory + Mashups, Zero App Builder Eclipse + RAD, Expeditor CAE + RAD, Expeditor
Client
Server UI artifacts, data, etc. REST (or other) Local (light) Server Composite Application Shell Expeditor Browser Plug-in Profile Expeditor Desktop
Server Infrastructure
Client Runtime
Developer Tools
Dojo
Dojo is an Open Source DHTML toolkit written in JavaScript. Dojo enables you to easily build dynamic capabilities into Web pages. Dojo provides a lot of power and consists of three major layers: Dojo Core, Dijit, and DojoX. The Dojo Toolkit is a JavaScript toolkit for developing Ajax applications with rich user interfaces. It works well across most modern client containers and has a small footprint with high function. IBM supports the Dojo Toolkit; Ajax applications that are created in the Dojo Toolkit can be used with WebSphere Application Server and WebSphere Portal. The Dojo Toolkit is available for download at: http://www.dojotoolkit.org/
19
Design pattern
WebSphere Portal and Dojo can be used to support the UI Composition and Communication realization as illustrated in the design pattern shown in Figure 13.
Browser Portlet
DOJO Dijit Service A Consumer
Portlet
DOJO Dijit Service B Consumer DOJO Dijit Service C Consumer
Portal Server
HTTP(s)
HTTP(s)
HTTP(s)
RESTful Endpoint A
RESTful Endpoint B
RESTful Endpoint C
This design pattern describes the following information: WebSphere Portal supports portlets that are Ajax-enabled by using IBM Rational Application Developer or Portlet Factory to generate these portlets. This approach allows for select fragment updates. Dojo Dijit is used to render widgets within the portlet. The portlet is written to invoke a RESTful service.
20
Summary
JKHL implements solutions that are based on all three realizations of the Web 2.0 SOA scenario: RESTful Service Creation realization Rendering and Consuming RESTful Services realization UI Composition and Communication realization Using these realizations enabled JKHLE to build a better travel agency Web site that provides a fast architecture to deliver new products and consume new services, removes business silos, and exposes business data to the Internet in a consumable form.
21
22
Notices
This information was developed for products and services offered in the U.S.A. IBM may not offer the products, services, or features discussed in this document in other countries. Consult your local IBM representative for information on the products and services currently available in your area. Any reference to an IBM product, program, or service is not intended to state or imply that only that IBM product, program, or service may be used. Any functionally equivalent product, program, or service that does not infringe any IBM intellectual property right may be used instead. However, it is the user's responsibility to evaluate and verify the operation of any non-IBM product, program, or service. IBM may have patents or pending patent applications covering subject matter described in this document. The furnishing of this document does not give you any license to these patents. You can send license inquiries, in writing, to: IBM Director of Licensing, IBM Corporation, North Castle Drive Armonk, NY 10504-1785 U.S.A. The following paragraph does not apply to the United Kingdom or any other country where such provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of express or implied warranties in certain transactions, therefore, this statement may not apply to you. This information could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new editions of the publication. IBM may make improvements and/or changes in the product(s) and/or the program(s) described in this publication at any time without notice. Any references in this information to non-IBM Web sites are provided for convenience only and do not in any manner serve as an endorsement of those Web sites. The materials at those Web sites are not part of the materials for this IBM product and use of those Web sites is at your own risk. IBM may use or distribute any of the information you supply in any way it believes appropriate without incurring any obligation to you. Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those products and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products. This information contains examples of data and reports used in daily business operations. To illustrate them as completely as possible, the examples include the names of individuals, companies, brands, and products. All of these names are fictitious and any similarity to the names and addresses used by an actual business enterprise is entirely coincidental. COPYRIGHT LICENSE: This information contains sample application programs in source language, which illustrates programming techniques on various operating platforms. You may copy, modify, and distribute these sample programs in any form without payment to IBM, for the purposes of developing, using, marketing or distributing application programs conforming to the application programming interface for the operating platform for which the sample programs are written. These examples have not been thoroughly tested under all conditions. IBM, therefore, cannot guarantee or imply reliability, serviceability, or function of these programs. You may copy, modify, and distribute these sample programs in any form without payment to IBM for the purposes of developing, using, marketing, or distributing application programs conforming to IBM's application programming interfaces. Copyright International Business Machines Corporation 2009. All rights reserved. Note to U.S. Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
23
This document REDP-4555-00 was created or updated on September 17, 2009. Send us your comments in one of the following ways: Use the online Contact us review Redbooks form found at: ibm.com/redbooks Send your comments in an email to: redbook@us.ibm.com Mail your comments to: IBM Corporation, International Technical Support Organization Dept. HYTD Mail Station P099, 2455 South Road Poughkeepsie, NY 12601-5400 U.S.A.
Redpaper
Trademarks
IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of International Business Machines Corporation in the United States, other countries, or both. These and other IBM trademarked terms are marked on their first occurrence in this information with the appropriate symbol ( or ), indicating US registered or common law trademarks owned by IBM at the time this information was published. Such trademarks may also be registered or common law trademarks in other countries. A current list of IBM trademarks is available on the Web at http://www.ibm.com/legal/copytrade.shtml The following terms are trademarks of the International Business Machines Corporation in the United States, other countries, or both: DataPower IBM Lotus Optim Rational Redpaper Redbooks (logo) WebSphere
The following terms are trademarks of other companies: EJB, Java, JavaScript, and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. Other company, product, or service names may be trademarks or service marks of others.
24