Introduction
MuleSoft's DataWeave available only from Anypoint Studio 3.7 since May 2015. It is a new powerful tool for data transformation. Earlier, we use DataMapper, or customer transformer to perform data transformation in addition to the out-of-box transformers, like Byte Array to String, object to JSON, XML to JSON, etc., just to name a few.
With DataWeave, the transformation become much less painful. In particular, if you don't want to write customer transform in java or scripts. Still, if you are good at writing java code, like me, customer transformer still be the best from development point of view. But it may not be the best for the long term maintenance. Once you get to the habits to write write customer transformer, you tend to use it a lot. I think it is time to change with this kind of powerful tool.
In this tutorial, I am going to demonstrate the basics about the DataWeave. Later, I will introduce more complicated cases. I will put this tutorial to Youtube.com. If you prefer to watch the usage in action.
Using Using Data Weave
The flow is like this:With this configuration, we will use the input of JSON like the follwoing:
{ "abc": { "cba":"ddd", "ccc":"eee", "aaa":["fgh","ghf","hgf"] } }
Put the above file into your local somewhere name it as transform1.json. I strongly recommend a tool named: subline test 2 for edition JSON.
Now create HTTP connector. Everything is the same as simple configuration. Only extra procedure is add Metadata as the following:
Now, we can add Transform Message to the flow. Note that the "Transform Message" which is DataWeave component, it is not a transformer!
Simple Transform Doing Nothing
For the doing nothing case, the transformer will be the following:%dw 1.0 %input payload application/json %output application/xml --- payload
Here is the snapshot of the transform panel:
Now we can test using PostMan with url: http://lcoalhost:8082/transform1. You should see the xml output like the following:
ddd eee fgh ghf hgf
All above is nothing fancy. Note, the payload in the transform panel. It means doing nothing. The power comes from that panel. All the logics will be input there. We will see in the next section.
Transform From JSON To XML
Now let's change the transform scripts to the following:
%dw 1.0 %input payload application/json %output application/xml --- items: { name: payload.abc.aaa[1], address: payload.abc.cba, ID: payload.abc.ccc }
Now if you run the POST operation, you will get the following result:
ghf dddeee
This is the transformation a bit interesting. Of course, you can do this with data mapper transformer. But I hope you see the power behind it. It opens up the huge possibility in manipulate data for the transformation purpose. I will cover more cases in my later blogs.
Conclusion
I think DataWeave is a powerful tool. It takes time to learn the syntaxes, but I think it worths the time spending if you want to be a good integration architect! You can visit my youtube channel to get dynamics of the DataWeave!
the blog is about Mule ESB Tutorial: Introduction To DataWeave it is useful for students and Mulesoft Developers for more updates on Mulesoft follow the link
ReplyDeletemulesoft Online course
For more info on other technologies go with below links
Python Online Training
tableau online training hyderabad
ServiceNow Online Training
ReplyDeletethe blog is good and Interactive it is about Mule ESB Tutorial: Introduction To DataWeave it is useful for students and Mulesoft Developers for more updates on Mulesoft
https://onlineitguru.com/mulesoft-online-training.html
the blog is good and Interactive it is about Mulesoft Developer it is useful for students and Mulesoft Developers for more updates on Mulesoft mulesoft Online training
ReplyDelete
ReplyDeleteThank you for sharing wonderful information with us to get some idea about it.
mule esb training
learn mulesoft online
mulesoft training courses
mulesoft online course
online mulesoft training
mulesoft certification
learn mulesoft
mulesoft online training
mule 4 training
mulesoft training
mule training
mule 4 certification
Thanks for your information. very good article
ReplyDeleteServiceNow developer certification
itsm certification
I have found great and massive information on. Thanks for sharing
ReplyDeleteMulesoft Onine Training Hyderabad
Mulesoft Online Training in India
Nice blog!!
ReplyDeleteMulesoft Online Training in India
Best Mulesoft Training
perde modelleri
ReplyDeleteMobil onay
VODAFONE MOBİL ÖDEME BOZDURMA
Nft Nasıl Alınır
ankara evden eve nakliyat
trafik sigortası
dedektör
Websitesi Kurma
aşk kitapları
Thanks for sharing such quality information.
ReplyDeleteMulesoft Online Training
Mulesoft Online Training in Hyderabad
smm panel
ReplyDeletesmm panel
İS İLANLARİ BLOG
İnstagram takipçi satın al
HIRDAVATÇI BURADA
Https://www.beyazesyateknikservisi.com.tr
SERVİS
TİKTOK JETON HİLESİ
üsküdar toshiba klima servisi
ReplyDeletebeykoz beko klima servisi
üsküdar beko klima servisi
pendik daikin klima servisi
tuzla toshiba klima servisi
tuzla beko klima servisi
çekmeköy vestel klima servisi
çekmeköy bosch klima servisi
ataşehir bosch klima servisi
en son çıkan perde modelleri
ReplyDeletenft nasıl alınır
yurtdışı kargo
lisans satın al
uc satın al
özel ambulans
minecraft premium
en son çıkan perde modelleri