SlideShare a Scribd company logo
By Acellam Guy
@mistaguy
1. Consume JSON REST based services
2. Publish data or microflows through REST API's
3. (Real time) Synchronization of data between Mendix
applications
By Acellam Guy
@mistaguy
REST ?
• REST stands for Representational StateTransfer
• BuildWeb services that are lightweight, maintainable, and scalable
• A service based on REST is called a RESTful service
• REST is not dependent on any protocol
By Acellam Guy
@mistaguy
Features of a RESTful webservice
• Representations
• Messages
• URIs
• Uniform interface
• Stateless
• Links between resources
• Caching
By Acellam Guy
@mistaguy
Representations
• Resources and how to provide access to these resources
• Format of representation JSON,XML ,etc
• Both client and server should be able to comprehend format of
representation
• A representation should be able to completely represent a resource
• The representation should be capable of linking resources to each other
By Acellam Guy
@mistaguy
Messages
• Contains the actual data and metadata about the message
• Based on HTTP 1.1
By Acellam Guy
@mistaguy
URI
• The job of a URI is to identify a resource or a collection of resources
• The actual operation is determined by an HTTP verb
Eg.
http://localhost:8080/Persons/1
This URL has following
format: Protocol://ServiceName/ResourceType/ResourceID
By Acellam Guy
@mistaguy
Uniform Interface
• Systems should have a uniform interface. HTTP 1.1 provides a set of
methods, called verbs, for this purpose
Method Operation performed on server Quality
GET Read a resource. Safe
PUT Insert a new resource or update if the resource already exists. Idempotent
POST Insert a new resource. Also can be used to update an existing resource. N/A
DELETE Delete a resource . Idempotent
OPTIONS List the allowed operations on a resource. Safe
HEAD Return only the response headers and no response body. Safe
By Acellam Guy
@mistaguy
Statelessness
• Does not maintain the application state for any client
• A request cannot be dependent on a past request and a service treats each
request independently
A stateless design looks like so:
Request1: GET http://MyService/Persons/1 HTTP/1.1
Request2: GET http://MyService/Persons/2 HTTP/1.1
Each of these requests can be treated separately.
A stateful design, on the other hand, looks like so:
Request1: GET http://MyService/Persons/1 HTTP/1.1
Request2: GET http://MyService/NextPerson HTTP/1.1
By Acellam Guy
@mistaguy
Links Between Resources
• A resource representation can contain links to other resources like an HTML
page contains links to other pages
• The user does not need a map before coming to a website
• A service can be (and should be) designed in the same way
By Acellam Guy
@mistaguy
Caching
• Caching is the concept of storing the generated results and using the stored
results instead of generating them repeatedly if the same request arrives in
the near future
By Acellam Guy
@mistaguy
Mendix REST Module
• Mendix 4.4.4+ or Mendix 5.3.1+
• If you want to publish REST services or use the data synchronization features,
addIVK_OpenServiceOverview to your main navigation.
add StartPublishServices to the startup sequence of your application
• map your administrative project role to the Administratorrole in the RestServices
for admin features
• The 'rest/' request handler needs to be opened if running in the Mendix Standard
Cloud (or on premise).
• strongly recommended to not use the default HSQLDB engine if you want to
publish RestServices while running locally
By Acellam Guy
@mistaguy
Consuming REST services
• The operations in the 'Consume' folder of the module provide the necessary
tools to invoke data
• The core of all these operations is the java action request
By Acellam Guy
@mistaguy
The REQUEST java action
• Request performs an HTTP request and provides the means to both send data and receive
data over HTTP
• Parameters
• Method : HTTP 1.1 verbs
• URL : location of the service
• optRequestData : provides parameters
• optResponseData : provides response
• ResquestResult : HTTP response
• sendWithFormEncoding
By Acellam Guy
@mistaguy
RequestResult Object
• contains the meta information of a response
• Response code
• Etag
• ResponseBody :the full and raw response body of the request.
By Acellam Guy
@mistaguy
Sending Request Headers
• addHeaderToNextRequest : will add a header to the next (and only the next)
request that will be made by the current microflow
By Acellam Guy
@mistaguy
Authentication
• Only supports Basic authentication out of the box
• Other authentication mechanism such as Oauth can be integrated
By Acellam Guy
@mistaguy
Consume Methods
• get :Tries to retrieve an object from the provided resourceURL
• get2: Similar to get, but also accepts a requestData parameter
• ?q=Rest%20Services‘
• getCollection : gets a list of objects. JSON array
• getCollectionAsync
• post
• delete
• put
• getRequestConsumerError
By Acellam Guy
@mistaguy
Template URLS
• This makes it possible to substitute values directly in an URL
By Acellam Guy
@mistaguy
Publishing webservices
• Publishing operations, based on a single microflow.
• Publishing a part of your data model, and providing a typical rest based API
to retrieve, update, delete, create and even real-time sync data.
• PLEASE NOTETHATTO BE ABLETO PUBLISH ANY SERVICE,THE
MICROFLOW STARTPUBLISHSERVICES SHOULD BE CALLED DURING
STARTUP OFTHE APP!
• Accessible via http://apphost/rest/yourservice
By Acellam Guy
@mistaguy
Publishing a microflow
• similar to publishing a webservice
• instead of SOAP it uses JSON based messages
• Has a single transient object as argument.
• Each field in this transient object is considered a parameter (from HTTP perspective)
• The return type of the microflow should be a transient object or a String or a filedocument
• Publish by calling CreateMicroflowService with the microflow that provides the
implementation
By Acellam Guy
@mistaguy
Microflow with template path
• Allows for constructing more complex URLs, from which values are parsed
Eg.
groups/{groupId}/users/{userId}
http://myapp.com/rest/groups/123/users/John
By Acellam Guy
@mistaguy
Publishing a data service
• JSON based API to list, retrieve, create, update, delete and track objects in
your database
• Documentation is generated automatically
By Acellam Guy
@mistaguy
End points on the service
By Acellam Guy
@mistaguy
How the data service works
• persistent entity in your database acting as data source
• transient object that acts as view object of your data
• Publish Microflow has the responsibility of converting source objects into
view objects
• Update Microflow is responsible for transforming a view as provided by
some consumer into real data in your database
• Each source object should be uniquely identifiable by a single key attribute
By Acellam Guy
@mistaguy
Example
• GET <your-app>/rest/<service name>/<identifier>
By Acellam Guy
@mistaguy
Creating a new webservice
• Add IVK_OpenServiceOverview to your navigation and create a new
Published Service after starting your app
• best practice is to use the GetOrCreateDataService microflow in the
startup microflow to create your service configuration
By Acellam Guy
@mistaguy
Configuring the service
• Its done on the form or the create service microflow
• Core configuration are:
• Name
• Description
• Source Entity
• Source Key Attribute
• Source Constraint : xpath
• Authentication Role
• On Publish Microflow
• On Update Microflow
• On Delete Microflow
By Acellam Guy
@mistaguy
Features
• Enable GET : HTTP GET
• Enable Listing : HTTP GET
• Enable Update : HTTP POST or PUT
• Enable Create : HTTP POST
• Enable Delete : HTTP DELETE
• Enable Change Log: caching
• Enable StrictVersion:
By Acellam Guy
@mistaguy
Securing Published webservice
• *
• Rolename
• Module.Microflowname : Authentication details found in the header eg key
By Acellam Guy
@mistaguy
JSON Serialization
• Converts transient object to JSON
• Nearest json type
• For each owned reference that points to a transient object, another
key/value pair is added to the object
• For each owned referenceset that points to a transient object, the same
approach is taken, except that the value is an array ([])
• Manual serialization process by use of serializeObjectToJson java action.
By Acellam Guy
@mistaguy
By Acellam Guy
@mistaguy
JSON Desrialization
• an be triggered manually by calling deserializeJsonToObject
• Converts the json from the consumer into a mendix transient object
• key/value pair for primitive attribute in transient object
• If the primitive is of type string, but the member with the same name in the
transient object is a reference, the process assumes that the string value represents
an url.
• If the member in the target object is a reference, and the value is a JSON object, a
new object of the child type of the reference is instantiated
• If target is reference set and JSON is array then reference set is created
By Acellam Guy
@mistaguy
By Acellam Guy
@mistaguy
Assignment
• Consume the twitter rest API and show the recent tweets for your profile
By Acellam Guy
@mistaguy
References
• http://www.drdobbs.com/web-development/restful-web-services-a-
tutorial/240169069
• https://github.com/mendix/RestServices

