REST Service Application
The REST Application allows to invoke REST Services with Process Data and retrieve
data from the response of the REST services into Process Data.
You can perform following operations on a REST Service Application.
Setting REST Service Properties
Apart from the common properties, the following property tabs are provided for a REST Service application:
Figure: Properties - REST Service Application
Parameters
You can define parameters to access the data associated with the application.
The REST Application only allows for zero or one Output Parameter which is
representing the HTTP Response content of the REST Service invocation.
It allows for multiple Input Parameters. One Input Parameter can
be selected to be transferred in the body of the HTTP Request of the REST Service invocation.
All other Input Parameters are expected to be provided in the header and hence have to
be primitive data.
Click the
Add icon to add the parameters.
- Body Input Access Point - By default None is selected. When you select Body Input access point then
the data value will be in the body of the exchange.
All other IN access points will be set to the header of the exchange.
- Body Output Access Point - By default None is selected. When you select Body Output access point then
the data value will be in the body of the exchange.
All other OUT access points will be set to the header of the exchange.
- Name - Specify name for the new parameter
- Direction - Select direction for the data from the Direction drop-down list.
If at least one out mapping is provided then application is considered send/receive.
If no out mapping provided the application is considered as send only.
Following options are provided:
- In - For read access. If an IN access point is used in the request URL it
should not be defined as Body Input Access Point.
- Out - For write access
- Data Type - Following data types are supported:
- Primitive - If you select Primitive data type, you need to provide Primitive Type.
- Structured Data - If you select structured data, you need to provide Structure Type.
It also lists structured types from other models.
To delete the parameters, select the added parameter and click the Delete
icon.
Test
- Reinitialize Input Data Fields - Input generates a string representation top-level JSON
object with all Input Parameters as fields. The objects underneath these fields represent
empty structures or primitive literals of the data types of the Input Parameters.
For arrays, one entry is created.
- Reinitialize External Web Application - Invoking the test performs the REST call and
displays a string value of the body of the HTTP response of the REST Service.
Figure: Properties - Test
Configuration
Figure: Properties - Configuration
- URI - Specify the URI of REST web services.
If you don't specify using place holders anywhere in your URL,
IN access point get appended as URL parameter.
However, as soon as you use a place holder for a certain IN access point in your URL,
the concrete value should end up where you have specified it. For example, in the following URL:
localhost://RestService.vcs/GetRestData/{id}
Should replace the place holder {id} with the value for IN access point id at runtime.
- Query String - Based on input parameters, the query string gets formed and displayed. The formed string
automatically gets appended to the URI for REST call.
Each IN access point will be appended as URL parameter with two exceptions:
- There is an explicit place holder for it. In that case the place holder will be replaced by the actual value at runtime.
- The IN access point has been defined as Body Input Access Point. In that case it will be handled as payload for a POST request.
- Command - By default, GET is selected. You can select following options as request methods:
- Request Type - By default, None is selected. You can select the following request types based on the
type of web service:
- Response Type - By default, HTML is selected. You can select following types based on the response
returned by web service.
- Allow Cross Domain Call - Select this checkbox to allow a web page to make
XMLHttpRequests to another domain. For more information, please refer to the
Cross-origin resource sharing.
- Transacted - If selected transacted mode for request processing
- Auto Startup - Specifies whether to auto startup the Camel route for this application.
- HTTP Headers - Could be derived from process data, configuration variable or static data being entered.
- Name - Specify the name to be passed to HTTP header
- Source - Specify the source of the HTTP header. There are three options:
- Direct - the header value is entered in the Value field (static data).
- Data - the value is derived from process data (matches the name of a primitive IN parameter).
- Configuration Variable - the header value is defined as a configuration variable
- Value - Specify the value to be passed to HTTP header
Security
Based on the security mode you need to specify the details.
For more information please refer to chapter
Security Propagation for Web Applications
of the Concepts
Security Propagation for Web Applications in the Concepts
handbook. The following options are provided in the Security Mode drop down list:
Basic HTTP Basic Authentication
Figure: Basic HTTP Basic Authentication
Custom Security Token
Figure: Custom Security Token
The Security Token value can be derived from a configuration variable, a process data or entered directly.
If the Token Key input field matches a primitive IN parameter, then the Security Token value and CV check box will be made read only.
The key/value pair gets added to the header of the HTTP request.
Proxy Configuration
However, note that you may need to add proxy settings to access the service. To do the proxy settings,
add the following bean in the context file or any Spring configuration file.
<bean id="httpConfiguration" class="org.apache.camel.component.http.HttpConfiguration">
<property name="proxyHost" value="<yourhostname>"/>
<property name="proxyPort" value="<yourportname>" />
</bean>
<bean id="http" class="org.apache.camel.component.http.HttpComponent">
<property name="camelContext" ref="defaultCamelContext" />
<property name="httpConfiguration" ref="httpConfiguration" />
</bean>