Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 134

Author : Sravan Lingam

SESSION 1
What is
Mulesoft

MULESOFT
TRAINING
FOR
ABSOLUTE BEGINNERS
Pre-Requisites / FAQ’s
‣ Why only for Absolute Beginners
‣ Do we need to know languages like Java, .net etc?
‣ Am from QA,Linux , xyz background , Can I learn MuleSoft ?
‣ What’s the best CTC that I can ask?
‣ What should we learn and best to know before starting of session?
‣ Practice Practice Practice - No Shortcuts
‣ Official Training Details
WHAT IS MULESOFT

•Is a Salesforce Company


•An Integration Platform
•An API Management Platform
WHAT IS MULESOFT

•Mule, the runtime engine of Anypoint Platform, is a lightweight


Java-based enterprise service bus (ESB) and integration
platform that allows developers to connect applications together
quickly and easily, enabling them to exchange data.
•It enables easy integration of existing systems, regardless of the
different technologies that the applications use, including JMS,
Web Services, JDBC, HTTP, and more
What does API Management Platform Mean?

-Design API’s
-Develop API’s
-Deploy API’s
-Manage API’s
-Secure API’s
-Reuse API’s
WHAT IS AN API?

•API stands for Application Programming Interface


•API’s allows to communicate/exchange data between two
systems
Request
Client Server

Response
Restaurant Example

Request from Process Response from


Client Request Server
WHAT ARE WEB SERVICES?

•A Web service is a way for two machines to communicate


with each other over a network
•A web server running on a computer listens for requests from
other computers. When a request from another computer is
received, over a network, the Web service returns the
requested resources.
API’s vs WebServices
•APIs and web services are not mutually exclusive.
•Every web service is an API — but not every API is a web
service.
•API’s are evolution of Web Services as both purpose is
information transfer
SOAP vs REST services

SOAP REST

REST APIs uses multiple standards like HTTP, JSON,


SOAP APIs is largely based on HTTP and XML.
URL, and XML

Request and Responses are in XML Can be on any format

Uses WSDL Uses RAML

Complex to understand User friendly


Walkthrough over a Website
API -LED-CONNECTIVITY
SYSTEM APIS

•System API’s are built to connect through underlying systems (Any system
which contains the raw data) .

•Basically System API contains Sensitive information as it contains raw data.

•Should never be exposed for public use.

•Eg : APIs which connect to Databases , Salesforce, SAP systems, Hadoop


systems etc..
PROCESS APIS

•Process API’s are built to compose or combine two or more System API’s
•Usually to do any kind of transformation or to implement any kind of
business logics or shape the data out of system apis.
•It may perform aggregation / splitting / routing the data.
•Process APIs must be private and should not be exposed to public for use.

•Eg: Aggregating Customer Data and Product Data that comes from 2 system
APIs where Actual data is originated , to provide Order Status.
EXPERIENCE APIS

•These are API’s which are a kind of a wrapper either to Process API’s (if
present ) or to System API’s , so that Client/Consumers can use it.

•Client/Consumers will not have exposure or contact with direct Raw Data.

•We can have minimal Data Transformation like the final result to be in JSON
or XML or whatever the consumer wants to have.

•Remember , if there is any change in System API , we do not need to modify


or change anything in Process or Exp API.
API - LED CONNECTIVITY

Experience Book Flight Offers for Customer Iternary Status


APIs

Pre-Booked flight
Process Payment Send Notification
Status
Process APIs

Flight API Customer API Notification API Payment API


System APIs