More Related Content

What's hot

REST Service Authetication with TLS & JWTs
REST Service Authetication with TLS & JWTsREST Service Authetication with TLS & JWTs
REST Service Authetication with TLS & JWTs
Jon Todd
 
User Management Life Cycle with Keycloak
User Management Life Cycle with KeycloakUser Management Life Cycle with Keycloak
User Management Life Cycle with Keycloak
Muhammad Edwin
 
SIngle Sign On with Keycloak
SIngle Sign On with KeycloakSIngle Sign On with Keycloak
SIngle Sign On with Keycloak
Julien Pivotto
 
DevSum: Azure AD B2C Application security made easy
DevSum: Azure AD B2C Application security made easyDevSum: Azure AD B2C Application security made easy
DevSum: Azure AD B2C Application security made easy
Sjoukje Zaal
 
Azure AD Connect
Azure AD ConnectAzure AD Connect
Azure AD Connect
Sasha Rosenbaum
 
SCIM presentation from CIS 2012
SCIM presentation from CIS 2012SCIM presentation from CIS 2012
SCIM presentation from CIS 2012
Twobo Technologies
 
IdP, SAML, OAuth
IdP, SAML, OAuthIdP, SAML, OAuth
IdP, SAML, OAuth
Dan Brinkmann
 
