This POC implements the calling static java method by using below 2 options.
Calling java static method from Data Weave.
Calling java static method using Java component operation, Invoke Static.
In the mule project, create the com package under the directory src/main/java.
create java class "StringUtils" inside the com package and then write the code inside the class like as shown below
1.Calling Java static method from Data Weave.
Drag a http listener from the mule palette and drop it in the canvas.
Next, click on the create new connector configuration and fill the host, port values.
Next, set the path to "/invokeDW"
Drag a transform message and drop it in the canvas.
Next, write the code as shown in the below screen.
Deploy the Mule application in local environment and test the URL as shown below.
2.Calling Java static method using Java component operation, Invoke Static.
Drag a http listener from the mule palette and drop it in the canvas.
Next, click on the create new connector configuration and fill the host, port values.
Next, set the path to "/invokeJava"
Drag a java "InvokeStatic" component and click on the search to add a class.
Select the method as shown in the below screen.
Next, write the arguments as shown below.
Next, drag and drop a Transform message component and configure as shown in the below screen.
Next step, Run the project and send the request from postman as shown below.
Summary: Thanks for watching the blog. Any questions/suggestions, please reach out to info@bilvasoft.com. We are happy to help the community to grow with your valuable inputs. Author: https://www.linkedin.com/in/battulachrao
Comments