SRAVAN LINGAM
Anypoint Platform
One Stop platform for APIs and integrations :
‣ Design Center - Design and Develop API’s
‣ Anypoint Exchange - Place where we will be able to share, discover api’s and reusable assets
‣ API Manager - Helps in Managing APIs by invoking policies
‣ Runtime Manager - Where Applications are deployed
‣ Access Management - Configures Access and permissions within organization
‣ Anypoint Monitoring/Visualizer -Provides Monitoring and real-time graphical representation
of APIs
‣ Secret Manager - Place to store and control access to private keys, passwords, certificates,
etc
Pre-Requisites / FAQ’s
‣ Training and certification Platform
‣ Anypoint Platform Account
‣ help.mulesoft.com
‣ What is MuleSoft 3D
MuleSoft Community
• MuleSoft Meetups - https://meetups.mulesoft.com
• MuleSoft CONNECT NOW: https://connect.mulesoft.com
• Training & Certification
• MuleSoft Blogs and many more.
• Tip : Learn from errors!
In case if you missed the session!
Subscribe To our YouTube Channels:
SESSION 2
Designing API’s

MULESOFT
TRAINING
FOR
ABSOLUTE BEGINNERS
Recap of Session 1

➡ What is MuleSoft?

➡ What is an API?

➡ REST vs SOAP services

➡ API led Connectivity

➡ Anypoint Platform

➡ MuleSoft 3D

➡ Walkthrough to a website

➡ At the end of session, you will be asked to submit assignment by next Saturday
What is API Specification?

An API specification provides an understanding of how an


API behaves .
➡What kind of Request it Accepts?
➡What kind of Response it returns?
➡What are Mandatory fields / Data Types etc…
Building
Construction:

SRAVAN LINGAM
DESIGNING APIS

Anypoint Platform’s Design Center


DESIGN CENTER

•API Designer helps us to create API Specification in RESTful API Modeling


Language (RAML)
•It supports RAML 0.8 and 1 versions
•After creating Specification , it can be published to API Exchange so that it is
available to your MuleSoft organization
DESIGNING RAML

•Resource: It is the unique name we give to identify a resource


•Method: GET , POST , PUT , DELETE , PUT , PATCH etc
•Request : like Body , queryparams, uriparams, headers.
•Response: like response Body and response type
Http Status: 200,201,400,404,500 etc ..
No two resources can have same name & method!
Walkthrough over a Website Again!
DESIGNING RAML

Hands-on
WHAT HAVE WE COVERED SO FAR!

•Designing RAML using Design Center


•Creating Single / multiple resources
•Defining the type of Method, Request and responses
•How to include files , how to use “types”.
•How to mock the url .
•How to publish to exchange to make it available
DESIGNING RAML

•To learn more , Visit : https://raml.org


•Submit your assignments without fail!
•Tip : Practice Practice Practice .
In case if you missed the session!
Subscribe To our YouTube Channels:
SESSION 3
Developing
API’s
Part- I
MULESOFT
TRAINING
FOR
ABSOLUTE BEGINNERS
MULE 4 - MESSAGE STRUCTURE

Mule
Mule Message
Message Mule
Mule Event
Event

Inbound properties Mule Message

Payload
Outbound properties
+
Attributes
Payload

Variables
(flow,session,record)
Variables
Attachments
Mule
Mule 3
3 Mule
Mule 4
4

Mule Event = Mule Message + Variables


MULE 4 - MESSAGE STRUCTURE

✦ Payload : It’s the actual message content. Payload can be over ridden

✦ Attributes : These provides metadata such as queryParams, file size etc .


These are immutable (cannot be changed)
✦ Variables : These are which you can store some kind of data or information
and can be used across the application as long as you connect the flows with
flow-ref
Anypoint Studio

Mule Palette
Project/Pack
Canvas
age explorer

Let’s Download and


Checkout!

Console and
other stuff
MULE PROJECT STRUCTURE
➡Every Project in Mule 4 is Mavenized Project
➡All Mule xml’s are placed under src/main/mule
➡Other files can be placed under : src/main/resources or
src/test/resources
➡mule-artifact.json
➡Each Mule app xml has - Message flow (Graphical
view) , Global elements(contains all config details)
,configuration xml (xml version of graphical view)
FLOW , SUB-FLOW AND PRIVATE FLOW

