Sie sind auf Seite 1von 6

****************** RAML type declaration or designer

****************************
#%RAML 1.0 DataType

type: object
properties:
id?: string
firstName: string
lastName: string
address: string
postal: string
country: string
miles: integer
creationDate?: datetime
type: string

****************** RAML samplefile for designer


****************************
#%RAML 1.0 NamedExample

value:
-
id: "55555"
firstName: "xxx"
lastName: "yyyy"
address: "555 xxx St., OverlandPark KS"
postal: "55555"
country: "USA"
miles: 999
creationDate: 2020-06-04T11:11:11.111Z
type: "personal"
-
id: "55555"
firstName: "xxx"
lastName: "yyyy
**********************************************************
Json Type declaration in program
{| id: String,
firstName: String,
lastName: String,
address: String,
postal: String,
country: String,
miles: Number {"typeId": "int"},
creationDate: String, "type": String
|}

**********************************************************
Json sample file for type
[
{
"id": "ABC-1234",
"firstName": "John",
"lastName": "Doe",
"address": "123 Main St., Dallas TX",
"postal": "77777",
"country": "US",
"miles": 999,
"creationDate": "2019-08-21T04:34:41.098Z",
"type": "Personal"
},
{
"id": "XYZ-8989",
"firstName": "Jane",
"lastName": "Doe",
"address": "10 Downing St., San Francisco CA",
"postal": "89897",
"country": "US",
"miles": 101,
"creationDate": "2018-12-09T21:53:12.127Z",
"type": "Business"
}
]
*********************************************
remember

Yaml example file no quotes for intiger


all required field should be there
*********************************************

two things to remember


attributes.headers.'requester-id'
attributes.uriParams.id
attributes.queryParams.destination
*********************************************
Adding Mule meta data type
After you add first metadata type application-type.xml file will be created.
*********************************************
1. Create a new Design Center project
2. Publish the API to Anypoint Exchange from API Designer
3. you should see your American Flights API in your private Exchange
4. you should not see your American Flights API in the public Exchange
5. Share the API in the private Exchange with others
6. In the Publish to public portal dialog box, select to share v1 of the API,
Creates a public API portal.
7. Create a Mule project in anypoint studio
8. you have to give application name this name is unique across the mule soft.
This name will be part of the URL (immplementaion url) used to access the
application on CloudHub.
Name must be unique across all applications on CloudHub
Deploy the application to CloudHub, this goes to runtime manager
worker and worker size to 0.1 vCores.
09 you application will be running you can test.
10 go back to API manger here only your are linking the REst API and application
you develop in anypoint studio
11 Create and deploy a proxy application from API manager, you have to bring REst
API designer from exchange and then deploy proxy
*********************************************
DataWeave Selectors -traverse the structures of objects and
arrays and return matching values.
Single-value .keyName Any type of
value that belongs to a matching key
Multi-value .*keyName Array of
values of any matching keys
Descendants ..keyName Array of
values of any matching descendant keys
Dynamic See Dynamic Selector.
Key-value pair .&keyName Object with
the matching key
Index [<index>] Value of any
type at selected array index
Range [<index> to <index>] Array with values
from selected indexes
XML attribute @, .@keyName String value
of the selected attribute
Namespace keyName.# String value
of the namespace for the selected key
Key present keyName?, keyName.@type? Boolean (true if
the selected key of an object or XML attribute is present, false if not)
Assert present keyName! String:
Exception message if the key is not present
Filter [?(boolean_expression)] Array or
object containing key-value pairs if the DataWeave expression returns true.

Otherwise, returns the value null.


*********************************************
Type System - A type system defines a set of constraints to a set of constructs,
such as:
Variables
Function parameters
These constraints are used in the type-checking phase,
when DataWeave ensures that the values assigned to variables or the arguments
for a function call respect its constraints,
DataWeave type system are divided into three categories:
Simple Types, Composite Types, Complex Types

Simple Types - String, Boolean, Number, Regex, Null, Temporal: Date, DateTime,
LocalDateTime, LocalTime, Time, Period
Null is a type and it has value null, null cannot be assigned to the type String
or any other type except for the type Null.
composite types - Array, Object and Function.

You can define an Object type in two ways: Object or {}. B

Close and Open Objects - Object type can be either closed or open.
The following example succeds even if age is not in the type declaration because
the type of the variable user is an open object:
var user: {firstName: String, lastName: String} = {firstName: "John", lastName:
"Smith", age: 34}

The syntax to specify a closed object is {| |}. The following example makes the
User type support only the keys firstName and lastName.
The script throws an exception because the age field is not accepted.
var user: {|firstName: String, lastName: String|} = {name: "John", lastName:
"Smith", age: 34}

