0

I am calling an http endpoint in WsO2 Integration Studio. How can I give the address of this endpoint externally as envrionment? .Because the addresses of my endpoints are different in dev environment and live environment. I looked at the document about it. But I couldn't do it. I want to changeable localhost:XXX address as a environment

Below is my WSO2 code:

         <call>
            <endpoint>
                <http method="get" uri-template="http://localhost:XXX/test">
                    <suspendOnFailure>
                        <initialDuration>-1</initialDuration>
                        <progressionFactor>-1</progressionFactor>
                        <maximumDuration>0</maximumDuration>
                    </suspendOnFailure>
                    <markForSuspension>
                        <retriesBeforeSuspension>0</retriesBeforeSuspension>
                    </markForSuspension>
                </http>
            </endpoint>
        </call>
Ahmet Kalem
  • 113
  • 6

2 Answers2

1

You can use $SYSTEM:EP_ADDR as the uri-template and set the environment variable EP_ADDR on your environment,

<call>
    <endpoint>
        <http method="get" uri-template="$SYSTEM:EP_ADDR">
            <suspendOnFailure>
                <initialDuration>-1</initialDuration>
                <progressionFactor>-1</progressionFactor>
                <maximumDuration>0</maximumDuration>
            </suspendOnFailure>
            <markForSuspension>
                <retriesBeforeSuspension>0</retriesBeforeSuspension>
            </markForSuspension>
        </http>
    </endpoint>
</call>

The above config works in fine MI 4.1.0. If this doesn't help please specify the version you are using.

For more info: https://ei.docs.wso2.com/en/latest/micro-integrator/develop/injecting-parameters/#endpoint-parameters

To see how we can inject variables in embed runtime of Integration Studio check https://medium.com/think-integration/how-to-inject-environment-variables-to-wso2-integration-studio-runtime-83b8f0cb882e

sanoJ
  • 2,935
  • 2
  • 8
  • 18
1

What Sanoj mentioned is one option. Another option is to use the Property Mediator. This will allow you are dynamically constructing the URL using the Environment variable or file parameters.

<property expression="concat('https://', get-property('env', 'host'), ':', get-property('env', 'port'))" name="uri.var.ep" scope="default" type="STRING"/>

Then use it in your Endpoint configuration

<call>
   <endpoint>
       <http method="get" uri-template="{uri.var.ep}">
           <suspendOnFailure>
               <initialDuration>-1</initialDuration>
               <progressionFactor>-1</progressionFactor>
               <maximumDuration>0</maximumDuration>
           </suspendOnFailure>
           <markForSuspension>
               <retriesBeforeSuspension>0</retriesBeforeSuspension>
           </markForSuspension>
       </http>
   </endpoint>
</call>

Update

In order to add them to your runtime you need to export them as environment variables in the server runtime. If you are on a linux environment you can add them into the integrator.sh (Depending on the Product you are using this may change.) For example for the given example above you can add the following two lines.

export host=abcd.efg.com
export port=8987
ycr
  • 12,828
  • 2
  • 25
  • 45
  • How can I export the values in the property in the example? Because I will use the car file I created in wso2 intregration studio in ci cd deployment processes, I need to use this method. – Ahmet Kalem Feb 10 '23 at 06:24
  • @AhmetKalem check the update on the answer. – ycr Feb 10 '23 at 12:31