davidad
davidad

Reputation: 137

How do I can call a jar file from wso2

I am new to esb WSO2 and I need to call a .jar with WSO2 parameters. I think I need to create a endpoint and call the jar file. Is it right?

Thanks for all.

Upvotes: 0

Views: 697

Answers (1)

Voicu
Voicu

Reputation: 17860

I have done this using the Script Mediator (Groovy language). So from within the Groovy script I called my custom method by passing it the payload as JSON and saved the return value of that method as the payload. I used JSON for the payload, but feel free to leave it to default XML. You can also pass parameters, not just the payload, to your custom method.

<script language="groovy">
    println "---------- start java call -----------"
    mc.setPayloadJSON(new my.own.package.MyClass().myMethod(mc.getPayloadJSON()))
    println "----------- end java call ----------"
</script>

Added my custom jar, JSON and Groovy jars under {ESB_ROOT}/repository/components/lib and bounced the WSO2 ESB.

There are probably other ways to achieve what you need.

Upvotes: 1

Related Questions