Enable Authentication and Authorization with Azure Active Directory and Sprin...
Enable Authentication and Authorization with Azure Active Directory and Sprin...Enable Authentication and Authorization with Azure Active Directory and Sprin...
Enable Authentication and Authorization with Azure Active Directory and Sprin...
VMware Tanzu
 
Demystifying SAML 2.0,Oauth 2.0, OpenID Connect
Demystifying SAML 2.0,Oauth 2.0, OpenID ConnectDemystifying SAML 2.0,Oauth 2.0, OpenID Connect
Demystifying SAML 2.0,Oauth 2.0, OpenID Connect
Vinay Manglani
 
What's inside "migrating to biz talk server 2020" Book (BizTalk360 Webinar)
What's inside "migrating to biz talk server 2020" Book (BizTalk360 Webinar)What's inside "migrating to biz talk server 2020" Book (BizTalk360 Webinar)
What's inside "migrating to biz talk server 2020" Book (BizTalk360 Webinar)
BizTalk360
 
Snyk Intro - Developer Security Essentials 2022
Snyk Intro - Developer Security Essentials 2022Snyk Intro - Developer Security Essentials 2022
Snyk Intro - Developer Security Essentials 2022
Liran Tal
 
Azure AD Presentation - @ BITPro - Ajay
Azure AD Presentation - @ BITPro - AjayAzure AD Presentation - @ BITPro - Ajay
Azure AD Presentation - @ BITPro - Ajay
Anoop Nair
 
WSO2 Identity Server - Getting Started
WSO2 Identity Server - Getting StartedWSO2 Identity Server - Getting Started
WSO2 Identity Server - Getting Started
Ismaeel Enjreny
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
Araf Karsh Hamid
 
All Day DevOps - Azure DevOps from Start to Star
All Day DevOps - Azure DevOps from Start to StarAll Day DevOps - Azure DevOps from Start to Star
All Day DevOps - Azure DevOps from Start to Star
Ángel Rayo
 
Liferay as a headless platform
Liferay as a headless platform  Liferay as a headless platform
Liferay as a headless platform
Jorge Ferrer
 
Introduction to Azure AD and Azure AD B2C
Introduction to Azure AD and Azure AD B2CIntroduction to Azure AD and Azure AD B2C
Introduction to Azure AD and Azure AD B2C
Joonas Westlin
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architecture
The Software House
 
Power Platform ALM with DevOps
Power Platform ALM with DevOpsPower Platform ALM with DevOps
Power Platform ALM with DevOps
Christopher R. Barber
 
Cloud App Security Customer Presentation.pdf
Cloud App Security Customer Presentation.pdfCloud App Security Customer Presentation.pdf
Cloud App Security Customer Presentation.pdf
ErikHof4
 

What's hot (20)

REST Service Authetication with TLS & JWTs
REST Service Authetication with TLS & JWTsREST Service Authetication with TLS & JWTs
REST Service Authetication with TLS & JWTs
 
User Management Life Cycle with Keycloak
User Management Life Cycle with KeycloakUser Management Life Cycle with Keycloak
User Management Life Cycle with Keycloak
 
SIngle Sign On with Keycloak
SIngle Sign On with KeycloakSIngle Sign On with Keycloak
SIngle Sign On with Keycloak
 
