top of page
Writer's pictureBilvasoft

Mule 4 Invoke Java Static method

Updated: Jul 5, 2022

This POC implements the calling static java method by using below 2 options.

  1. Calling java static method from Data Weave.

  2. 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




Recent Posts

See All

API-Led connectivity

To connect the devices, applications, data in an enterprise, API's will play a key role and enterprises are quickly adopting the key...

Comments


bottom of page