Engage 2019 session with Tom Van Aken (https://twitter.com/vanakentom):
Your Data in the Major Leagues: A Practical and Updated Guide to RESTful Domino v10
Things are moving fast with many new tools and toys in our hands. While Domino v10 creates a whole new world of possibilities, we still need to interact with other internal and external applications. One of the key technologies to do that is the RESTful services and we have an updated toolbox now. Regardless of your experience, come to this session to see what options are available to you, what pitfalls you may experience and how to break down the borders between your applications and others. We will present the basic concepts and best practices, allowing you to walk away with the techniques that you will need to take your applications to the next level. Last but not the least, we will show you practical examples on how you provide RESTful services for other applications and how you can use REST data to enrich your applications using the the new capabilities.
Speakers:
Serdar Basegmez , Developi Information Systems
Tom Van Aken, GroupWave
15 May 2019
19. #engageug
URI GET PUT POST DELETE
/contacts/ List Contacts Replace Contacts Create New Contact Delete Contacts
/contacts/id Retrieve a Contact Replace a Contact N/A (generally) Delete a Contact
Source: https://en.wikipedia.org/wiki/Representational_state_transfer
22. #engageug
Some InspiraCon
• New Front-ends and Enhanced UX
• JS Frameworks (e.g. Angular, React), Mobile Apps, etc.
• Grids, quick searches, becer type-aheads, etc.
• Richer experiences with chatbots, AI, etc.
• IntegraCon for third party sites/applicaCons
• Pull exchange rates, get weather info
• Get customers from CRM, create leads
• Upload to Box, Send to Slack…
• AutomaCng processes using APIs
• Push data to the AccounCng system…
• Access to ERP, check the inventory, iniCate a new PO
User Experience
Business Processes
Integration
34. #engageug
J2EE (JAX-RS) Methods
• Drawbacks:
• Plugin only
• Difficult if you are not familiar, Takes Cme to learn
• Overkill?
• Not suitable for small projects and simple needs
• Tool selecCon is criCcal.
• Apache Wink is old school
• IntegraCng alternaCves might be difficult
38. #engageug
Providing RESTful Services on Domino
Benefits Challenges Suggested When?
Domino Access Services
(DAS)
Zero-setup
True RESTful
No Programming
No Business Logic
Exposes the Internals
Simple data exchange
ExtLib Components
for REST
Less Backend Code
Minimal Setup
Partial/Full Customization
Error Handling
Spaghetti Code Risk
URL Convention
Simple needs for a limited
scope
Hardcoding
(XAgents, Web agents…)
Tailor-made
Any Language is OK
Hardcoding Everything
Spaghetti Code Risk
URL Conventions
Very specific needs for a
limited scope
J2EE / JAX-RS
Tailor-made
OSGi Benefits
True RESTful
Learning Curve
Barrier to Entry
Environment Setup
Large scope implementation,
API Design
Node.js
Tailor Made
Node.js Benefits
True RESTful
Learning Curve
Still Improving
Environment Setup
Modernization Projects
SmartNSF Beta
Less Backend Code
True RESTful
Learning Curve
Limited Support
Simple needs for a limited
scope
41. #engageug
ConnecCng Java
• Pulling exchange rates via Java (Agent or Managed Beans)
public Double receiveEurUsdRate() throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet("http://api.fixer.io/latest?base=USD");
CloseableHttpResponse response = httpclient.execute(httpGet);
try {
HttpEntity entity = response.getEntity();
// This is the worst practice ever!
// We don't check anything! Everything can go wrong...
JsonJavaObject ratesMap = (JsonJavaObject) JsonParser.fromJson(JsonJavaFactory.instanceEx,
EntityUtils.toString(entity));
JsonJavaObject rates = ratesMap.getAsObject("rates");
// We can write values into a NotesDocument
return rates.getAsDouble("EUR");
} finally {
response.close();
}
}
* Networking is a restricted operation for Agents! Agent Security should be configured.
Create an HTTP client
Get a Response
Convert to JSON
42. #engageug
ConnecCng SSJS
• Pulling exchange rates on an XPage acCon
<xp:button
id="button1" value="What is the exchange rate?">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial"
refreshId="computedField1">
<xp:this.action><![CDATA[#{javascript:
viewScope.EurUsdRate = test.ExchangeRate.receiveEurUsdRate()
}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
* This code will run multiple times for each page cycle.
Always cache values!
Call Java (via Managed Bean)
50. #engageug
Consuming RESTful Services
Usage Examples
XPages
Java - SSJS
Through SSJS or Java beans
Call when needed
Sending message to Slack
Integrations to IBM Watson
Social Media Interaction
Agents
Java - Lotusscript
Scheduled agents
Call by Notes Client
Periodically pulling exchange rates
Pushing data to remote service
Training IBM Watson AI
Using SDKs
Access to services using libraries
Call when needed
Schedule / Trigger
Accessing IBM Connections
Integration to Box