DevSum: Azure AD B2C Application security made easy
DevSum: Azure AD B2C Application security made easyDevSum: Azure AD B2C Application security made easy
DevSum: Azure AD B2C Application security made easy
 
Azure AD Connect
Azure AD ConnectAzure AD Connect
Azure AD Connect
 
SCIM presentation from CIS 2012
SCIM presentation from CIS 2012SCIM presentation from CIS 2012
SCIM presentation from CIS 2012
 
IdP, SAML, OAuth
IdP, SAML, OAuthIdP, SAML, OAuth
IdP, SAML, OAuth
 
Enable Authentication and Authorization with Azure Active Directory and Sprin...
Enable Authentication and Authorization with Azure Active Directory and Sprin...Enable Authentication and Authorization with Azure Active Directory and Sprin...
Enable Authentication and Authorization with Azure Active Directory and Sprin...
 
Demystifying SAML 2.0,Oauth 2.0, OpenID Connect
Demystifying SAML 2.0,Oauth 2.0, OpenID ConnectDemystifying SAML 2.0,Oauth 2.0, OpenID Connect
Demystifying SAML 2.0,Oauth 2.0, OpenID Connect
 
What's inside "migrating to biz talk server 2020" Book (BizTalk360 Webinar)
What's inside "migrating to biz talk server 2020" Book (BizTalk360 Webinar)What's inside "migrating to biz talk server 2020" Book (BizTalk360 Webinar)
What's inside "migrating to biz talk server 2020" Book (BizTalk360 Webinar)
 
Snyk Intro - Developer Security Essentials 2022
Snyk Intro - Developer Security Essentials 2022Snyk Intro - Developer Security Essentials 2022
Snyk Intro - Developer Security Essentials 2022
 
Azure AD Presentation - @ BITPro - Ajay
Azure AD Presentation - @ BITPro - AjayAzure AD Presentation - @ BITPro - Ajay
Azure AD Presentation - @ BITPro - Ajay
 
WSO2 Identity Server - Getting Started
WSO2 Identity Server - Getting StartedWSO2 Identity Server - Getting Started
WSO2 Identity Server - Getting Started
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
 
All Day DevOps - Azure DevOps from Start to Star
All Day DevOps - Azure DevOps from Start to StarAll Day DevOps - Azure DevOps from Start to Star
All Day DevOps - Azure DevOps from Start to Star
 
Liferay as a headless platform
Liferay as a headless platform  Liferay as a headless platform
Liferay as a headless platform
 
Introduction to Azure AD and Azure AD B2C
Introduction to Azure AD and Azure AD B2CIntroduction to Azure AD and Azure AD B2C
Introduction to Azure AD and Azure AD B2C
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architecture
 
Power Platform ALM with DevOps
Power Platform ALM with DevOpsPower Platform ALM with DevOps
Power Platform ALM with DevOps
 
Cloud App Security Customer Presentation.pdf
Cloud App Security Customer Presentation.pdfCloud App Security Customer Presentation.pdf
Cloud App Security Customer Presentation.pdf
 

Similar to Mendix rest services

J2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environmentJ2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environment
joearunraja2
 
CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)
CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)
CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)
Sam Bowne
 
Tutorial_Rest_API_For_Beginners_125.pptx
Tutorial_Rest_API_For_Beginners_125.pptxTutorial_Rest_API_For_Beginners_125.pptx
Tutorial_Rest_API_For_Beginners_125.pptx
T.Choithram & Sons Dubai
 
BITM3730 11-1.pptx
BITM3730 11-1.pptxBITM3730 11-1.pptx
BITM3730 11-1.pptx
MattMarino13
 
BITM3730 Networking.pdf
BITM3730 Networking.pdfBITM3730 Networking.pdf
BITM3730 Networking.pdf
MattMarino13
 
Windows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside worldWindows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside world
Prabhakaran Soundarapandian
 
REST Methodologies
REST MethodologiesREST Methodologies
REST Methodologies
jrodbx
 
web connectivity in IoT
web connectivity in IoTweb connectivity in IoT
web connectivity in IoT
FabMinds
 
Windows 8 Apps and the Outside World
Windows 8 Apps and the Outside WorldWindows 8 Apps and the Outside World
BeJUG JAX-RS Event
BeJUG JAX-RS EventBeJUG JAX-RS Event
BeJUG JAX-RS Event
Stephan Janssen
 
Rest
Rest Rest
AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
Ganesh Chavan
 
