restapi and json use case scenarios - db2-aktuell.de and... · db2 aktuell 2017 2 ibm’s...

28
Db2 Aktuell 2017 REST API / JSON Use Case Scenarios Oliver Draese, STSM Db2 for z/OS Development IBM Silicon Valley Lab ([email protected])

Upload: lethien

Post on 06-Mar-2018

219 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

REST API / JSON Use Case ScenariosOliver Draese, STSM Db2 for z/OS DevelopmentIBM Silicon Valley Lab ([email protected])

Page 2: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

2

IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal without notice at IBM’s sole discretion. Information regarding potential future products is intended to outline our general product direction and it should not be relied on in making a purchasing decision. The information mentioned regarding potential future products is not a commitment, promise, or legal obligation to deliver any material, code or functionality. Information about potential future products many not be incorporated into any contract. The development, release, and timing of any future features or functionality described for our product remains at our sole discretion.

DisclaimerDisclaimer

Page 3: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

3

Worum geht es?

§ Db2 ist nun selbst ein RESTful Service Provider§ Einfache Integration von Enterprise Data in neue APIs oder

Anwendungen§ Statisches SQL mit modernem Interface§ Unabhängig von verwendeten Programmiersprachen§ DBA hat volle Kontrolle über das hinterlegte SQL

Page 4: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

4

API API

API

API Connect

IBM Watson

API API

API

Page 5: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

5

Die verschiedenen Lösungen in der Übersicht

Db2 liefert als Service Provider Zugriff auf Enterprise Daten. Existente SQL Applikationen können modernisiert werden. Daten können einfach mit anderen API integriert werden!

Db2

z/OS Connect implementiert Industrie Standards (OpenAPIInitiative) und erlaubt durch seine mehrschichtige Architektur einen vereinheitlichten Zugangspunkt zu z/OS mit EAL5+ Sicherheit.

API Connect ist eine umfassende API Management Schicht für Authentifizierung und Token Management, Monitoring, Throttling und Abrechnung.

API Connect

Page 6: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

6

Db2 als Service Provider

Eingebaute Management Services:Anlegen, auflisten, ausführen von Services, ebenfalls via REST API

DDFService Discovery

Service CreationService Invoc.

Access Control (SAF)Security & Auditing

SQLPackage

z/OSConnect

Data Studio

RESTfulJSON

HTTP

DDF

Page 7: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

7

Db2 als Service Provider

Anlegen von neuen Services:Ein einzelnes SQL Statement (INSERT, UPDATE, DELETE, SELECT, CALL) in ein eigenes Package gebunden

DDFService Discovery

Service CreationService Invocation

Access Control (SAF)Security & Auditing

SQLPackage

z/OSConnect

Data Studio

RESTfulJSON

HTTP

DDF

Page 8: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

8

Db2 als Service Provider

Zugriffskontrolle:Existente DDF Infrastruktur für Klassifizierung, Sicherheit, Accounting, Statistics, Auditing

DDFService Discovery

Service CreationService Invocation

Acc. Control (SAF)Security & Auditing

SQLPackage

z/OSConnect

Data Studio

RESTfulJSON

HTTP

DDF

Page 9: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

9

Db2 als Service Provider

Eingebettet in DDF:DDF beantwortet nun auch die HTTP Requests, formatiert die JSON Ausgaben und startet das statische SQL Statement. Dabei werden Thread Pooling, Profiling... genauso genutzt wie bei „traditionellem“ DDF.

DDFService Discovery

Service CreationService Invocation

Access Control (SAF)Security & Auditing

SQLPackage

z/OSConnect

Data Studio

RESTfulJSON

HTTP

DDF

Page 10: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

10

Db2 Service mit DataStudio anlegen...1. SQL Statement schreiben 2. Statement als Service anlegen

3. Service registrieren (Deploy)4. Service Aufruf testen

Page 11: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

11

...oder einfach via REST Calls

Page 12: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

12

...oder einfach via REST Calls

Page 13: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

13

…oder via UI für MacOS

https://github.com/draese/DB2-for-zOS-REST-Manager

Page 14: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

14

...oder via BIND Command

BIND SERVICE(collid) NAME(service_name) [SQLDDNAME(ddname)] [SQLENCODING()] DESCRIPTION('string') [Additional BIND options]

*voraussichtlich November 2017

Page 15: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

15

Beispiel: AngularJS, NodeJS & Db2AngularJS / HTML5 Node Server App

Sichere ZoneDMZClient / Offene Zone

HTTP HTTP

https://github.com/draese/Db2RESTSample

Page 16: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

16

Beispiel: AngularJS, NodeJS & Db2AngularJS / HTML5 Node Server App

HTTP HTTP

https://github.com/draese/Db2RESTSample

Page 17: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

17

Beispiel: AngularJS, NodeJS & Db2AngularJS / HTML5 Node Server App

Node Server liefert die Web Seite und den Angular JavaScript Code.

1

Page 18: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

18

Beispiel: AngularJS, NodeJS & Db2AngularJS / HTML5 Node Server App

Angular View fordert Daten via „Relay“ REST Service „getEmpData“ an

