SlideShare uma empresa Scribd logo
1 de 51
Baixar para ler offline
#engageug
1
REST services
and
IBM Domino/XWork
A presentation for EngageUG
30-31 March 2015
by John Dalsgaard
#engageug
2
Agenda
● About me
● Webservices
● REST & JSON
● Domino/XWork – out of the box...
– Domino Access Service (DAS)
– Extension Library controls
– Build your own
– Demos
● Round up
#engageug
3
About me
● Worked with Notes since 1995
version 4.5
● Java since Notes 5.0.7 (2000)
● Large web-apps. (40.000+ users)
● Object Oriented approach since 1999 (yes, in
LotusScript...)
● XPages & mobile apps (Appcelerator Titanium)....
● Certified Principal/advanced administrator and
developer – all versions 4.6 → 9.0
● Developer, project manager, IT manager – own
company since 1998.
● IBM Champion for 2015
#engageug
4
About me
#engageug
5
Webservices
● What is a webservice?
– Program to program communication
– Implemementation independent
– ”Contract” about interface
● Traditionally SOAP & XML...
– Very ”verbose” (=not ”light”)
– Needs pre-/post processing to ”extract” data
→ Meet the ”new kid on the block”:
#engageug
6
REST services using JSON
● REST = REpresentational State Transfer
● JSON = JavaScript Object Notation
● Why?? → Loose coupling...
– Angular, Ext.js, etc.
– Mobile apps/web apps
● Let's take a quick look at these terms:
#engageug
7
REST
● Wikipedia:
Representational state transfer (REST) is an abstraction of the
architecture of the World Wide Web; more precisely, REST is an
architectural style consisting of a coordinated set of architectural
constraints applied to components, connectors, and data elements,
within a distributed hypermedia system. REST ignores the details of
component implementation and protocol syntax in order to focus on the
roles of components, the constraints upon their interaction with other
components, and their interpretation of significant data elements.....
WHAT?????
#engageug
8
REST
● Client-server architecture
– Uniform interface separates client from server
● Stateless
– All info in request
● Cacheable communications protocol
– Almost always HTTP
● Uniform interface...
– HTML, URIs, XML, JSON, MIME, meta-data....
● Actually, WWW via HTTP can also be viewed as a REST-
based architecture – so nothing new here that you did not
know... :-)
#engageug
9
”RESTful” web-service
● Architectural style:
– URI structure (base URI)
– Internet media type. JSON – or: XML, Atom, …
– Standard HTTP methods:
● GET
● POST
● PUT
● DELETE
… also known as: CRUD (Create, Read, Update,
Delete) methods
#engageug
10
”RESTful” web-service
● Designed for networked applications
● Using HTTP as a simple alternative to more
complex mechanisms to connect between
machines:
– WebServices (SOAP, WSDLs etc.)
– CORBA
– RPC
#engageug
11
”RESTful” web-service
● Example – SOAP:
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:body pb="http://www.acme.com/phonebook">
<pb:GetUserDetails>
<pb:UserID>12345</pb:UserID>
</pb:GetUserDetails>
</soap:Body>
</soap:Envelope>
– … must to be sent via a request (HTTP POST)
● Example – RESTful web-service:
http://www.acme.com/phonebook/UserDetails/12345
– … just a URL!! (HTTP GET) – simple....
#engageug
12
JSON
● Wikipedia:
JSON (/ˈdʒeɪsən/ jay-sən), or JavaScript Object Notation, is an
open standard format that uses human-readable text to transmit
data objects consisting of attribute–value pairs. It is used primarily
to transmit data between a server and web application, as an
alternative to XML.
Although originally derived from the JavaScript scripting language,
JSON is a language-independent data format. Code for parsing
and generating JSON data is readily available in a large variety of
programming languages.
#engageug
13
JSON
● A syntax for storing & exchanging data
● An easier to use alternative to XML
● Is a lightweight data interchange format
● Is language independant
● Is ”self-describing” and easy to understand
JSON uses JavaScript syntax, but the JSON format is text
only, just like XML. Text can be read and used as a data
format by any programming language...
#engageug
14
JSON vs. XML
● XML
<employees>
<employee>
<firstName>John</firstName> <lastName>Doe</lastName>
</employee>
<employee>
<firstName>Anna</firstName> <lastName>Smith</lastName>
</employee>
<employee>
<firstName>Peter</firstName> <lastName>Jones</lastName>
</employee>
</employees>
● JSON
{"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}
#engageug
15
JSON syntax
● Object: {}
{ 'text' : 'Hello world!',
'number' : 123,
'valid' : true }
● Array: []
{ 'numbers' : [ 1, 2, 3 ] }
{ 'objects' : [ {'a':1}, {'b':2}, {'c':3} ] }
● Value:
– string, number, object, array, boolean, null
● Please note: NO date/time type...!!! Grrrrr.....
#engageug
16
JSON and JavaScript
var text = ”{ 'name' : 'EngageUG', 'current' : 2015 }”;
● Create an object:
– var engageUG = JSON.parse(text);
● Create text representation of an object:
– var engageUGText = JSON.stringify(engageUG);
● Refer to attributes:
– var name = engageUG.name;
● Add another attribute:
– engageUG['venue'] = 'Ghent'
#engageug
17
Domino/XWork - out of the box
● Webservices (SOAP, XML, etc...)
– Consumer (client) – since 8.0
– Provider (server) – since 7.0
– Written in LotusScript/Java
RESTful service using JSON →
● Domino Access Services (DAS)
– core service - since 9.0.1
– data service - since 8.5.3 UP1 (~DDS)
– calendar service - since 9.0.1
#engageug
18
Domino Access Services
● Implemented as OSGi plugins/servlets
● Based on Apache Wink
● How to enable & configure
– Web access
– Enable Domino Access Service (DAS)
– Enable for database
– Enable for specific elements
#engageug
19
Enable web access
● HTTP Server must be started.
– Check console: show tasks
HTTP Server Listen for connect requests on TCP Port:80
● Use internet sites – just do it!
– Activate in server document
– Create Internet site document for domain
● After changes: restart task http
● Check:
– Open the server on the port you saw on the console
– http://server.dom.dk:80/ (leave out port if 80)
#engageug
20
Check DAS
Open: server.dom.dk/api
– lists service and
their state
#engageug
21
Enable data service
● On Internet site document (configuration tab):
● Need to refresh http to take effect
– tell http refresh
#engageug
22
DAS: List all ”services” (db's)
● Open: server.dom.dk/api/data
#engageug
23
DAS: Open a specific database
● Try: server.dom.dk/reports.nsf/api/data/collections
→ We need to enable DAS for the database
#engageug
24
DAS: Enable for database
● On the advanced properties of the database:
● Select level in ”Allow Domino Data Service”:
● Important decision: Views and/or documents
#engageug
25
DAS: Open database again
● Try: server.dom.dk/demo/json.nsf/api/data/collections
#engageug
26
DAS: Enable for view
● We need to enable DAS for the view first
● Open the view in Domino Designer
● On the view properties – advanced tab
● Enable: ”Allow Domino Data Service operations”:
● Save the view, open it using the url returned
#engageug
27
DAS: Open a view
● Try: server.dom.dk/.../collections/unid/A892133953...
●
● Heureka!! - we see a list of all documents!
● Also try: server.dom.dk/.../collections/name/persons
#engageug
28
DAS: Open a document
● Try: server.dom.dk/.../documents/unid/33735D0BC...
● Requires ”Views and documents” to be set in DB props.
#engageug
29
DAS: Writing back...
● Remember content type MUST be:
– application/json
– Set ”Content-type” in header of request
● If you get ”405 Method not allowed”
– Enable method in internet site
● By default these are NOT enabled:
– PUT
– PATCH
– DELETE
– Or override header in your request
● ”X-HTTP-Method-Override” : ”POST”
#engageug
30
DAS: Save existing document
● Use ”PATCH” to change specific fields
– url: …/documents/unid/33735D0BCE799....
– updates only the fields in the request
● Use ”PUT” to change ALL fields
– url: …/documents/unid/33735D0BCE799....
– All fields are replaced with the fields from request –
fields not specified are blanked....
#engageug
31
DAS: Create / delete document
● Use ”POST” to create a document with specified
fields
– url: …/documents?form=Person
– You MUST add form to url
● Use ”DELETE” to remove the document entirely
– url: …/documents/unid/33735D0BCE799....
#engageug
32
DAS: Data service - more...
● See the design of a view:
– //.../collections/name/persons/design
● Compute values on update of document
– //.../documents/unid/33735D0BC...?
computewithform=true
● Use ”normal” url actions to control view collection,
e.g.
– //.../collections/name/persons?start=1&count=2
#engageug
33
DAS: Calendar service
● There is a catch to enable this service...
– In the internet site document you have to type
”Calendar” as an option.... - it is not predefined
#engageug
34
DAS: Calendar service
● Built on the new calendar backend classes in
Domino/XWork 9.0.1
● Current user's calendars, email address, and
services
server.dom.dk/api/calendar
● Events from specific calendar
server.dom.dk/demo/cal.nsf/api/calendar/events
● Events from specific calendar (iCal format)
server.dom.dk/.../events?format=iCalendar
● Only shows events that have NOT started yet
#engageug
35
DAS: Calendar service
● You can also CREATE new events!!!
– Using POST and specifiying all fields under an
”events” object
– Handles the various types: Meeting, appointment,
etc.
– Will send invites to participants of meetings
– Handles notifications
– Actions for complete workflow: Accept, decline,
delegate, etc.
– … and more!
#engageug
36
Extension Library
● Comes with the Domino 9.0.x server (and Domino
Designer)
● Just needs to be enabled in XSP properties
● Does NOT require DAS to be enabled
● Provides easy to use controls:
– REST Service (data)
– Remote Service (JSON-RPC)
● Allow you to run serverside code as a REST service...
● Also provide support for:
– NSF and OSGi servlets... - advanced stuff!!
#engageug
37
Extension Library
● Why would you use it...????
● → Allows further customizations
– Include/exclude certain data columns
– Include/exclude system columns (@....)
– Calculate contents of own columns
– Run code before/after CRUD operations
– Sort and search
– Create ”handles” (variable) to use in XPage as
datasources
#engageug
38
Ext. Lib. REST Service
● Create a new XPage
● Drag a ”REST Service” component to it:
● Fill in ”the blanks”
– pathInfo → identifies the service
– Select service
– Fill in the info
needed for that
type of service
#engageug
39
Ext. Lib. REST Service
● To call your service you open the XPage with the
REST Service control(s) and add the pathInfo, e.g.:
server.dom.dk/db.nsf/yourpage.xsp/persons
– ...assuming you set pathInfo to ”persons” for one of
the REST Services on the ”yourpage” XPage
#engageug
40
Ext. Lib. NSF servlet
● You can register a servlet to e.g. give you a JSON
representation of a view
● Extends DefaultServletFactory
– add a factory that maps to a service (e.g. view name)
– Register in Code/Java/META-INF/services
● file: com.ibm.xsp.adapter.servletFactory
→ Full name of servlet class
● Refer to using url, e.g.:
server.dom.dk/db.nsf/xsp/services/Persons
● Does NOT require DAS to be enabled
#engageug
41
Build your own...
● Why??
– … using your own MVC – Java objects
– Full control
– Does NOT require DAS to be enabled
● Handy ”ingredients”
– Java
– XPages
● Use an ”XAgent” (or an NSF/OSGi servlet)
● Select a JSON ”package”
– Built-in with XPages
– Or others like GSON – (wrap as plugin!!)
#engageug
42
Build your own...
● Use cases:
– Generate JSON directly from your Java class
– Consume your JSON POSTs directly by parsing
them to the corresponding Java class
→ Ready to use in your logic
– Control e.g. date formating generally for all Date
fields
● Eg. use ISO datetime format
#engageug
43
Build your own...
● LotusScript....
– You didn't expect me to say this!
– An option if you have existing systems with business
logic written in LotusScript
– Simple:
● print – correct content-type
● print …. your JSON (as text)
– … but I would not advice to build new this way →
you would like to use a library/package to build your
JSON for you!
● Does NOT require DAS to be enabled
#engageug
44
Demo...
● Server:
– Local VM with Domino 9.0.1FP2 on CentOS 6.6
– Extension Library (from IBM)
– OpenNTF Domino API installed
– OpenNTF Essentials installed
● A demo database
– Showing an MVC pattern I use
– Added a number of JSON demos
– Is available for download
● Tool for testing:
– Google Chrome Postman
#engageug
45
Demo...
● DAS
– core
– data
– calendar
● Extension Library REST Service
● Build you own
– Built-in JSON classes
– GSON based on Java objects
– LotusScript...
● Download DB from Bitbucket.org
#engageug
46
LiveDEMO
#engageug
47
Round Up
● What are REST and JSON
● GET, POST, PUT, DELETE – ~CRUD
● Domino Access Services – out of the box
– Data
– Calendar
● Extension Library
– REST Service
– (Remote Service)
● Build own solution
– Java & JSON ”package” - …. & LotusScript ;-)
#engageug
48
Questions??
● Did you learn something?
● Could you use it?
?
#engageug
49
Contact info
Please feel free to contact me:
John Dalsgaard
Dalsgaard Data A/S
Solbjergvej 42
Solbjerg
DK-4270 Høng
Phone: +45 4914-1271
Email: john@dalsgaard-data.dk
www.dalsgaard-data.dk
Blog: www.dalsgaard-data.eu
Twitter: @john_dalsgaard, @DalsgaardDataAS
Skype: john_dalsgaard
#engageug
50
Sources & links
● Wikipedia: Representational state transfer
● Learn REST: A Tutorial
● VIEW Tips: Brad Balassaitis on JSON-RPC
● IBM Domino Access Services 9.0.1
● Wikipedia: JSON / JavaScript Object Notation
● Introducing JSON
● JSON Tutorial
● REST services in Domino - Domino Access Services (PDF)
● Extension Library REST Services (PDF)
● Extension Library on OpenNTF (includes demo db)
● JSON test client: Chrome Postman
● Wrap an existing jar into a plugin
● Demo-DB on Bitbucket.org
#engageug
51
Sources & links
● For the advanced – check these frameworks....
– Apache Wink (what DAS etc. is build on)
– … and Wink with OpenNTF Extension Library
– Jersey
– Specifikation: Java API for RESTful Services (JAX-RS)

Mais conteúdo relacionado

Mais procurados

RNUG - Dirty Secrets of the Notes Client
RNUG - Dirty Secrets of the Notes ClientRNUG - Dirty Secrets of the Notes Client
RNUG - Dirty Secrets of the Notes ClientChristoph Adler
 
Important tips on Router and SMTP mail routing
Important tips on Router and SMTP mail routingImportant tips on Router and SMTP mail routing
Important tips on Router and SMTP mail routingjayeshpar2006
 
RNUG - HCL Notes V11 Performance Boost
RNUG - HCL Notes V11 Performance BoostRNUG - HCL Notes V11 Performance Boost
RNUG - HCL Notes V11 Performance BoostChristoph Adler
 
IBM Domino / IBM Notes Performance Tuning
IBM Domino / IBM Notes Performance Tuning IBM Domino / IBM Notes Performance Tuning
IBM Domino / IBM Notes Performance Tuning Vladislav Tatarincev
 
Domino OSGi Development
Domino OSGi DevelopmentDomino OSGi Development
Domino OSGi DevelopmentPaul Fiore
 
INF107 - Integrating HCL Domino and Microsoft 365
INF107 - Integrating HCL Domino and Microsoft 365INF107 - Integrating HCL Domino and Microsoft 365
INF107 - Integrating HCL Domino and Microsoft 365Dylan Redfield
 
Improving notes addressing experience with recent contacts
Improving notes addressing experience with recent contactsImproving notes addressing experience with recent contacts
Improving notes addressing experience with recent contactsVinayak Tavargeri
 
Enable Domino Data Access Services (DAS)
Enable Domino Data Access Services (DAS)Enable Domino Data Access Services (DAS)
Enable Domino Data Access Services (DAS)Slobodan Lohja
 
HCL Domino V12 Key Security Features Overview
HCL Domino V12 Key Security Features Overview HCL Domino V12 Key Security Features Overview
HCL Domino V12 Key Security Features Overview hemantnaik
 
Introduction to ELK
Introduction to ELKIntroduction to ELK
Introduction to ELKYuHsuan Chen
 
How to use the new Domino Query Language
How to use the new Domino Query LanguageHow to use the new Domino Query Language
How to use the new Domino Query LanguageTim Davis
 
Domino Administration Wizardry - Dark Arts Edition
Domino Administration Wizardry - Dark Arts EditionDomino Administration Wizardry - Dark Arts Edition
Domino Administration Wizardry - Dark Arts EditionKeith Brooks
 
October OpenNTF Webinar - What we like about Domino/Notes 12, recommended new...
October OpenNTF Webinar - What we like about Domino/Notes 12, recommended new...October OpenNTF Webinar - What we like about Domino/Notes 12, recommended new...
October OpenNTF Webinar - What we like about Domino/Notes 12, recommended new...Howard Greenberg
 
Bewährte Praktiken für HCL Notes/Domino-Sicherheit. Teil 2: Der Domino-Server
Bewährte Praktiken für HCL Notes/Domino-Sicherheit. Teil 2: Der Domino-ServerBewährte Praktiken für HCL Notes/Domino-Sicherheit. Teil 2: Der Domino-Server
Bewährte Praktiken für HCL Notes/Domino-Sicherheit. Teil 2: Der Domino-Serverpanagenda
 
How to fix ‘database is corrupt: cannot allocate space’ error in lotus notes
How to fix ‘database is corrupt: cannot allocate space’ error in lotus notesHow to fix ‘database is corrupt: cannot allocate space’ error in lotus notes
How to fix ‘database is corrupt: cannot allocate space’ error in lotus notesandrewscott01
 
From frustration to fascination: dissecting Replication
From frustration to fascination: dissecting ReplicationFrom frustration to fascination: dissecting Replication
From frustration to fascination: dissecting ReplicationBenedek Menesi
 
HCL Notes and Nomad Troubleshooting for Dummies
HCL Notes and Nomad Troubleshooting for DummiesHCL Notes and Nomad Troubleshooting for Dummies
HCL Notes and Nomad Troubleshooting for Dummiespanagenda
 
dominocamp2022.t1s1.dde.pptx
dominocamp2022.t1s1.dde.pptxdominocamp2022.t1s1.dde.pptx
dominocamp2022.t1s1.dde.pptxUlrich Krause
 

Mais procurados (20)

RNUG - Dirty Secrets of the Notes Client
RNUG - Dirty Secrets of the Notes ClientRNUG - Dirty Secrets of the Notes Client
RNUG - Dirty Secrets of the Notes Client
 
Important tips on Router and SMTP mail routing
Important tips on Router and SMTP mail routingImportant tips on Router and SMTP mail routing
Important tips on Router and SMTP mail routing
 
RNUG - HCL Notes V11 Performance Boost
RNUG - HCL Notes V11 Performance BoostRNUG - HCL Notes V11 Performance Boost
RNUG - HCL Notes V11 Performance Boost
 
IBM Domino / IBM Notes Performance Tuning
IBM Domino / IBM Notes Performance Tuning IBM Domino / IBM Notes Performance Tuning
IBM Domino / IBM Notes Performance Tuning
 
Domino OSGi Development
Domino OSGi DevelopmentDomino OSGi Development
Domino OSGi Development
 
INF107 - Integrating HCL Domino and Microsoft 365
INF107 - Integrating HCL Domino and Microsoft 365INF107 - Integrating HCL Domino and Microsoft 365
INF107 - Integrating HCL Domino and Microsoft 365
 
Improving notes addressing experience with recent contacts
Improving notes addressing experience with recent contactsImproving notes addressing experience with recent contacts
Improving notes addressing experience with recent contacts
 
Domino Adminblast
Domino AdminblastDomino Adminblast
Domino Adminblast
 
Daos
DaosDaos
Daos
 
Enable Domino Data Access Services (DAS)
Enable Domino Data Access Services (DAS)Enable Domino Data Access Services (DAS)
Enable Domino Data Access Services (DAS)
 
HCL Domino V12 Key Security Features Overview
HCL Domino V12 Key Security Features Overview HCL Domino V12 Key Security Features Overview
HCL Domino V12 Key Security Features Overview
 
Introduction to ELK
Introduction to ELKIntroduction to ELK
Introduction to ELK
 
How to use the new Domino Query Language
How to use the new Domino Query LanguageHow to use the new Domino Query Language
How to use the new Domino Query Language
 
Domino Administration Wizardry - Dark Arts Edition
Domino Administration Wizardry - Dark Arts EditionDomino Administration Wizardry - Dark Arts Edition
Domino Administration Wizardry - Dark Arts Edition
 
October OpenNTF Webinar - What we like about Domino/Notes 12, recommended new...
October OpenNTF Webinar - What we like about Domino/Notes 12, recommended new...October OpenNTF Webinar - What we like about Domino/Notes 12, recommended new...
October OpenNTF Webinar - What we like about Domino/Notes 12, recommended new...
 
Bewährte Praktiken für HCL Notes/Domino-Sicherheit. Teil 2: Der Domino-Server
Bewährte Praktiken für HCL Notes/Domino-Sicherheit. Teil 2: Der Domino-ServerBewährte Praktiken für HCL Notes/Domino-Sicherheit. Teil 2: Der Domino-Server
Bewährte Praktiken für HCL Notes/Domino-Sicherheit. Teil 2: Der Domino-Server
 
How to fix ‘database is corrupt: cannot allocate space’ error in lotus notes
How to fix ‘database is corrupt: cannot allocate space’ error in lotus notesHow to fix ‘database is corrupt: cannot allocate space’ error in lotus notes
How to fix ‘database is corrupt: cannot allocate space’ error in lotus notes
 
From frustration to fascination: dissecting Replication
From frustration to fascination: dissecting ReplicationFrom frustration to fascination: dissecting Replication
From frustration to fascination: dissecting Replication
 
HCL Notes and Nomad Troubleshooting for Dummies
HCL Notes and Nomad Troubleshooting for DummiesHCL Notes and Nomad Troubleshooting for Dummies
HCL Notes and Nomad Troubleshooting for Dummies
 
dominocamp2022.t1s1.dde.pptx
dominocamp2022.t1s1.dde.pptxdominocamp2022.t1s1.dde.pptx
dominocamp2022.t1s1.dde.pptx
 

Destaque

Speed up your XPages Application performance
Speed up your XPages Application performanceSpeed up your XPages Application performance
Speed up your XPages Application performanceMaarga Systems
 
ConnectED2015: IBM Domino Applications in Bluemix
ConnectED2015: 	IBM Domino Applications in BluemixConnectED2015: 	IBM Domino Applications in Bluemix
ConnectED2015: IBM Domino Applications in BluemixMartin Donnelly
 
BP204 - Take a REST and put your data to work with APIs!
BP204 - Take a REST and put your data to work with APIs!BP204 - Take a REST and put your data to work with APIs!
BP204 - Take a REST and put your data to work with APIs!Craig Schumann
 
Fun With SHA2 Certificates
Fun With SHA2 CertificatesFun With SHA2 Certificates
Fun With SHA2 CertificatesGabriella Davis
 
IBM Presents the IBM Notes and Domino Roadmap
IBM Presents the IBM Notes and Domino RoadmapIBM Presents the IBM Notes and Domino Roadmap
IBM Presents the IBM Notes and Domino RoadmapTeamstudio
 

Destaque (6)

Speed up your XPages Application performance
Speed up your XPages Application performanceSpeed up your XPages Application performance
Speed up your XPages Application performance
 
XPages: Performance-Optimierung - Ulrich Krause (eknori) SNoUG 2013
XPages: Performance-Optimierung  - Ulrich Krause (eknori) SNoUG 2013XPages: Performance-Optimierung  - Ulrich Krause (eknori) SNoUG 2013
XPages: Performance-Optimierung - Ulrich Krause (eknori) SNoUG 2013
 
ConnectED2015: IBM Domino Applications in Bluemix
ConnectED2015: 	IBM Domino Applications in BluemixConnectED2015: 	IBM Domino Applications in Bluemix
ConnectED2015: IBM Domino Applications in Bluemix
 
BP204 - Take a REST and put your data to work with APIs!
BP204 - Take a REST and put your data to work with APIs!BP204 - Take a REST and put your data to work with APIs!
BP204 - Take a REST and put your data to work with APIs!
 
Fun With SHA2 Certificates
Fun With SHA2 CertificatesFun With SHA2 Certificates
Fun With SHA2 Certificates
 
IBM Presents the IBM Notes and Domino Roadmap
IBM Presents the IBM Notes and Domino RoadmapIBM Presents the IBM Notes and Domino Roadmap
IBM Presents the IBM Notes and Domino Roadmap
 

Semelhante a RESTful services on IBM Domino/XWork

RESTful services on IBM Domino/XWork (ICON UK 21-22 Sept. 2015)
RESTful services on IBM Domino/XWork (ICON UK 21-22 Sept. 2015)RESTful services on IBM Domino/XWork (ICON UK 21-22 Sept. 2015)
RESTful services on IBM Domino/XWork (ICON UK 21-22 Sept. 2015)John Dalsgaard
 
RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)
RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)
RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)John Dalsgaard
 
