Invoke Custom Java Class using Dataweave
To Invoke Custom Java Class Using Dataweave, Let’s create a project in Anypoint studio.
Create Java Class in Anypoint studio
Set the variable value
Drag and drop Transform message and write code to invoke java class in Dataweave
Dataweave
%dw 2.0 import java!company::TestSubstring output application/json --- { "a":TestSubstring::getSubString(vars.string) }
Deploy the project and test
Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.
Why did it give -> “a” : “Tendulkar” ? the variable string was of value “Sachin Tendulkar”
Java method return substring(6) and 6th is the index of space between “Sachin Tendulkar” and so it return ” Tendulkar”