within Java, can I get a variable with messageContext.getMessage().getVariable() ?

Not applicable

Suppose I've set a variable called "url" in my API Proxy flow, maybe using AssignMessage/AssignVariable, or via Javascript context.setVariable(), or implicitly in some other way.

If I then call messageContext.getMessage().getVariable("url") from within Java Callout class, will I be able to retrieve the variable value?

Solved Solved
1 5 1,646
1 ACCEPTED SOLUTION

Not applicable

You dont need the getMessage()

You can get your variables direcrly off the context for instance messageContext.getVariable("foo");

I would be careful about setting variables with names that may be reserved like url. For instance i would set my var to local_url or script_url. This avoids a scenerio where you can't overwrite a variable and it doesnt fail giving you a false sense of the variable being set.

View solution in original post

5 REPLIES 5

so you have created a variable 'url' in one of your policies? then you should be able to access that in javacallout using messageContext.getVariable('url')

Not applicable

You dont need the getMessage()

You can get your variables direcrly off the context for instance messageContext.getVariable("foo");

I would be careful about setting variables with names that may be reserved like url. For instance i would set my var to local_url or script_url. This avoids a scenerio where you can't overwrite a variable and it doesnt fail giving you a false sense of the variable being set.

Thanks Guys! One more question related to java callouts. How to handle exceptions/faults in Java callouts? The cookbook samples aren't very good. I'm simply trying to pass some simple error info like error code, text from Java class to edge policy. Not working. Any samples out there?

@ek9jawan sounds like a great new question thread 🙂 To keep it easier for people to navigate through the community content, would be great if you could post this as a separate questions. Can you post this question as a separate thread?

Please post this as a separate question.