REST services and IBM Domino/XWork - DanNotes 19-20. november 2014
REST services and IBM Domino/XWork - DanNotes 19-20. november 2014REST services and IBM Domino/XWork - DanNotes 19-20. november 2014
REST services and IBM Domino/XWork - DanNotes 19-20. november 2014John Dalsgaard
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleDmytro Semenov
 
Dart the better Javascript 2015
Dart the better Javascript 2015Dart the better Javascript 2015
Dart the better Javascript 2015Jorg Janke
 
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Per Henrik Lausten
 
Ten practical ways to improve front-end performance
Ten practical ways to improve front-end performanceTen practical ways to improve front-end performance
Ten practical ways to improve front-end performanceAndrew Rota
 
Use Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsUse Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsNathan Smith
 
Introduction to PostgreSQL
Introduction to PostgreSQLIntroduction to PostgreSQL
Introduction to PostgreSQLJim Mlodgenski
 
GDayX - Advanced Angular.JS
GDayX - Advanced Angular.JSGDayX - Advanced Angular.JS
GDayX - Advanced Angular.JSNicolas Embleton
 
Ledingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @LendingkartLedingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @LendingkartMukesh Singh
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScriptJorg Janke
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausWomen in Technology Poland
 
Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1Matthew Barlocker
 
OpenERP e l'arte della gestione aziendale con Python
OpenERP e l'arte della gestione aziendale con PythonOpenERP e l'arte della gestione aziendale con Python
OpenERP e l'arte della gestione aziendale con PythonPyCon Italia
 