➡An App can consists of a single flow !

➡Or it can break up processing into discrete(private) flows


and sub flows that you add to the app and connect together

➡Private and sub-flows can be triggered by Flow-reference


or by DataWeave lookup!
FLOW :

➡A flow has “Source” , “Process” and “Error Handling” Part


➡You should definitely keep something in Source
PRIVATE FLOW :

➡A private flow has “Source” , “Process” and “Error Handling” Part


➡It’s called a private flow when we don’t keep anything in Source Part
SUB FLOW :
➡A sub flow do not have “Source” and “Error Handling” Part

➡It has only Process Part.

➡Error Handling for sub-flows are handled by the calling flow/private flow.
CONNECTORS
HTTP
LISTENER:

Listens to the request which client/user sends.

Mandatory Config Details required: host , port ,


path
Default : Accepts all kind of Methods if nothing is
specified
SET PAYLOAD

The Set Payload component lets you update the


payload of the message.
The payload can be a literal string or a DataWeave
expression
Mandatory Config Details required: value
eg : #[“Hello World” ] or #[payload] or
#[attributes.queryParams.name]
Default : #[payload]
HTTP
LISTENER:

s - o n
Ha nd
SET PAYLOAD

ds - o n
Ha n
BUILDING A RESTFUL API

Hands-on
DEBUGGING AN APPLICATION

Hands-on
WHAT HAVE WE COVERED SO FAR!

•MULE 4 – MESSAGE STRUCTURE


•Introduction to Anypoint Studio
•Mule 4 Project Structure
•Introduction to Flow, Sub-flow, and a Private Flow
•HTTP – Listener
•Set Payload
•Building a Simple RESTful API – Hands-on
•Debugging an Application in AnypointStudio – Hands-on
IMPORTANT THINGS!

•Download Anypoint Studio - https://www.mulesoft.com/lp/dl/studio


•Create Anypoint Platform Account : http://anypoint.mulesoft.com/
•Download POSTMAN
•Register for last MuleSoft CONNECT for the year :
https://connect.mulesoft.com/events/connect/japac
•Watch video and practice . Submit assignment without fail
•Practice Practice Practice !
In case if you missed the session!
Subscribe To our YouTube Channels:
SESSION 4
Developing
API’s
Part- II
MULESOFT
TRAINING
FOR
ABSOLUTE BEGINNERS
FLOW-
REFERENCE

Mandatory Config Details required: flow name


to be called. All names are present in drop-down
list
Default : empty but it fails to deploy if you don’t
give any flow name from drop down

ds - o n
Ha n
SRAVAN LINGAM
ATTRIBUTES

We know that attributes is part of Mule


Message
Attributes are nothing but the meta-data
coming from the system which we are
connecting .
Accessed as #[attributes.requestPath]
#[attributes.queryParams.name]
Attributes are replaced with new or no values
whenever we connect to any external systems.
SRAVAN LINGAM
VARIABLES

Mule 4 has only one kind of variable called “variable” where in Mule 3
we used to have 3 kinds of variables (flow, session and record) .

They are used to preserve information which you think might be useful
at any point of flow.

Accessed as #[vars.id]

Vars are carried as long as the flow is connected. If you think that you
SRAVAN LINGAM
no longer need the variable, you can use “remove variable” to remove it.
SET VARIABLE

•Mandatory Config Details required: Nothing


Mandatory . If nothing provided , it sets to
null
d s - o n
Ha n

SRAVAN LINGAM
SCOPE OF ATTRIBUTES , PAYLOAD AND VARIABLES
TRANSFORM
MESSAGE
Mandatory Config Details required: Should
have something written.
You can set a payload, variable or attribute using
Transform message.
You can set Multiple variables along with payload.
Best practise is to define output type
Default : output application/java - - - { }

SRAVAN LINGAM
TRANSFROM
MESSAGE

s - o n
Ha nd

