foz1284
foz1284

Reputation: 373

In Mule, How would I create an Array using MEL to be passed into a Java component

I am Trying to Use a Java component which has 3 string parameters,

I believe to get the reflection entry point resolver to work for this I need to set the payload to be an array of 3 strings however I am struggling to find how to do this,

Any help would be appreciated.

thanks

I am wanting to pass in an xml template file location, xml xpath and new value for the node which the xpath is returning(these will be Hardcoded as array items of the payload(I assume this is the correct approach but I cannot see how to do this)):

    public class XMLParserWithParameters
{
    public static Object parse2(String TemplatePath, String XPathQuery, String NewValue) throws Exception
    {   

Upvotes: 0

Views: 6403

Answers (4)

user10852029
user10852029

Reputation: 1

If you are trying to set Array of String as Payload simply this should work

Upvotes: 0

David Dossot
David Dossot

Reputation: 33413

No need to create an array, just call the static method from MEL:

#[your.package.XMLParserWithParameters.parse2('a','b','c')]

Upvotes: 2

user1760178
user1760178

Reputation: 6657

From your post I guess you are looking for a way to set a String array as payload in the config file.

Try the following way

 <set-payload value="#[new String[]{&quot;String1&quot; , &quot;String2&quot;, &quot;String3&quot;}]"></set-payload>

Or You can also try the following way.

<expression-transformer>
   <return-argument expression="new String(&quot;Test&quot;)" />
   <return-argument expression="new String(&quot;Test3&quot;)" />
   <return-argument expression="new String(&quot;Test5&quot;)" />
</expression-transformer>

In the expression you can use any of the Mule Expressioin Landuage expression.

Hope this helps.

Upvotes: 1

foz1284
foz1284

Reputation: 373

I have found that this can be achieved using an expression transformer by setting multiple return values which will create an array of strings.

Upvotes: 0

Related Questions