Pass-through Proxy Service with an Endpoint Reference
This page describes how you can create the ESB projects for the endpoint values for Dev and QA environments. Another ESB project is created for proxy configuration where the endpoints are referenced.
Creating the Endpoint Reference Projects
In this section, you will create two ESB projects containing endpoint values for the Dev environment and the QA environment.
The endpoints URLS for the services hosted in Dev and QA environments respectively are:
- In ESB Tooling, choose File > New > ESB Config Project and create a project called HelloWorldDevResources.
- Right click the HelloWorldResources project and select New > Endpoint.
Ensure Create a New Endpoint is selected and click Next. Fill in the information as in the table below:
Field Value Endpoint Name HelloWorldEP Endpoint Type Address Endpoint Address http://localhost:9772/services/HelloService/ Address endpoint needs to be in the format
<IP Address of Dev instance>:<port number>/services/HelloService
. Since the port offset for the Dev instance is 9, the port where the service will be hosted is 9772.Click Finish.
- Similarly, to create resources for the QA environment, create another ESB Config project named HelloWorldQAResources and create an endpoint named HelloWorldEP. Provide the following as the endpoint address:
http://localhost:9773/services/HelloService/
Creating the Proxy Service Project
In this section, you will create the ESB project containing the proxy service configuration.
In ESB Tooling, choose File -> New -> ESB Solution Project, and create a Project called HelloWorldServices . Only select the option for Create Registry Resources Project and click Finish.
Right-click the HelloWorldServices project in the project explorer, choose New -> Proxy Service. Ensure Create a New Proxy Service is selected and click Next. Fill in the details as specified in the table below:
Field 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.)
Click Finish.
The projects setup is now complete. You now need to create CApp projects for each of the Composite Applications you want to generate. The ESB proxy service and Dev endpoint must go in its own CApp, and you create a separate CApp for the ESB proxy service and QA endpoint.
Creating the Composite Application Project
- In ESB Tooling, choose File -> New -> Composite Application Project.
- Name the project HelloWorldDevCApp.
- Select HelloWorldServices and HelloWorldDevResources projects in the dependencies list.
Click Finish. - Similarly, create HelloWorldQACApp containing the projects HelloWorldServices and HelloWorldQAResources.
Your CApp projects are now ready to be deployed to your ESB servers. For details on how to deploy the CApp project, see Deploying Composite Application in the Server in WSO2 Admin Guide.
Testing the Service
- Open the Dev ESB Server admin console by navigating to the admin console URL that is listed in the terminal.
- Log in using admin as the username and password.
- Go to Services > List.
- Click on Try This Service for the HelloWorldProxy (which you just deployed using the CApp).
Use the following request to invoke the service:
<body> <p:greet xmlns:p="http://www.wso2.org/types"> <!--0 to 1 occurrence--> <name>?</name> </p:greet> </body>
Enter the name and click Send.
You should see a response from the HelloWorld service hosted in WSO2 AS.
Updating the Endpoint URI Value
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 ESB Tooling
- 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 ESB server. For details on how to deploy the CApp project, see Deploying Composite Application in the Server in WSO2 Admin Guide.
Option 2: From Command Line
- Open a Terminal window and navigate to
<ESB_TOOLING_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
<ESB_TOOLING_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 Deploying Composite Applications in the Server in WSO2 Admin Guide.
- 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.