Browser
BrowserBrowser
Browser
Shweta Oza
 
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
IT2255 Web Essentials - Unit V Servlets and Database ConnectivityIT2255 Web Essentials - Unit V Servlets and Database Connectivity
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
pkaviya
 
SCWCD : The web client model
SCWCD : The web client modelSCWCD : The web client model
SCWCD : The web client model
Ben Abdallah Helmi
 
rest-api-basics.pptx
rest-api-basics.pptxrest-api-basics.pptx
rest-api-basics.pptx
AgungSutikno1
 
Lecture 2: Servlets
Lecture 2:  ServletsLecture 2:  Servlets
Lecture 2: Servlets
Fahad Golra
 
restapitest-anil-200517181251.pdf
restapitest-anil-200517181251.pdfrestapitest-anil-200517181251.pdf
restapitest-anil-200517181251.pdf
mrle7
 
Rest API Testing
Rest API TestingRest API Testing
Rest API Testing
upadhyay_25
 
REST Basics
REST BasicsREST Basics
REST Basics
Ivano Malavolta
 

Similar to Mendix rest services (20)

J2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environmentJ2EE : Java servlet and its types, environment
J2EE : Java servlet and its types, environment
 
CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)
CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)
CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)
 
Tutorial_Rest_API_For_Beginners_125.pptx
Tutorial_Rest_API_For_Beginners_125.pptxTutorial_Rest_API_For_Beginners_125.pptx
Tutorial_Rest_API_For_Beginners_125.pptx
 
BITM3730 11-1.pptx
BITM3730 11-1.pptxBITM3730 11-1.pptx
BITM3730 11-1.pptx
 
BITM3730 Networking.pdf
BITM3730 Networking.pdfBITM3730 Networking.pdf
BITM3730 Networking.pdf
 
Windows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside worldWindows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside world
 
REST Methodologies
REST MethodologiesREST Methodologies
REST Methodologies
 
web connectivity in IoT
web connectivity in IoTweb connectivity in IoT
web connectivity in IoT
 
Windows 8 Apps and the Outside World
Windows 8 Apps and the Outside WorldWindows 8 Apps and the Outside World
Windows 8 Apps and the Outside World
 
BeJUG JAX-RS Event
BeJUG JAX-RS EventBeJUG JAX-RS Event
BeJUG JAX-RS Event
 
Rest
Rest Rest
Rest
 
AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
 
Browser
BrowserBrowser
Browser
 
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
IT2255 Web Essentials - Unit V Servlets and Database ConnectivityIT2255 Web Essentials - Unit V Servlets and Database Connectivity
IT2255 Web Essentials - Unit V Servlets and Database Connectivity
 
SCWCD : The web client model
SCWCD : The web client modelSCWCD : The web client model
SCWCD : The web client model
 
rest-api-basics.pptx
rest-api-basics.pptxrest-api-basics.pptx
rest-api-basics.pptx
 
Lecture 2: Servlets
Lecture 2:  ServletsLecture 2:  Servlets
Lecture 2: Servlets
 
restapitest-anil-200517181251.pdf
restapitest-anil-200517181251.pdfrestapitest-anil-200517181251.pdf
restapitest-anil-200517181251.pdf
 
Rest API Testing
Rest API TestingRest API Testing
Rest API Testing
 
REST Basics
REST BasicsREST Basics
REST Basics
 

Recently uploaded

2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
aymanquadri279
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 

Recently uploaded (20)

2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 

