The HTTP endpoint allows you to define REST endpoints using URI templates similar to the REST API. The URI templates allow a RESTful URI to contain variables that can be populated during mediation runtime using property values whose names have the "
uri.var." prefix. An HTTP endpoint can also define the particular HTTP method to use in the RESTful invocation.
The syntax is as follows.
HTTP Endpoint Attributes
The URI template that constructs the RESTful endpoint URL at runtime.
Using the URI postfix property:
Let's take a look at it using an example. If you add a
The HTTP method to use during the invocation.
The parameters to configure an HTTP endpoint are as follows.
|Name||This parameter is used to enter a unique name for the endpoint.|
The URI template of the endpoint. Insert
If the endpoint URL is an encoded URL, then you need to add
The HTTP method to use during the invocation of the endpoint. Supported methods are as follows.
|Show Advanced Options||Click this link if you want to add advanced options to the endpoint. See Advanced Options for details of common advanced options you can add.|
You can create HTTP endpoints by specifying values for the parameters given above.
Alternatively, you can specify one parameter as the HTTP endpoint by using multiple other parameters, and then pass that to define the HTTP endpoint as follows:
Example 1 - populating an HTTP endpoint during mediation
The URI template variables in this example HTTP endpoint can be populated during mediation as follows:
This configuration will cause the RESTful URL to evaluate to:
Example 2 - Sending a Message from a WebSocket Client to an HTTP Endpoint
The following sections walk you through a sample scenario that demonstrates how to send a message from a WebSocket client to an HTTP endpoint via the ESB Profile of WSO2 Enterprise Integrator (WSO2 EI):
If you need to send a message from a WebSocket client to an HTTP endpoint via the ESB Profile of WSO2 EI, you need to establish a persistent WebSocket connection from the WebSocket client to the ESB Profile of WSO2 EI.
To demonstrate this scenario, you need to create two dispatching sequences. One for the client to back-end mediation, and another for the back-end to client mediation. Finally you need to configure the WebSocket inbound endpoint of the ESB Profile of WSO2 EI to use the created sequences and listen on port 9091.
- Start the ESB Profile of WSO2 EI. For information on how to start the ESB Profile, see Running the Product.
- Download the sample netty artifacts.
Configuring the sample scenario
Create the sequence for client to back-end mediation as follows:
This sequence calls an HTTP endpoint.
Create the sequence for back-end to client mediation as follows:
Configure the WebSocket inbound endpoint in the ESB Profile of WSO2 EI as follows to use the created sequences and listen on port 9091:
Executing the sample scenario
Execute the following command to start the WebSocket client:
Analyzing the output
If you analyze the log, you will see that a connection from the WebSocket client to the ESB Profile of WSO2 EI is established. You will also see that the sequences are executed by the WebSocket inbound endpoint.