Android development - the basics, FI MUNI, 2012
Android development - the basics, FI MUNI, 2012Android development - the basics, FI MUNI, 2012
Android development - the basics, FI MUNI, 2012Tomáš Kypta
 
Deploying Perl apps on dotCloud
Deploying Perl apps on dotCloudDeploying Perl apps on dotCloud
Deploying Perl apps on dotClouddaoswald
 

Semelhante a RESTful services on IBM Domino/XWork (20)

RESTful services on IBM Domino/XWork (ICON UK 21-22 Sept. 2015)
RESTful services on IBM Domino/XWork (ICON UK 21-22 Sept. 2015)RESTful services on IBM Domino/XWork (ICON UK 21-22 Sept. 2015)
RESTful services on IBM Domino/XWork (ICON UK 21-22 Sept. 2015)
 
RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)
RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)
RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)
 
REST services and IBM Domino/XWork - DanNotes 19-20. november 2014
REST services and IBM Domino/XWork - DanNotes 19-20. november 2014REST services and IBM Domino/XWork - DanNotes 19-20. november 2014
REST services and IBM Domino/XWork - DanNotes 19-20. november 2014
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scale
 
Dart the better Javascript 2015
Dart the better Javascript 2015Dart the better Javascript 2015
Dart the better Javascript 2015
 
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)
 
