0
votes

I have the config with development and production sections. This sections contain the URLs of backends. In my inSequence i need it to Callout to these backends several times per request.

<config>
 <env>prod</env>
 <backend env="prod">http://localhost:1234/</backend>
 <backend env="dev">http://localhost:2345/</backend>
</config>

I read this config from Local Entry (as XML) and want to set Callout's URL as an Property. I don't want to hardcode these backends inside my code with "Switch" statement, because it's possible to use more than two environments. Could you please show me an example?

Thank you.

2

2 Answers

1
votes

You can read xml file in registry. Simply define property of OM type like this:

<property name="test" expression="get-property('registry','conf:/test.xml')" scope="default" type="OM" />

Then you can see the value by logging like this:

<log level="custom"> <property name="test.b" expression="$ctx:test//b" /> </log>

And in the xml file that you have put in the root of registry, you would fill it like:

<a>Hello<b>WSO2</b></a>

I have learned it from this link.

0
votes

I found the answer. According to source of Callout mediator:

CalloutMediator.java

It uses "To" header if URL is not specified.