Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

37
Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013

Transcript of Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

Page 1: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

Server Access

The REST of the Story

David ClearyPrincipal Software EngineerJune 12, 2013

Page 2: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.2

OE Mobile Tooling

Page 3: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.3

Rest Adapter Tooling

Page 4: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.4

OE Mobile Tooling

Page 5: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.5

Rest Adapter Tooling

Page 6: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.6

Agenda

Why REST? REST Architectural Overview

What is RESTful in the Progress World

RESTing your Progress Servers

Demo

Page 7: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.7

Key Takeaways

Understanding of RESTful Application Principals

Knowing when to REST or not

What OpenEdge provides in 11.2 and later to REST

Page 8: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.8

Architecture or Protocol?

HTTP

• HyperText Transfer Protocol

• Defines text-based message format and exchange protocol

• Foundation for communications in the cloud

SOAP

• Simple Object Access Protocol

• Defines an XML-based message format and exchange protocol

• Specifies bindings to HTTP and other transports

REST

• Representational State Transfer

• Style of software architecture for distributed systems

• Describes the architecture of HTTP

• Predominate web API design model

Page 9: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.9

REST Architecture

There is no REST Specification

REST does not define a message format

REST does not define a message exchange protocol

REST is stateless

• Each client request contains all the information to service the request

REST is resource-based

• Resources are identified by URI (Uniform Resource Identifier)

• Server provides a representation of resource to client

• Client can manipulate resource on server through the representation

CRUD Model

• Create, Read, Update and Delete

Page 10: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.10

What is a Resource?

Page 11: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.11

REST Web Services

Uses HTTP as its protocol

Resource identification through URI

Uniform interface (GET, PUT, POST, DELETE)

Typically uses JSON or XML as message format

Every interaction with a resource is stateless

Page 12: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.12

RESTful Web Services vs. SOAP

REST

Resource based

Lighter weight

Can use JSON or XML

Contract via documentation

SOAP

Procedural

Contains more details

Uses XML

Contract via WSDL

When to use SOAP

• Intranet applications – More mature tooling

• B2B applications – Strong contract

• Exposing existing applications

When to use REST

• Cloud-based and mobile applications

• Creating highly scalable stateless applications

Page 13: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.13

Scientific Approach to Choosing

21 Decisions and 64 alternativesREST Rules

The Cloud

Page 14: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.14

Scientific Approach to Choosing

21 Decisions and 64 alternativesREST Rules

The Cloud

Page 15: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.15

Agenda

Why REST? REST Architectural Overview

What is RESTful in the Progress World

RESTing your Progress Servers

Demo

Page 16: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.16

Progress REST Support

WebSpeed

• Supporting RESTful applications since 1997

• No tooling support specific to REST – Developer must do everything

OpenEdge Reference Architecture (OERA)

• Business Entities are resources

• AutoEdge a RESTful application

OpenEdge REST Adapter

• Delivered as part of OpenEdge 11.2

Progress DataDirect Cloud

Page 17: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.17

OpenEdge Reference Architecture

Presentation Enterprise Services

Business Components

Data Access

Data Sources

Com

mon Infrastructure

Workflow Task Entity

Page 18: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.18

OpenEdge Reference Architecture

Presentation Enterprise Services

Business Components

Data Access

Data Sources

Com

mon Infrastructure

Workflow Task Entity

Page 19: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.19

AutoEdge

Page 20: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.20

OpenEdge REST Adapter

Machine AMachine B

Machine C

HTTP Web ServerOpenEdge Explorer /

OpenEdge ManagementOpenEdge Explorer /

OpenEdge Management

RESTMAN /command lineRESTMAN /command line

Java containerJava container

REST Management AgentREST Management Agent

REST Client #1 OpenEdge AppServerOpenEdge AppServerREST Application #1REST Application #1

OpenEdge AppServerOpenEdge AppServer

OpenEdge AppServerOpenEdge AppServer

REST Client #2

REST Client #3 REST Application #3REST Application #3

REST Application #2REST Application #2

Progress Developer Studio for OpenEdge

Progress Developer Studio for OpenEdge

Page 21: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.21

