In this sample scenario, you will use an Inbound Endpoint to expose an already defined REST API through a different port. You can reuse the REST API that was defined in the Sending a Simple Message to a Service tutorial. See Creating an Inbound Endpoint for details on how to work with inbound endpoints using WSO2 Integration Studio.
Before you begin,
- Install Oracle Java SE Development Kit (JDK) version 1.8.* and set the JAVA_HOME environment variable.
- Download the product installer from here, and run the installer.
Let's call the installation location of your product the <EI_HOME> directory.
If you installed the product using the installer, this is located in a place specific to your OS as shown below:
OS Home directory Mac OS
Select and download the relevant WSO2 Integration Studio ZIP file based on your operating system from here and then extract the ZIP file.
The path to this folder will be referred to as
<EI_TOOLING>throughout this tutorial.
Getting an error message? See the troubleshooting tips given under Installing WSO2 Integration Studio.
- If you did not try the Sending a Simple Message to a Service tutorial yet, open the WSO2 Integration Studio, click File, and click Import.
Next, expand the WSO2 category and select Existing WSO2 Projects into workspace, click Next and upload the pre-packaged project.
This contains the configurations of the Sending a Simple Message to a Service tutorial so that you do not have to repeat those steps.
- Download the MSF4J service from here and copy the JAR file to the
<EI_HOME>/wso2/msf4j/deployment/microservicesdirectory. The back-end service is now deployed in the MSF4J profile of WSO2 EI.
Let's get started!
Configuring an Inbound Endpoint
Once you have exported the ESB project as described in above, the project directory will appear with the artifacts as shown below. Note the 'HealthcareAPI' that is already included.
Right-click on SampleServices and navigate to New -> Inbound Endpoint. Select Create A New Inbound Endpoint and click Next.
Enter the following details and click Finish.
Inbound Endpoint Name QueryDoctorInboundEndpoint Inbound Endpoint Creation Type HTTP
Go to the Properties tab in the Design view and enter the following:
Inbound HTTP port 8285 Dispatch Filter Pattern /healthcare/querydoctor/.*
The endpoint will now get mapped to any URL that matches the above pattern provided. You will be exposing the health care API on a new port through this inbound endpoint.
Deploying the Inbound Endpoint
pom.xmlfile under the SampleServicesCompositeApplication project from the project explorer.
See that the newly added 'QueryDoctorInboundEndpoint' artifact is listed under Dependencies. Select this artifact to add it to the composite application project.
Save your changes.
Open the Getting Started view and click Miscellaneous →Add New Server to open the New Server dialog.
- In the New Server dialog, expand the WSO2 folder and select the version of your server.
- Click Next. In the CARBON_HOME field, provide the path to your product's home directory, and then click Next again.
Review the default port details for your server and click Next.
To deploy the CApp project to your server, select the SampleServicesCompositeApplication project from the list, click Add to move it into the configured list, and then click Finish.
On the Servers tab, note that the server is currently stopped. Click the 'play' icon on the tool bar. If prompted to save changes to any of the artifact files you created earlier, click Yes.
As the server starts, the Console tab appears. Note messages indicating that the composite app was successfully deployed.
Invoking the Inbound Endpoint
Let's send a message to the healthcare REST API on the 8285 port.
Open a command line terminal and execute the following command:
You will get the response shown below. The inbound endpoint has successfully invoked the REST API, and further, the response received by the REST API has been routed back to client through the inbound endpoint.