Ten practical ways to improve front-end performance
Ten practical ways to improve front-end performanceTen practical ways to improve front-end performance
Ten practical ways to improve front-end performance
 
Use Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsUse Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile Apps
 
Introduction to PostgreSQL
Introduction to PostgreSQLIntroduction to PostgreSQL
Introduction to PostgreSQL
 
GDayX - Advanced Angular.JS
GDayX - Advanced Angular.JSGDayX - Advanced Angular.JS
GDayX - Advanced Angular.JS
 
Workflow Engines + Luigi
Workflow Engines + LuigiWorkflow Engines + Luigi
Workflow Engines + Luigi
 
Ledingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @LendingkartLedingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @Lendingkart
 
Nicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JSNicolas Embleton, Advanced Angular JS
Nicolas Embleton, Advanced Angular JS
 
JavaScripts & jQuery
JavaScripts & jQueryJavaScripts & jQuery
JavaScripts & jQuery
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
 
Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1
 
OpenERP e l'arte della gestione aziendale con Python
OpenERP e l'arte della gestione aziendale con PythonOpenERP e l'arte della gestione aziendale con Python
OpenERP e l'arte della gestione aziendale con Python
 
Android development - the basics, FI MUNI, 2012
Android development - the basics, FI MUNI, 2012Android development - the basics, FI MUNI, 2012
Android development - the basics, FI MUNI, 2012
 