SRAVAN LINGAM
LOGGER

•Mandatory Config Details required: Nothing


is mandatory here. You can set anything in
“message” field.
d s - on
Ha n

SRAVAN LINGAM
CONFIGURATION PROPERTIES
Property values are used for best practices to extract some values from
property files using corresponding key to avoid Hardcoding values

We can extract property values from property file by two ways , either by ${}
or p(' ') .

${} can be used anywhere at any place , either in configuration or in


dataweave etc.

p(' ') can only be used in DataWeave expression Language scope. i.e, within #[]

s - o n
Remember : Either of the cases , we have to restart the application if there are any
d
Ha
changes made in property file to get the new values reflected
SRAVAN LINGAM
n
WHAT HAVE WE COVERED SO FAR!

•Flow – Reference – Hands-On


•Attributes and Variables
•SET VARIABLE and Attributes – Hands-On
•TRANSFORM MESSAGE
•LOGGER
•SCOPE OF ATTRIBUTES , PAYLOAD AND VARIABLES- Hands-On
•CONFIGURATION PROPERTIES
IMPORTANT THINGS!

•SCOPE OF ATTRIBUTES , PAYLOAD AND VARIABLES- Is very


important both in Certification Perspective as well as Real time
projects, a you play around it
•Transform Message is used to set all 3
-Payload,Variable,Attributes.
•Watch video and practice . Submit assignment without fail
•Practice Practice Practice !
In case if you missed the session!
Subscribe To our YouTube Channels:
SESSION 5
DataWeave

MULESOFT
TRAINING
FOR
ABSOLUTE BEGINNERS
DATAWEAVE - 2.0

•DataWeave is the MuleSoft expression language for accessing and


transforming data.

•We can Transform Data from one format to other . Eg: JSON to XML

•We can access any specific field inside a payload. Eg: payload.name

•Basically we can do all kind of Extraction and Transformation.

SRAVAN LINGAM
DATAWEAVE - THE POWER OF PREVIEW FEATURE

•Are you not sure about the syntax you want to write?

•Are you struggling to deploy your application always to check whether


your syntax or DW is correct or not?
ds - o n
•DataWeave Preview helps us to overcome it! Ha n
•Please make sure that your Tooling instance is running properly. or else this
feature won’t be available

SRAVAN LINGAM
UNDERSTANDING ARRAY AND OBJECT

•How to Identify an Object and an Array?

•An Object is always enclosed with { } and contains key-value pair.


•Eg:
•{ “name” : “Sravan” }
•{ “name” : “Sravan” , “id” : “2”}
•{ “Sravan” }
•{ “name” : “Sravan” , “2”}

SRAVAN LINGAM
UNDERSTANDING ARRAY AND OBJECT

•An Array is always enclosed with [ ] and contains only values

•Eg:
• [“Sravan” , “2” ,”MuleSoft”]
ds - o n
•{ “name” : [“Sravan”, “Lingam”]}
•[“name” : “Sravan”] Ha n

SRAVAN LINGAM
TRANSFORMING ONE DATA TYPE TO OTHER

•In Mule 3 ,we have separate connectors to convert from one type to other.

•In Mule 4 we use DataWeave to achieve this.

•Eg :
ds - o n
•JSON to XML
•XML to JSON Ha n
•JSON to CSV
•And many more…..

SRAVAN LINGAM
MAP AND MAP OBJECT

•map operator is used on Arrays.


d s - o n
•mapObject is used for Objects. Ha n
•You Cannot use mapObject operator for Arrays.
•You Cannot use map operator for objects.

•$ : Gives the value of the particular field/key.

•$$ : Gives index of the field.


SRAVAN LINGAM
SOME MOST IMPORTANT AND COMMONLY USED OPERATORS

Can be applied on input


Operator Output type Used for
which is/are

map On Arrays only Array Array of Object

mapObject On Objects only Object Output is an Object