Mendix rest services

  • 1. By Acellam Guy @mistaguy 1. Consume JSON REST based services 2. Publish data or microflows through REST API's 3. (Real time) Synchronization of data between Mendix applications
  • 2. By Acellam Guy @mistaguy REST ? • REST stands for Representational StateTransfer • BuildWeb services that are lightweight, maintainable, and scalable • A service based on REST is called a RESTful service • REST is not dependent on any protocol
  • 3. By Acellam Guy @mistaguy Features of a RESTful webservice • Representations • Messages • URIs • Uniform interface • Stateless • Links between resources • Caching
  • 4. By Acellam Guy @mistaguy Representations • Resources and how to provide access to these resources • Format of representation JSON,XML ,etc • Both client and server should be able to comprehend format of representation • A representation should be able to completely represent a resource • The representation should be capable of linking resources to each other
  • 5. By Acellam Guy @mistaguy Messages • Contains the actual data and metadata about the message • Based on HTTP 1.1
  • 6. By Acellam Guy @mistaguy URI • The job of a URI is to identify a resource or a collection of resources • The actual operation is determined by an HTTP verb Eg. http://localhost:8080/Persons/1 This URL has following format: Protocol://ServiceName/ResourceType/ResourceID
  • 7. By Acellam Guy @mistaguy Uniform Interface • Systems should have a uniform interface. HTTP 1.1 provides a set of methods, called verbs, for this purpose Method Operation performed on server Quality GET Read a resource. Safe PUT Insert a new resource or update if the resource already exists. Idempotent POST Insert a new resource. Also can be used to update an existing resource. N/A DELETE Delete a resource . Idempotent OPTIONS List the allowed operations on a resource. Safe HEAD Return only the response headers and no response body. Safe
  • 8. By Acellam Guy @mistaguy Statelessness • Does not maintain the application state for any client • A request cannot be dependent on a past request and a service treats each request independently A stateless design looks like so: Request1: GET http://MyService/Persons/1 HTTP/1.1 Request2: GET http://MyService/Persons/2 HTTP/1.1 Each of these requests can be treated separately. A stateful design, on the other hand, looks like so: Request1: GET http://MyService/Persons/1 HTTP/1.1 Request2: GET http://MyService/NextPerson HTTP/1.1
  • 9. By Acellam Guy @mistaguy Links Between Resources • A resource representation can contain links to other resources like an HTML page contains links to other pages • The user does not need a map before coming to a website • A service can be (and should be) designed in the same way
  • 10. By Acellam Guy @mistaguy Caching • Caching is the concept of storing the generated results and using the stored results instead of generating them repeatedly if the same request arrives in the near future
  • 11. By Acellam Guy @mistaguy Mendix REST Module • Mendix 4.4.4+ or Mendix 5.3.1+ • If you want to publish REST services or use the data synchronization features, addIVK_OpenServiceOverview to your main navigation. add StartPublishServices to the startup sequence of your application • map your administrative project role to the Administratorrole in the RestServices for admin features • The 'rest/' request handler needs to be opened if running in the Mendix Standard Cloud (or on premise). • strongly recommended to not use the default HSQLDB engine if you want to publish RestServices while running locally
  • 12. By Acellam Guy @mistaguy Consuming REST services • The operations in the 'Consume' folder of the module provide the necessary tools to invoke data • The core of all these operations is the java action request
  • 13. By Acellam Guy @mistaguy The REQUEST java action • Request performs an HTTP request and provides the means to both send data and receive data over HTTP • Parameters • Method : HTTP 1.1 verbs • URL : location of the service • optRequestData : provides parameters • optResponseData : provides response • ResquestResult : HTTP response • sendWithFormEncoding
  • 14. By Acellam Guy @mistaguy RequestResult Object • contains the meta information of a response • Response code • Etag • ResponseBody :the full and raw response body of the request.
  • 15. By Acellam Guy @mistaguy Sending Request Headers • addHeaderToNextRequest : will add a header to the next (and only the next) request that will be made by the current microflow
  • 16. By Acellam Guy @mistaguy Authentication • Only supports Basic authentication out of the box • Other authentication mechanism such as Oauth can be integrated
  • 17. By Acellam Guy @mistaguy Consume Methods • get :Tries to retrieve an object from the provided resourceURL • get2: Similar to get, but also accepts a requestData parameter • ?q=Rest%20Services‘ • getCollection : gets a list of objects. JSON array • getCollectionAsync • post • delete • put • getRequestConsumerError
  • 18. By Acellam Guy @mistaguy Template URLS • This makes it possible to substitute values directly in an URL
  • 19. By Acellam Guy @mistaguy Publishing webservices • Publishing operations, based on a single microflow. • Publishing a part of your data model, and providing a typical rest based API to retrieve, update, delete, create and even real-time sync data. • PLEASE NOTETHATTO BE ABLETO PUBLISH ANY SERVICE,THE MICROFLOW STARTPUBLISHSERVICES SHOULD BE CALLED DURING STARTUP OFTHE APP! • Accessible via http://apphost/rest/yourservice
  • 20. By Acellam Guy @mistaguy Publishing a microflow • similar to publishing a webservice • instead of SOAP it uses JSON based messages • Has a single transient object as argument. • Each field in this transient object is considered a parameter (from HTTP perspective) • The return type of the microflow should be a transient object or a String or a filedocument • Publish by calling CreateMicroflowService with the microflow that provides the implementation
  • 21. By Acellam Guy @mistaguy Microflow with template path • Allows for constructing more complex URLs, from which values are parsed Eg. groups/{groupId}/users/{userId} http://myapp.com/rest/groups/123/users/John
  • 22. By Acellam Guy @mistaguy Publishing a data service • JSON based API to list, retrieve, create, update, delete and track objects in your database • Documentation is generated automatically
  • 23. By Acellam Guy @mistaguy End points on the service
  • 24. By Acellam Guy @mistaguy How the data service works • persistent entity in your database acting as data source • transient object that acts as view object of your data • Publish Microflow has the responsibility of converting source objects into view objects • Update Microflow is responsible for transforming a view as provided by some consumer into real data in your database • Each source object should be uniquely identifiable by a single key attribute
  • 25. By Acellam Guy @mistaguy Example • GET <your-app>/rest/<service name>/<identifier>
  • 26. By Acellam Guy @mistaguy Creating a new webservice • Add IVK_OpenServiceOverview to your navigation and create a new Published Service after starting your app • best practice is to use the GetOrCreateDataService microflow in the startup microflow to create your service configuration
  • 27. By Acellam Guy @mistaguy Configuring the service • Its done on the form or the create service microflow • Core configuration are: • Name • Description • Source Entity • Source Key Attribute • Source Constraint : xpath • Authentication Role • On Publish Microflow • On Update Microflow • On Delete Microflow
  • 28. By Acellam Guy @mistaguy Features • Enable GET : HTTP GET • Enable Listing : HTTP GET • Enable Update : HTTP POST or PUT • Enable Create : HTTP POST • Enable Delete : HTTP DELETE • Enable Change Log: caching • Enable StrictVersion:
  • 29. By Acellam Guy @mistaguy Securing Published webservice • * • Rolename • Module.Microflowname : Authentication details found in the header eg key
  • 30. By Acellam Guy @mistaguy JSON Serialization • Converts transient object to JSON • Nearest json type • For each owned reference that points to a transient object, another key/value pair is added to the object • For each owned referenceset that points to a transient object, the same approach is taken, except that the value is an array ([]) • Manual serialization process by use of serializeObjectToJson java action.
  • 32. By Acellam Guy @mistaguy JSON Desrialization • an be triggered manually by calling deserializeJsonToObject • Converts the json from the consumer into a mendix transient object • key/value pair for primitive attribute in transient object • If the primitive is of type string, but the member with the same name in the transient object is a reference, the process assumes that the string value represents an url. • If the member in the target object is a reference, and the value is a JSON object, a new object of the child type of the reference is instantiated • If target is reference set and JSON is array then reference set is created
  • 34. By Acellam Guy @mistaguy Assignment • Consume the twitter rest API and show the recent tweets for your profile
  • 35. By Acellam Guy @mistaguy References • http://www.drdobbs.com/web-development/restful-web-services-a- tutorial/240169069 • https://github.com/mendix/RestServices