2

http://localhost:3000/getEmpData

Page 19: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

19

Beispiel: AngularJS, NodeJS & Db2AngularJS / HTML5 Node Server App

NodeJS REST Service fordert die “Rohdaten“ via REST POST bei Db2 an.

3

http://server:446/services/birthDayList

Page 20: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

20

Beispiel: AngularJS, NodeJS & Db2{ "ResultSet Output": [ { "firstName": "CHRISTINE", "lastName": "HAAS", "bDay": "1933-08-14"

}, { "firstName": "MICHAEL", "lastName": "THOMPSON", "bDay": "1948-02-02"

}, ... ],

"StatusCode": 200, "StatusDescription": "Execution Successful“

}

4

http://server:446/services/birthDayList

Page 21: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

21

Beispiel: AngularJS, NodeJS & Db2

[ { firstName: "Christine",

lastName: "Haas", bDay: "1933-08-14", age: 83},

{ firstName: "Michael", lastName: "Thompson", bDay: "1948-02-02", age: 69},

...]

AngularJS / HTML5

5

http://localhost:3000/getEmpData

Page 22: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

22

Beispiel: AngularJS, NodeJS & Db2

<tbody> <tr ng-repeat="emp in empData">

<td>{{emp.firstName}}</td> <td>{{emp.lastName}}</td> <td>{{emp.bDay}}</td> <td>{{emp.age}}</td>

</tr></tbody>

AngularJS / HTML5Angular generiert die Tabellen – Zeilen basierend auf dem JSON Objekt Array...

Page 23: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

23

Demo

Page 24: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

24

Integration mit z/OS Connect EE

Data Web Servicesin Data Studio

Db2

SQL Statement

Db2 REST ServiceJSON Request undResponse Schemas

POST http://<host>:<port>/services/DB2ServiceManager{“requestType”:“createService“, “serviceName”:“EmployeeLookup“,“sqlStmt”:”select * from employee where empno=:empno”,“description”:”Query employee for the input empno”

}

ViaDB2ServiceManager

API

Db2ServiceDiscover API

zCEE Service Archive Toolkit

(zconbt)zCEE Service Archive (SAR)

Datei

Page 25: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

25

APARs für Db2 V11 und V12

25

DB2 V11 APARs• PI66828 - Initiale Version. Einschränkungen: Kein LOB/XML, Keine SP ResultSets, ...• PI70477 (Ähnlich wie Db2 V12 PI70652) – Erster Db2 V11 Service Refresh. Db2 V11 GA Version.• PI74409 (Ähnlich wie Db2 V12 PI74515) – Verschiedene Fehlerbehebungen• PI80087 (Ähnlich wie Db2 V12 PI80088) – Unterstützung für Db2 Trusted Contexts. Fehlerbehebungen für

SSL Client Certificate Authentifizierung, Benennung von Ergebnisspalten, …

DB2 V12 APARs• PI70652 (Ähnlich wie Db2 V11 PI70477) – Erster Db2 V12 Release (DB2 V12 "GA" level).• PI74515 (Ähnlich wie Db2 V11 PI74409) - Verschiedene Fehlerbehebungen• PI80088 (Ähnlich wie Db2 V11 PI80087) – Unterstützung für Db2 Trusted Contexts. Fehlerbehebungen für

SSL Client Certificate Authentifizierung, Benennung von Ergebnisspalten, …

Page 26: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

26

Videos und Demo Code

§ Db2 11 and 12 for z/OS Native REST Services – Part #1Demo, wie Db2 REST Services angelegt werden könnenhttps://youtu.be/6XkiEysnsCg

§ Db2 11 and 12 for z/OS Native REST Services and z/OS Connect EE 2.0 – Part #2Video über die Erweiterung von Db2 REST Services mit z/OS Connect EE 2.0. https://youtu.be/91ji0w01E3A

§ Demo Code dieser Db2 Aktuell Sessionhttps://github.com/draese/Db2RESTSample

Page 27: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

27

DB212rulestheAPIEconomy

TheRESTfulAPIisyetanotherwaywhereDB2isattheleadingedge– andagaincementingDB2’sandthemainframespositionasafullcapableserverintheITinfrastructureoftoday.UsingtheseREST-servicesMobileapplicationscanbothbebuiltfasterandrunfaster!

Frank PetersenChief Architect BankData

DB2 12 – RESTful API helping enterprises to be Agile

“RestfulAPIinDB212forz/OSallowsyoutodevelopmobileandotherappswithscalableperformanceinamatterofminutes.Doyouwanttobequickandagile?UseRestfulAPIinDB212forz/OS”

Kurt Struyf IBM GOLD Consultant IBM Champion for Analytics

Kundenzitate

Page 28: RESTAPI and JSON Use Case Scenarios - db2-aktuell.de and... · Db2 Aktuell 2017 2 IBM’s statements regarding its plans, directions and intent are subject to change or withdrawal

Db2 Aktuell 2017

28

Danke!Oliver Draese

STSM, Db2 for z/OS Development, IBM Silicon Valley Lab

[email protected]://www.linkedin.com/in/draese