reduce On Arrays Anything To reduce into given expression

Same as mapObject, only difference is the


pluck On Objects Array output is returned as array instead of
Object

flatten On arrays Single set of Array Turns into set of subarrays to single array
CANNOT COERCE - ERRORS

•Null checks
•Default
• Converting String to Number, Number to String
•Very Important while developing
d s - on
Ha n

SRAVAN LINGAM
DATAWEAVE IN OTHER COMPONENTS

•We can write DW wherever required.


s - o n
•In loggers to prints payload
Ha nd
•In choice router to write expression etc..

•Do you know how to add multiple variables and attributes in Transform
message?

SRAVAN LINGAM
DATAWEAVE - INPUT OUTPUT MAPPING

•DW syntax is auto generated when we manually map Sample input with
Sample Output.

s - o n
Ha nd

SRAVAN LINGAM
DATAWEAVE - FUNCTIONS

•DataWeave Provides number of in-built functions for Data Transformation .


•Eg : upper , join , contains etc…

•You can write your own functions.

•You can also Write your DataWeave in separate scripts and call them!

• You can call a sub-flow or private flow using “lookup” in DataWeave

d s - o n
Ha n
SRAVAN LINGAM
WHAT HAVE WE COVERED SO FAR!

•What is DataWeave
•DataWeave -preview
•Array & Object Identification
•Map and MapObject , $ , $$
•Pluck,flatten,reduce,if-else,upper,filter,groupBy,orderBy
•How to write DataWeave in other components
•How to map using Drag and drop fields to build syntaxes
•Local variables
•Various inbuilt functions/ custom functions
•Calling using lookup, calling dw scripts etc
IMPORTANT THINGS!

•Map and mapObject are important


•Lookup , DWL script calling , custom functions are important
• Xml mapping if you are perfect then its easy for you for other formats
•Try practising all different Data Types
•training.mulesoft.com
•Practice Practice Practice
•Learn from errors!
In case if you missed the session!
Subscribe To our YouTube Channels:
SESSION 6
Developing
API’s
Part- III
MULESOFT
TRAINING
FOR
ABSOLUTE BEGINNERS
THINGS TO REMEMBER WHEN YOU WANT TO CONNECT TO EXTERNAL
SYSTEMS:

•External Systems : Database,SFTP , any external Webservices etc..


•Gather the configuration details that are required to connect to that
particular system
•See what is the request that particular system is accepting
•See what is the security that is required to connect to that system
•See what is the type of response that the system return to us back.
•Good to know how much time the system takes to respond to us back , so
that we can configure timeout response

SRAVAN LINGAM
HTTP
REQUEST:

Http Request is used to call other web-services .

It can be placed only in “Process” area of flow/private-


flow/sub-flow .

We should make sure that we send all kind of proper


inputs to Http Request component like URL,method, the
input payload that the external web-service is expecting,
various attributes like queryParams,headers etc.
SRAVAN LINGAM
HTTP
REQUEST:

Mandatory Config Details required:


•Protocol
•Method
•URL or Path : If you provide whole URL, then port base
path are not required. But If you give path, then host, port ,
path are necessary.

You can pass body , headers ,Attributes , QueryParams in


respective tabs
SRAVAN LINGAM
HTTP
REQUEST:
In any case if an error coming from the web-service we are calling to be
considered as success , then we have to make changes in Response Tab of Http
Request and make use of Success-status-code-validator.

d s - o n
Ha n

SRAVAN LINGAM 85
85
CHOICE

The Choice router routes messages through a


flow based in evaluating an expression.

Only one of the routes in the Choice router


executes, meaning that the first expression that
evaluates to true triggers that route’s execution
and the others are not checked.
If none of the expressions are true , then it goes
to default route .
SRAVAN LINGAM
CHOICE

Mandatory Config Details required: Expression


is mandatory which checks some validation. The
ds - o n
Ha
result of the expression should be either true or n
false nothing else.