Editor's Notes

  1. REST has become the default for most Web and mobile apps, it's imperative to have the basics at your fingertips. Every major development language now includes frameworks for building RESTful Web services Almost every RESTful service uses HTTP as its underlying protocol. In this article
  2. Use plural nouns for naming your resources. Avoid using spaces as they create confusion. Use an _ (underscore) or – (hyphen) instead. A URI is case insensitive. I use camel case in my URIs for better clarity. You can use all lower-case URIs. You can have your own conventions, but stay consistent throughout the service. Make sure your clients are aware of this convention. It becomes easier for your clients to construct the URIs programmatically if they are aware of the resource hierarchy and the URI convention you follow. A cool URI never changes; so give some thought before deciding on the URIs for your service. If you need to change the location of a resource, do not discard the old URI. If a request comes for the old URI, use status code 300 and redirect the client to the new location. Avoid verbs for your resource names until your resource is actually an operation or a process. Verbs are more suitable for the names of operations. For example, a RESTful service should not have the URIs http://MyService/FetcthPerson/1 orhttp://MyService/DeletePerson?id=1.
  3. so that your internal data structure is not directly published to the outside. This allows for better maintainability and it guarantees that you can pre- or post-process your data when required.
  4. It will search for the first source object in your database which key value equals the identifier. If found, this object will be converted by thePublish Microflow into a view object. This view object will be serialized to JSON (or HTML or XML) and returned to the consumer.