Agenda

Why REST? REST Architectural Overview

What is RESTful in the Progress World

RESTing your Progress Servers

Demo

Page 22: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.22

Applications and Services

Service - A collection of operations on a set of resources

• Create – Create a new resource

• Read – Retrieve an existing resource

• Update – Update an existing resource

• Delete – Delete an existing resource

An OpenEdge REST Application supports one or more services

• Compiled into a Java WAR file

Page 23: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.23

The URL Space

http://api-public.netflix.com/catalog/titles?term=Ironman

• Protocol: HTTP

• DNS System Name: api-public.netflix.com

• Service Name: catalog

• Resource Name: titles

• URL Parameters: term=Ironman

http://localhost:8980/Application/rest/Service/Resource

Additional information required

• HTTP Verb (GET, PUT, POST, and DELETE)

• Optional body

• Media type

Page 24: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.24

HTTP GET

Retrieves a resource or resource locators identified by a URL

Client identifies what media type[s] it wants via Accept header

• application/json only type supported currently by OpenEdge

Input parameters specified in URL

• Path parameters

• URL Parameters

Additional parameter support

• HTTP Headers

• Additional metadata from request context

Does not support sending a body

Page 25: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.25

HTTP POST

Creates a new resource on server

Typically uses URL of parent resource

Requires a body that represents resource

• OpenEdge limited to application/json

Can support path and URL parameters

OpenEdge supports mapping individual parameters extracted from a JSON body

Returns representation of new resource if accepted by the server

Page 26: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.26

HTTP PUT

Updates an existing resource on server

Uses URL of resource, unlike POST

Can create new resource at location specified by client, but not recommended

Idempotent – Identical requests have same effect as a single request

Page 27: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.27

HTTP DELETE

Deletes the resource identified on the server

Also Idempotent

Page 28: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.28

Message Bodies

Bodies must be JSON

Map TempTables and Datasets directly to bodies

Map CHARACTER and LONGCHARS to bodies

• Custom JSON objects

Multiple parameters in body supported by request and response objects

• Input parameters extracted and passed to AppServer

• Output parameters added to response object

• Only one level deep

Page 29: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.29

HTTP DELETE

Deletes the resource identified on the server

Also Idempotent

Page 30: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.30

Message Bodies

Bodies must be JSON

Map TempTables and Datasets directly to bodies

Map CHARACTER and LONGCHARS to bodies

• Custom JSON objects

Multiple parameters in body supported by request and response objects

• Input parameters extracted and passed to AppServer

• Output parameters added to response object

• Only one level deep

Page 31: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.31

Service Interfaces

Identify the entities you want to expose

Map these entities to your URL space

Determine what CRUD operations are applicable to what resources

Document the representation of your resources

Avoid verbs, but not at the cost of complexity

Page 32: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.32

Sessions and Identity Management

Authentication, Authorization, and Session Management done at Web Server

Uses Spring Security Framework 3.1

Supports internal and external authentication providers

For production, you want stateful sessions

• Web Server sessions, not AppServer

Done through JSESSIONID cookie

Must use AppServer SSO if you want identity on AppServer

• Spring creates sealed ClientPrincipal

Page 33: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.33

Agenda

Why REST? REST Architectural Overview

What is RESTful in the Progress World

RESTing your Progress Servers

Demo

Page 34: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.34

CRM Application

Resources

• Customers

• Orders

• CustomerOrders

Techniques used

• Hyperlinks (Locators)

• HTTP Response Code

• Multiple parameter bodies

Page 35: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

© 2013 Progress Software Corporation. All rights reserved.35

CRM Application

Resources

• Customers

• Orders

• CustomerOrders

Techniques used

• Hyperlinks (Locators)

• HTTP Response Code

• Multiple parameter bodies

Page 36: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.

October 6–9, 2013 • Boston #PRGS13

www.progress.com/exchange-pug

Special low rate of $495 for PUG Challenge attendees with the code PUGAM

And visit the Progress booth to learn more about the Progress App Dev Challenge!

Page 37: Server Access The REST of the Story David Cleary Principal Software Engineer June 12, 2013.