Expression : empty but you can’t keep empty


expression, it will not deploy your application

Remember : If first condition is satisfied, then it


will not go to other blocks. It will execute the first
SRAVAN LINGAM

satisfied condition block and continue further


SCATTER -
GATHER
Scatter Gather sends the request message to multiple targets
concurrently , it collects responses from various targets and aggregate
them to single message.

It executes routes concurrently instead of sequentially . But wait till all


targets executes.

Output payload is combination of all targets. And each target output has
payload+attributes.
SRAVAN LINGAM
SCATTER - GATHER

So its always best practice to wrap every target within Try-Block with
On-Error-Continue , So that you can handle the errors and complete the
process successfully .

Remember : If any of the targets fail inside scatter-gather , it will fail


whole process.

The total time taken to process all targets is the max time took by one of
the targets
SRAVAN LINGAM
SCATTER - GATHER

ds - o n
Ha n
SRAVAN LINGAM
VALIDATION

Validation component will verify the


content of message whether it matches the
specified criteria

It will proceed to further connector if


the conditions are matched. Else , it will
raise an error
d s - o n
Ha n
SRAVAN LINGAM
WHAT HAVE WE COVERED SO FAR!

•How to connect to 3rd party services/webservices/APIs


•Things to remember when connecting to external systems
•HTT request-handson
•Choice,scatter-gather,validation - with hands-on
IMPORTANT THINGS!
•Success-status-code-validator.
•Only one of the routes in the Choice router executes, meaning that the first expression
that evaluates to true triggers that route’s execution and the others are not checked.
•Scatter-gather executes routes concurrently instead of sequentially . But wait till all
targets executes.
•The total time taken to process all targets is the max time took by one of the targets .
•Validation component will verify the content of message whether it matches the
specified criteria.
•Practice Practice Practice
FOR NEXT SESSION!
•Install My SQL Server + Workbench :
https://www.youtube.com/watch?v=GIRcpjg-3Eg&ab_channel=edureka%
21
•Create an AWS account
•Create a Salesforce developer account
•We will connect to all these 3 external systems in next session!
In case if you missed the session!
Subscribe To our YouTube Channels:
SESSION 7
Developing
API’s
Part- IV
MULESOFT
TRAINING
FOR
ABSOLUTE BEGINNERS
DATABASE

Mandatory Config Details required:


• Driver
• Host
• Port
• User
• Password
• Database/servicename/instance
• SQL Query text

Default : empty but you can’t keep empty


expression, it will not deploy your
application
SRAVAN LINGAM
DATABASE

Remember : In Mule 3 , we used to have one Database connector and we will be


selecting the kind of operation that we want . Like Select, update, delete, insert etc.

But in Mule 4 , we have separate connectors for each operation.

You can test connection if you want to check if connection is successful

The output type of Select statement results in “Array”.

If Database Select doesn't return any rows , we receive an Empty Array instead of
SRAVAN LINGAM

null payload
DATABASE

d s - o n
Ha n

SRAVAN LINGAM
FILE

Mandatory Config Details required: Only configuration


which has one value that needs to be set I.e, Working
Directory. You can leave empty too. But You have to create
a Configuration for sure.

But in Mule 4 , we have separate connectors for each


operation. You can test connection if you want to check if
connection is successful

SRAVAN LINGAM
FILE

By default , if we Read a file, the file will not


be deleted.
You can extract file name, size etc using
attributes

d s - o n
Ha n

SRAVAN LINGAM
SFTP/FTP

Remember : FTP, SFTP are one and same except that


SFTP uses secured protocol. The way we connect, the
operations are all same. The operations and the way it
works is same for File,FTP and SFTP

Mandatory Config Details required: Host, port ,


username and password

File,FTP and SFTP operations, all are same because the


functionality remains same. Only difference is File is on
SRAVAN LINGAM

local, FTP and SFTP are on Server.


105
106
107
108

You might also like