BEA Confidential. | 1 Building REST Service APIs for Rich Internet Applications Peter Laird Managing Architect WebLogic Portal BEA Systems.

Slides:



Advertisements
Similar presentations
Pierre-Johan CHARTRE Java EE - JAX-RS - Pierre-Johan CHARTRE
Advertisements

Building and using REST information services Rion Dooley.
Introduction to Web Services
By Loukik Purohit & Rohit Ghatol
JavaScript and AJAX Jonathan Foss University of Warwick
SOAP Quang Vinh Pham Simon De Baets Université Libre de Bruxelles1.
Peter Laird. | 1 Getting Started Building Mashups using JavaScript, Ajax, and Google Maps Peter Laird Managing Architect WebLogic Portal BEA Systems.
9. AJAX & RIA. 2 Motto: O! call back yesterday, bid time return. — William Shakespeare.
Web Servers How do our requests for resources on the Internet get handled? Can they be located anywhere? Global?
Ajax / Rich Internet Applications ICW Lecture 21 Errol Thompson.
Peoplesoft: Building and Consuming Web Services
1 JavaScript & AJAX CS , Spring JavaScript.
Jon Flanders INT303. About Me  Jon Flanders –  Independent consultant/trainer  BizTalk MVP.
A closer look Dynamic Webpages Jessica Meyerson March 1, 2011.
RESTful Web Development With Nodejs and Express. REST Stands for REpresentational State Transfer Has the following constraints: ◦Client-Server ◦Stateless.
Presented by…. Group 2 1. Programming language 2Introduction.
RIA Introduce Comparison among several technology.
XML Web Services in Visual Studio.NET Peter Ty Developer Evangelist.NET and Developer Group.
AJAX Chat Analysis and Design Rui Zhao CS SPG UCCS.
JavaScript & jQuery the missing manual Chapter 11
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
GIS technologies and Web Mapping Services
AJAX Without the “J” George Lawniczak. What is Ajax?
Web Architecture & Services (2) Representational State Transfer (REST)
REST.  REST is an acronym standing for Representational State Transfer  A software architecture style for building scalable web services  Typically,
Wyatt Pearsall November  HyperText Transfer Protocol.
CSCI 6962: Server-side Design and Programming Web Services.
Web Services XML-RPC, SOAP, REST Advanced Web-based Systems | Misbhauddin.
Instructor, Dr. Khalili Bahram Jeevan Kumar Gogineni.
Python and REST Kevin Hibma. What is REST? Why REST? REST stands for Representational State Transfer. (It is sometimes spelled "ReST".) It relies on a.
Peter Laird. | 1 Building Dynamic Google Gadgets in Java Peter Laird Managing Architect WebLogic Portal BEA Systems.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
1 Seminar on Service Oriented Architecture Principles of REST.
1 Web Servers (Chapter 21 – Pages( ) Outline 21.1 Introduction 21.2 HTTP Request Types 21.3 System Architecture.
2007cs Servers on the Web. The World-Wide Web 2007 cs CSS JS HTML Server Browser JS CSS HTML Transfer of resources using HTTP.
Chapter 16: Ajax-Enabled Rich Internet Applications with XML and JSON TP2543 Web Programming Mohammad Faidzul Nasrudin.
Web Technologies Lecture 8 Server side web. Client Side vs. Server Side Web Client-side code executes on the end-user's computer, usually within a web.
Spring and DWR Frameworks for Rich Web Enterprise Application Thomas Wiradikusuma Presentation to the 20 th.
Ajax VS Flex A comparison based on shopping cart implementation PoHsu Yeh py2157.
ICM – API Server & Forms Gary Ratcliffe.
RESTful Web Services What is RESTful?
AJaX and SOA Partha Kuchana. Agenda What is AJaX Benefits & Problems AJaX & SOA AJaX architecture AJaX with No XML.
REST By: Vishwanath Vineet.
Web Technologies Lecture 10 Web services. From W3C – A software system designed to support interoperable machine-to-machine interaction over a network.
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
AJAX Use Cases for WSRP Subbu Allamaraju BEA Systems Inc WSRP F2F Meeting, May 2006.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
Janakiram MSV Developer Evangelist Microsoft Corporation.
Feeling RESTful? Well, first we’ll define a Web Service –A web page meant to be consumed by a computer via an autonomous program as opposed to a web browser.
© 2010 IBM Corporation RESTFul Service Modelling in Rational Software Architect April, 2011.
NCCUCS 軟體工程概論 Lecture 5: Ajax, Mashups April 29, 2014.
National College of Science & Information Technology.
ArcGIS for Server Security: Advanced
API (Application Program Interface)
Better RESTFul API – Best Practices
Web Development Web Servers.
WEB SERVICES.
Node.js Express Web Services
AJAX and REST.
Unit – 5 JAVA Web Services
GeneXus 9.0: Web applications at their higher power
Subbu Allamaraju BEA Systems Inc
AJAX.
Ajax Design Patterns – Programming Practices in Web Services
AJAX.
Ashish Pandit IT Architect, Middleware & Integration Services
WEB API.
JavaScript & jQuery AJAX.
Python and REST Kevin Hibma.
Chengyu Sun California State University, Los Angeles
Presentation transcript:

BEA Confidential. | 1 Building REST Service APIs for Rich Internet Applications Peter Laird Managing Architect WebLogic Portal BEA Systems

Peter Laird About the Speaker Has 10 years of server side Java development experience Leads the architecture team for BEA WebLogic Portal, a leading Java enterprise portal product  Has worked on WebLogic Portal for 7 years as a developer and architect  WebLogic Portal introduced REST-like APIs in version 10.2 Holds the following certifications  Oracle DBA  Cisco CCNA Regular contributor to BEA’s developer website 

Peter Laird Housekeeping This is a 30 Minute Presentation  A lot to cover, will move very fast  Will focus more on REST, less on RIA development Assumes you have a basic understanding of:  HTTP  XML  JavaScript  A dynamic web programming technology (Java Servlets,.NET, PHP)

Peter Laird Agenda Rich Internet Applications (RIA) Data Driven Rich Internet Applications Principles of REST REST in Practice

Peter Laird Rich Internet Applications Attributes of Rich Internet Applications (RIA)  Run in a browser, or do not require a software install  Supported with a server side component which holds application state  HTTP is used to communicate with the server  Client contains some basic processing capabilities  Have an interactive feel like a fat-client application Technologies used to create RIAs  JavaScript and the XmlHttpRequest (Ajax)  Adobe Flash and Flex  Microsoft Silverlight  Laszlo, JavaFX, XUL, etc etc

Peter Laird RIA: the New Web Standard Think of the browser as a virtual machine  Not just a page rendering application  Programmable through JavaScript or plugins  HTTP networking support RIAs becoming the standard of web applications  Netflix, Google Mail, etc started the trend  Now any noteworthy consumer facing web app is an RIA  Browser support for RIA is very good

Peter Laird Data Driven Rich Internet Applications

Peter Laird RIA: Data Driven RIAs typically request data from a server  Netflix – movie catalog  Gmail – messages Often these requests are very fine grained Requires an efficient mechanism for retrieving that data RIA technologies universally provide an HTTP client  XmlHttpRequest for Ajax use cases  We will use Ajax in this presentation

Peter Laird Ajax and XmlHttpRequest Sample // create a request object var xhr = new XMLHttpRequest(); // define the request properties xhr.open("GET", " true); xhr.onreadystatechange = myHandler; // define the callback handler xhr.send(null); // send the request function myHandler() // callback definition { if (xhr.readyState == 4) // response has been received { if (xhr.status != 404) { var data=eval(‘(’ + xhr.responseText + ‘)’); // invoke JS to manipulate the response }

Peter Laird WS-* Web Services (WS-*) Standards are a valid approach  SOAP is an XML format for defining a service request and response  I will use WS-* notation to refer to SOAP over HTTP  WS-* also includes a number of subordinate standards WS-Security WS-Transaction Etc Proper deployment of a WS requires a WSDL to describe it  XML document that describes the Web Service and how to access it WS-* is not a lightweight approach  Requires a good SOAP stack on the client, or  Requires client code to create SOAP requests and parse the SOAP response

Peter Laird Introducing REST Yes, there is a better way REpresentational State Transfer (REST)  A simpler approach to building data services REST services are implemented using the basics of the web  Service end points are resources  Return payload is usually simple plain text, JSON or XML structures REST is a general approach for building services, but…  RIA development will likely be the first time you will use REST  Will focus exclusively on RIA use cases for REST in this talk

Peter Laird REST Example: Search Suggestions You want to have Google like suggestions in your search box You have wired the search box with a JavaScript event handler that uses an XmlHttpRequest to call the data service The XmlHttpRequest callback expects a list of search keywords in return  JavaScript populates the suggestion dropdown How do you implement the REST service?

Peter Laird REST Example: Search Suggestions Impl Create a REST service on the server  Java: easily implemented using a Servlet or JSP URLs used by Ajax will look like   Where “am” is the text the user has typed into the box The service will respond with an HTTP response with the following body: amigo america ammunition The JavaScript parses that list and populates the drop-down

Peter Laird REST Real World: WebLogic Portal Author was involved in a REST implementation for WebLogic Portal (WLP) WLP needed to implement dynamic UI features  Move portlets around on a page using drag and drop  Retrieve the list of portlets that can be added to a page  Choose from a list of available branding schemes for a page JavaScript+XmlHttpRequest was the RIA technology chosen WLP implemented a set of REST-like APIs  Not 100% REST compliant, but pretty close

Peter Laird REST Real World: WebLogic Portal

Peter Laird REST Principles

Peter Laird Two REST References Roy Fielding Dissertation  Origin of the idea  Focus on Chapter 5Chapter 5 RESTful Web Services book  Leonard Richardson and Sam Ruby  Recommended as a pragmatic guide  Not loved by all, search the internet to learn what the community thinks about this book  Explains why the REST principles are important to follow

Peter Laird Beware of the REST Nerd Wars REST similar to Object Oriented design  Common to see arguments between pragmatists and purists  We had some of this during our WebLogic Portal implementation Purists are known as the RESTafarians  Joke: Are RESTafarians clean? No, they don’t use any SOAP. Joke: As with OO, there are some core principles but also a lot of opinion and style  You will need to formulate your own style

Peter Laird URL Represents a Noun, not a Verb REST services are based on Resources not Operations  Use Case: URL for a service that returns a list of addresses  Good:  Bad:  Bad: Guidelines:  URLs should express a noun, not a verb  URL path should illustrate a logical structure of the resources  URL parameters are used to feed modifiers into an algorithm

Peter Laird HTTP Verb Matters REST services should honor the HTTP method (verb)  GET –reads the state of a resource described by the URL  PUT – adds the resource described by the URL  DELETE – deletes the resource described by the URL  POST – updates the resource described by the URL Guidelines:  Do not embed the verb in the URL path or query parameters  GET must not alter the state of the server  GET, PUT and DELETE must be idempotent

Peter Laird HTTP Response Codes REST services should use the proper HTTP response codes  200 – request was properly understood, the operation succeeded  400 – the client sent an invalid request  500 – internal server error, there is a problem on the server  404 – the URL does not map to a valid resource  401 – not authorized Guidelines:  Anti-pattern is to always return 200, and embed the result of the operation in the response body

Peter Laird REST in Practice

Peter Laird JSON as the Return Payload XML is a safe format to return from the REST service  But not the easiest when the client is JavaScript JavaScript Object Notation (JSON) is usually a better alternative when the client will always be JavaScript One line reconstitutes the returned structure into a native JavaScript object  var payload = eval(‘(’ + xhr.responseText + ‘)’);

Peter Laird Authenticaton Many REST services will require authentication Usually “just works” for Ajax RIA applications  User logs into the application  XmlHttpRequests carry the session cookies to the server  REST services will recognize the user session Two easy solutions for explicit authentication for REST  HTTP Basic authentication  Custom authentication REST service  Make sure HTTPS is used for transport! Two harder solutions for explicity authentication  Digest  WSSE

Peter Laird Single Origin Policy This issue affects any XmlHttpRequest XmlHttpRequest cannot target a network domain different from the outer page This is a security feature, but will affect how you deploy your REST services Example:  Outer page:  XmlHttpRequest:  That XHR will fail

Peter Laird Thank You