Function Type
The syntax to define a function type is: (paramType: ParamType,...) -> ReturnType,
(paramA: String, paramB: Number) -> Boolean
*********************************************
You can see error mapping option
Validator
Http Request connector
mostly all connectors has but no http listner
getFlight connector has
*********************************************
1. assuming no error handler on the flow but error handle in application level
On Error Continue
when error occurs, application On Error Continue handles the error,
then it return backs to the flow continues process from next valid porcess and
ends,
finally throws the error message at the end.
on error propagate
when error occurs in child flow, application on error propagate - handles the error

(when there is no error handler in the child flow)


and throws the error message to parent flow (parent of chlid flow) error handler,
if no error handler in parent flow it comes back to application
on-error handler and ends the process.
if there was on error handler in (process/flow) that will handle the error.
*********************************************
if you have error handler in flow that one triggers first.
if you have on propagate handler then error in the flow error handle then that is
thrown and ends the process.
if flow has error handler and if it is not having setup to hande the error and
if you have application level errror handler enven if you have setup for error
handling it is no use.
since process will end in flow error handler.
if you have error handler in the flow you have to handle all errors as much as you
can
*********************************************
when you post josn message, and if tranform message has output application/java
then payload will have linkedhashmap
*********************************************
STEP1 Create API specification in Designer, online
For get method level 2 or level 3
First Get, post, /{ID} are one intendent from /flights.
/{ID} is URI parameter.
For queryparameters at the next line, press one tab, enter the parameter name
(destination)
Note type also get same data types.
For queryparameters at the next line, press one tab, enter the parameter name
(destination) if nothing selected from the datatype
next line, press one tab
After required false entered, same level as required above in next line, drawer
displays the same itmes in different order without required parameter. you should
be at the same indent level as required.
Above /flights same level as /flights
Step 2 Publish to Exchange.
Step3 Private Exchange
Exchange can have following assets. We create REST API asset.
Publish the API to your private Exchange from Designer.
When you click the api in exchange, a page opens, that page is the home page of
that API.
You should not see the API in public Exchange.
Step 4 Public Portal/ Public Exchange
From Exchange (not from api home page) you can go to your public portal. Every
company get one public portal for all aPI they create
url https://anypoint.mulesoft.com/exchange/portals/balasuk-inc/
Even you logged into public folder you will not see the API.
You can see only after you shared the API from exchange by checking the check box
After shared the API with public from exchange , you can see the auto-generated
public API portal
Step 5 Building API
Build API using Anypoint Studio
1. Create a RESTful interface for a Mule application (retrieving the data from
database) This file you rename as implementation.xml
2. Create a RESTful API interface from a RAML file. This is done by importing
the RAML file from Exchange online. APIkit console and main are created in this
method. This file you rename as interface.xml
3. Implement a RESTful web service
In this process you will link the implementation code to interface
Step 6 Deploy to Cloud
• When you deploy the application to cloud hub from your local pc application
studio a jar file is created and it deployed to CloudHub.
• You have to give the application name. Name must be unique across all
applications on CloudHub.
• After deploy to CloudHub you can run the application online from runtime
manager.
• After deploy you can see one application running in runtime manager using jar
file
Step 6- Deploy Proxy
Proxy - the authority to represent someone else
You will do Proxy deployment from API manager, using Manage API from Exchange
After deployed to proxy only, you can see the API in API manager.
When you deploy you have to give proxy application name.
Proxy application name and mule Application name can be different
Proxy URL and Consumer end point URL should be same
After deploy you can see two application running in runtime manager
1. First one was deployed from local PC to Exchange
2. Second was deployed from exchange to cloudhub, from API manger.
Step 7 To see the proxy in public portal
you have to give public access from Exchange – Select api– go to api instance, give
public access
You will create policies and SLA tiers in API manager under specific API Home page
you will approve the manual request under specific API Home page on API manager
under contract
Step 8 Consume Web Services that has API and connector in exchange
Starts from middle of the module 7.
1. Make a request to the web service
2.
Notes
when you add logger from palette then only you can see the log on console
Query parameters from HTTP listener will be removed if it passes through HTTP
request.
HTTP request can add new set of Query parameters if you have general tab, request
section.
If header is added in http listener response tab then that hear value will be
return back in response as part of the header. This will not be impacted by http
request.
Http request does not have header for response.
Http request does have header for request in general request tab.
You cannot reference the query parameters value in HTTP listener response header.
Variables are local to that loop even it goes through flow reference
Subflow has only one section may be process section
Flow has three section source, process and error handling
Flow reference can call flow or subflow
VM module VM connector/Listener
Publish - this is different it is like parallel, it completes the entire flow
then goes to publish queue and ends
Publish Consume – Works like SubFlow (Sequential)
After you add first metadata type application-type.xml file will be created.
Scater Gather
goes to setcode reference of all three one by one
then goes to set code subflow three times
get flight each flight one after other
each trasformation one after other
each logget one after other