Changing the Endpoint of a Deployed Proxy Service¶
The below sections describe how you can change the endpoint reference of a deployed proxy service without changing its own configuration. For example, in this scenario, you have two endpoints to manage two environments (i.e., Dev and QA). The endpoint URLs for the services hosted in the Dev and QA environments respectively are as follows:
-
Dev environment: http://localhost:8280/services/echo
-
QA environment: http://localhost:8281/services/echo
Creating the Endpoints¶
You need to create two Endpoint artifacts to represent the Dev and QA environments respectively. Follow the steps given below.
- Create two ESB config projects as given below.
Project Name Description HelloWorldDevResources The ESB config project will store the Endpoint artifact for the Dev environment. HelloWorldQAResources The ESB config project will store the Endpoint artifact for the QA environment. -
Create two Endpoint artifacts in two projects with the following configurations:
-
HelloWorldDevResources project
Endpoint Parameter Value Endpoint Name HelloWorldEP Endpoint Type Address Endpoint Address URL http://localhost:8280/services/ech -
HelloWorldQAResources project
Endpoint Parameter Value Endpoint Name HelloWorldEP Endpoint Type Address Endpoint Address URL http://localhost:8281/services/ech0
-
Creating the Proxy Service¶
- Create an ESB Config project named HelloWorldServices.
-
Create a proxy service in the HelloWorldServices project with the following configurations:
Parameter Value Proxy Service Name HelloWorldProxy Proxy Service Type Select Pass Through Proxy Endpoint Select HelloWorldEP (You need to select Predefined Endpoint from the endpoint options listed.)
The projects setup is now complete.
Creating the composite application projects¶
Create two composite application projects to package the QA artifacts and Dev artifacts separately. The proxy service and the Dev endpoint must go in its own CApp, and the proxy service and the QA endpoint should be in another CApp as shown below.
See the instructions on packaging artifacts into CApps.
Environment | CApp Name | Artifacts Included |
---|---|---|
Dev | HelloWorldDevCApp | HelloWorldServices project and the HelloWorldDevResources project. |
QA | HelloWorldQACApp | HelloWorldServices project and the HelloWorldQAResources project. |
Your CApp projects are now ready to be deployed to the Micro Integrator.
Deploying the Dev composite application¶
If you have an instance of WSO2 Micro Integrator setup as your Dev environment, deploy the HelloWorldDevCApp CApp in the server.
Testing the Dev environment¶
Use the following request to invoke the service:
<body>
<p:echoInt xmlns:p="http://echo.services.core.carbon.wso2.org">
<!--0 to 1 occurrence-->
<in>50</in>
</p:echoInt>
</body>
You view the response from the HelloWorldProxy.
Changing the endpoint reference¶
Follow the steps below to change the endpoint reference of the HelloWorldProxy you deployed, to point it to the QA environment, without changing its configuration.
-
Set a port offset by changing the following configuration in the
deployment.toml
file.
2. Undeploy the HelloWorldDevCApp, deploy the HelloWorldQACApp and re-start the Micro Integrator.offset=2
Testing the QA environment¶
Use the following request to invoke the service:
<body>
<p:echoInt xmlns:p="http://echo.services.core.carbon.wso2.org">
<!--0 to 1 occurrence-->
<in>100</in>
</p:echoInt>
</body>
You view the response from the HelloWorldProxy as seen in the image below.
Changing an endpoint reference¶
Once the endpoint has been created, you can update it using any one of the options listed below. The options below describe how you can update the endpoint value for QA environment.
Option 1: Using WSO2 Integration Studio¶
- Open the
HelloWorldEP.xml
file under HelloWorldQAResources project and replace the URL with the QA URL. - Save all changes.
Your CApp can be deployed to your QA Micro Integrator.
Option 2: From Command Line¶
- Open a Terminal window and navigate to
<WORKSPACE>/HelloWorldQAResources/src/main/synapse_configendpoints/HelloWorldEP.xml
file. -
Edit the HelloWorldEP.xml (e.g. using gedit or vi) under HelloWorldResources/QA and replace the URL with the QA one.
... <address uri="http://192.168.1.110:9773/services/HelloService/"/> ...
-
Navigate to
<Workspace>/HelloWorldQAResources
and build the ESB Config project using the following command:mvn clean install
-
Navigate to
<ESB_TOOLING_WORKSPACE>/HelloWorldQACApp
and build the CApp project using the following command:mvn clean install
-
The resulting CAR file can be deployed directly to the QA ESB server. For details, see Running the ESB profile via WSO2 Integration Studio .
Note
- To build the projects using the above commands, you need an active network connection.
- Creating a Maven Multi Module project that contains the above projects, allows you to projects in one go by simply building the parent Maven Multi Module project.
Option 3: Using a Script¶
Alternatively you can have a CAR file with dummy values for the endpoint URLs and use a customized shell script or batch script. The script created would need to do the following:
- Extract the CAR file.
- Edit the URL values.
- Re-create the CAR file with new values.
The resulting CAR file can be deployed directly to the QA ESB server.
Top