Deploying Perl apps on dotCloud
Deploying Perl apps on dotCloudDeploying Perl apps on dotCloud
Deploying Perl apps on dotCloud
 

RESTful services on IBM Domino/XWork

  • 1. #engageug 1 REST services and IBM Domino/XWork A presentation for EngageUG 30-31 March 2015 by John Dalsgaard
  • 2. #engageug 2 Agenda ● About me ● Webservices ● REST & JSON ● Domino/XWork – out of the box... – Domino Access Service (DAS) – Extension Library controls – Build your own – Demos ● Round up
  • 3. #engageug 3 About me ● Worked with Notes since 1995 version 4.5 ● Java since Notes 5.0.7 (2000) ● Large web-apps. (40.000+ users) ● Object Oriented approach since 1999 (yes, in LotusScript...) ● XPages & mobile apps (Appcelerator Titanium).... ● Certified Principal/advanced administrator and developer – all versions 4.6 → 9.0 ● Developer, project manager, IT manager – own company since 1998. ● IBM Champion for 2015
  • 5. #engageug 5 Webservices ● What is a webservice? – Program to program communication – Implemementation independent – ”Contract” about interface ● Traditionally SOAP & XML... – Very ”verbose” (=not ”light”) – Needs pre-/post processing to ”extract” data → Meet the ”new kid on the block”:
  • 6. #engageug 6 REST services using JSON ● REST = REpresentational State Transfer ● JSON = JavaScript Object Notation ● Why?? → Loose coupling... – Angular, Ext.js, etc. – Mobile apps/web apps ● Let's take a quick look at these terms:
  • 7. #engageug 7 REST ● Wikipedia: Representational state transfer (REST) is an abstraction of the architecture of the World Wide Web; more precisely, REST is an architectural style consisting of a coordinated set of architectural constraints applied to components, connectors, and data elements, within a distributed hypermedia system. REST ignores the details of component implementation and protocol syntax in order to focus on the roles of components, the constraints upon their interaction with other components, and their interpretation of significant data elements..... WHAT?????
  • 8. #engageug 8 REST ● Client-server architecture – Uniform interface separates client from server ● Stateless – All info in request ● Cacheable communications protocol – Almost always HTTP ● Uniform interface... – HTML, URIs, XML, JSON, MIME, meta-data.... ● Actually, WWW via HTTP can also be viewed as a REST- based architecture – so nothing new here that you did not know... :-)
  • 9. #engageug 9 ”RESTful” web-service ● Architectural style: – URI structure (base URI) – Internet media type. JSON – or: XML, Atom, … – Standard HTTP methods: ● GET ● POST ● PUT ● DELETE … also known as: CRUD (Create, Read, Update, Delete) methods
  • 10. #engageug 10 ”RESTful” web-service ● Designed for networked applications ● Using HTTP as a simple alternative to more complex mechanisms to connect between machines: – WebServices (SOAP, WSDLs etc.) – CORBA – RPC
  • 11. #engageug 11 ”RESTful” web-service ● Example – SOAP: <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:body pb="http://www.acme.com/phonebook"> <pb:GetUserDetails> <pb:UserID>12345</pb:UserID> </pb:GetUserDetails> </soap:Body> </soap:Envelope> – … must to be sent via a request (HTTP POST) ● Example – RESTful web-service: http://www.acme.com/phonebook/UserDetails/12345 – … just a URL!! (HTTP GET) – simple....
  • 12. #engageug 12 JSON ● Wikipedia: JSON (/ˈdʒeɪsən/ jay-sən), or JavaScript Object Notation, is an open standard format that uses human-readable text to transmit data objects consisting of attribute–value pairs. It is used primarily to transmit data between a server and web application, as an alternative to XML. Although originally derived from the JavaScript scripting language, JSON is a language-independent data format. Code for parsing and generating JSON data is readily available in a large variety of programming languages.
  • 13. #engageug 13 JSON ● A syntax for storing & exchanging data ● An easier to use alternative to XML ● Is a lightweight data interchange format ● Is language independant ● Is ”self-describing” and easy to understand JSON uses JavaScript syntax, but the JSON format is text only, just like XML. Text can be read and used as a data format by any programming language...
  • 14. #engageug 14 JSON vs. XML ● XML <employees> <employee> <firstName>John</firstName> <lastName>Doe</lastName> </employee> <employee> <firstName>Anna</firstName> <lastName>Smith</lastName> </employee> <employee> <firstName>Peter</firstName> <lastName>Jones</lastName> </employee> </employees> ● JSON {"employees":[ {"firstName":"John", "lastName":"Doe"}, {"firstName":"Anna", "lastName":"Smith"}, {"firstName":"Peter", "lastName":"Jones"} ]}
  • 15. #engageug 15 JSON syntax ● Object: {} { 'text' : 'Hello world!', 'number' : 123, 'valid' : true } ● Array: [] { 'numbers' : [ 1, 2, 3 ] } { 'objects' : [ {'a':1}, {'b':2}, {'c':3} ] } ● Value: – string, number, object, array, boolean, null ● Please note: NO date/time type...!!! Grrrrr.....
  • 16. #engageug 16 JSON and JavaScript var text = ”{ 'name' : 'EngageUG', 'current' : 2015 }”; ● Create an object: – var engageUG = JSON.parse(text); ● Create text representation of an object: – var engageUGText = JSON.stringify(engageUG); ● Refer to attributes: – var name = engageUG.name; ● Add another attribute: – engageUG['venue'] = 'Ghent'
  • 17. #engageug 17 Domino/XWork - out of the box ● Webservices (SOAP, XML, etc...) – Consumer (client) – since 8.0 – Provider (server) – since 7.0 – Written in LotusScript/Java RESTful service using JSON → ● Domino Access Services (DAS) – core service - since 9.0.1 – data service - since 8.5.3 UP1 (~DDS) – calendar service - since 9.0.1
  • 18. #engageug 18 Domino Access Services ● Implemented as OSGi plugins/servlets ● Based on Apache Wink ● How to enable & configure – Web access – Enable Domino Access Service (DAS) – Enable for database – Enable for specific elements
  • 19. #engageug 19 Enable web access ● HTTP Server must be started. – Check console: show tasks HTTP Server Listen for connect requests on TCP Port:80 ● Use internet sites – just do it! – Activate in server document – Create Internet site document for domain ● After changes: restart task http ● Check: – Open the server on the port you saw on the console – http://server.dom.dk:80/ (leave out port if 80)
  • 20. #engageug 20 Check DAS Open: server.dom.dk/api – lists service and their state
  • 21. #engageug 21 Enable data service ● On Internet site document (configuration tab): ● Need to refresh http to take effect – tell http refresh
  • 22. #engageug 22 DAS: List all ”services” (db's) ● Open: server.dom.dk/api/data
  • 23. #engageug 23 DAS: Open a specific database ● Try: server.dom.dk/reports.nsf/api/data/collections → We need to enable DAS for the database
  • 24. #engageug 24 DAS: Enable for database ● On the advanced properties of the database: ● Select level in ”Allow Domino Data Service”: ● Important decision: Views and/or documents
  • 25. #engageug 25 DAS: Open database again ● Try: server.dom.dk/demo/json.nsf/api/data/collections
  • 26. #engageug 26 DAS: Enable for view ● We need to enable DAS for the view first ● Open the view in Domino Designer ● On the view properties – advanced tab ● Enable: ”Allow Domino Data Service operations”: ● Save the view, open it using the url returned
  • 27. #engageug 27 DAS: Open a view ● Try: server.dom.dk/.../collections/unid/A892133953... ● ● Heureka!! - we see a list of all documents! ● Also try: server.dom.dk/.../collections/name/persons
  • 28. #engageug 28 DAS: Open a document ● Try: server.dom.dk/.../documents/unid/33735D0BC... ● Requires ”Views and documents” to be set in DB props.
  • 29. #engageug 29 DAS: Writing back... ● Remember content type MUST be: – application/json – Set ”Content-type” in header of request ● If you get ”405 Method not allowed” – Enable method in internet site ● By default these are NOT enabled: – PUT – PATCH – DELETE – Or override header in your request ● ”X-HTTP-Method-Override” : ”POST”
  • 30. #engageug 30 DAS: Save existing document ● Use ”PATCH” to change specific fields – url: …/documents/unid/33735D0BCE799.... – updates only the fields in the request ● Use ”PUT” to change ALL fields – url: …/documents/unid/33735D0BCE799.... – All fields are replaced with the fields from request – fields not specified are blanked....
  • 31. #engageug 31 DAS: Create / delete document ● Use ”POST” to create a document with specified fields – url: …/documents?form=Person – You MUST add form to url ● Use ”DELETE” to remove the document entirely – url: …/documents/unid/33735D0BCE799....
  • 32. #engageug 32 DAS: Data service - more... ● See the design of a view: – //.../collections/name/persons/design ● Compute values on update of document – //.../documents/unid/33735D0BC...? computewithform=true ● Use ”normal” url actions to control view collection, e.g. – //.../collections/name/persons?start=1&count=2
  • 33. #engageug 33 DAS: Calendar service ● There is a catch to enable this service... – In the internet site document you have to type ”Calendar” as an option.... - it is not predefined
  • 34. #engageug 34 DAS: Calendar service ● Built on the new calendar backend classes in Domino/XWork 9.0.1 ● Current user's calendars, email address, and services server.dom.dk/api/calendar ● Events from specific calendar server.dom.dk/demo/cal.nsf/api/calendar/events ● Events from specific calendar (iCal format) server.dom.dk/.../events?format=iCalendar ● Only shows events that have NOT started yet
  • 35. #engageug 35 DAS: Calendar service ● You can also CREATE new events!!! – Using POST and specifiying all fields under an ”events” object – Handles the various types: Meeting, appointment, etc. – Will send invites to participants of meetings – Handles notifications – Actions for complete workflow: Accept, decline, delegate, etc. – … and more!
  • 36. #engageug 36 Extension Library ● Comes with the Domino 9.0.x server (and Domino Designer) ● Just needs to be enabled in XSP properties ● Does NOT require DAS to be enabled ● Provides easy to use controls: – REST Service (data) – Remote Service (JSON-RPC) ● Allow you to run serverside code as a REST service... ● Also provide support for: – NSF and OSGi servlets... - advanced stuff!!
  • 37. #engageug 37 Extension Library ● Why would you use it...???? ● → Allows further customizations – Include/exclude certain data columns – Include/exclude system columns (@....) – Calculate contents of own columns – Run code before/after CRUD operations – Sort and search – Create ”handles” (variable) to use in XPage as datasources
  • 38. #engageug 38 Ext. Lib. REST Service ● Create a new XPage ● Drag a ”REST Service” component to it: ● Fill in ”the blanks” – pathInfo → identifies the service – Select service – Fill in the info needed for that type of service
  • 39. #engageug 39 Ext. Lib. REST Service ● To call your service you open the XPage with the REST Service control(s) and add the pathInfo, e.g.: server.dom.dk/db.nsf/yourpage.xsp/persons – ...assuming you set pathInfo to ”persons” for one of the REST Services on the ”yourpage” XPage
  • 40. #engageug 40 Ext. Lib. NSF servlet ● You can register a servlet to e.g. give you a JSON representation of a view ● Extends DefaultServletFactory – add a factory that maps to a service (e.g. view name) – Register in Code/Java/META-INF/services ● file: com.ibm.xsp.adapter.servletFactory → Full name of servlet class ● Refer to using url, e.g.: server.dom.dk/db.nsf/xsp/services/Persons ● Does NOT require DAS to be enabled
  • 41. #engageug 41 Build your own... ● Why?? – … using your own MVC – Java objects – Full control – Does NOT require DAS to be enabled ● Handy ”ingredients” – Java – XPages ● Use an ”XAgent” (or an NSF/OSGi servlet) ● Select a JSON ”package” – Built-in with XPages – Or others like GSON – (wrap as plugin!!)
  • 42. #engageug 42 Build your own... ● Use cases: – Generate JSON directly from your Java class – Consume your JSON POSTs directly by parsing them to the corresponding Java class → Ready to use in your logic – Control e.g. date formating generally for all Date fields ● Eg. use ISO datetime format
  • 43. #engageug 43 Build your own... ● LotusScript.... – You didn't expect me to say this! – An option if you have existing systems with business logic written in LotusScript – Simple: ● print – correct content-type ● print …. your JSON (as text) – … but I would not advice to build new this way → you would like to use a library/package to build your JSON for you! ● Does NOT require DAS to be enabled
  • 44. #engageug 44 Demo... ● Server: – Local VM with Domino 9.0.1FP2 on CentOS 6.6 – Extension Library (from IBM) – OpenNTF Domino API installed – OpenNTF Essentials installed ● A demo database – Showing an MVC pattern I use – Added a number of JSON demos – Is available for download ● Tool for testing: – Google Chrome Postman
  • 45. #engageug 45 Demo... ● DAS – core – data – calendar ● Extension Library REST Service ● Build you own – Built-in JSON classes – GSON based on Java objects – LotusScript... ● Download DB from Bitbucket.org
  • 47. #engageug 47 Round Up ● What are REST and JSON ● GET, POST, PUT, DELETE – ~CRUD ● Domino Access Services – out of the box – Data – Calendar ● Extension Library – REST Service – (Remote Service) ● Build own solution – Java & JSON ”package” - …. & LotusScript ;-)
  • 48. #engageug 48 Questions?? ● Did you learn something? ● Could you use it? ?
  • 49. #engageug 49 Contact info Please feel free to contact me: John Dalsgaard Dalsgaard Data A/S Solbjergvej 42 Solbjerg DK-4270 Høng Phone: +45 4914-1271 Email: john@dalsgaard-data.dk www.dalsgaard-data.dk Blog: www.dalsgaard-data.eu Twitter: @john_dalsgaard, @DalsgaardDataAS Skype: john_dalsgaard
  • 50. #engageug 50 Sources & links ● Wikipedia: Representational state transfer ● Learn REST: A Tutorial ● VIEW Tips: Brad Balassaitis on JSON-RPC ● IBM Domino Access Services 9.0.1 ● Wikipedia: JSON / JavaScript Object Notation ● Introducing JSON ● JSON Tutorial ● REST services in Domino - Domino Access Services (PDF) ● Extension Library REST Services (PDF) ● Extension Library on OpenNTF (includes demo db) ● JSON test client: Chrome Postman ● Wrap an existing jar into a plugin ● Demo-DB on Bitbucket.org
  • 51. #engageug 51 Sources & links ● For the advanced – check these frameworks.... – Apache Wink (what DAS etc. is build on) – … and Wink with OpenNTF Extension Library – Jersey – Specifikation: Java API for RESTful Services (JAX-RS)