Skip to main content
Version: 7.2405.x.x LTS

RestDataSink

The RestDataSink is used to interact with REST-full web services. It uses HTTP as a transport layer and can issue GET, HEAD, POST, PUT, PATCH and DELETE requests. All requests can carry data in the form of query and matrix parameters. In addition, PATCH, POST and PUT requests can carry content that is transferred to the service. Two different message formats are supported: XML and JSON. Regarding the statistics, each REST call counts as one processed entity.

Configuration

NameType, usage constraints, defaultsDescription
connectionPoolrequired: paraVal
default: none
type: HttpConnectionPool
The HTTP connection pool to be used.
urlrequired: paraVal
default: none
type: URL
The URL of the service resource.
commandoptional: paraVal
default: GET
type: GET, HEAD, PATCH, POST, PUT, DELETE
The HTTP method or command to request on the resource.
queryParametersoptional: paraMap
default: none
type: string/string
Defines the query parameters that are encoded in the URL.Query parameters are parameters that are encoded in the URL after a "?" and that are concatenated with "&". Example: <http://url>?param1=value1&param2=value2.
matrixParametersoptional: paraMap
default: none
type: string/string
Defines the matrix parameters that are encoded in the URL.Matrix parameters are parameters that are encoded in the URL after a ";" and that are concatenated with ";". Example: <http://url>;param1=value1;param2=value2.
messageFormatoptional: paraVal
default: XMLtype: XML or JSON
Defines the format of the messages transported and received through HTTP. The Content-type and Accept HTTP headers are automatically set to the correct values: XML: application/xml; JSON: application/json. The headers can be overwritten using the headers parameter.
contentoptional: paraList
default: none
type: list of strings
The content that is sent in the body of the HTTP protocol. The content should reflect what was specified as message format. The values of the list are concatenated to form the content.Only the PATCH, POST and PUT methods can carry content in the HTTP body. Therefore, this parameter is only available for PATCH, POST and PUT requests.
headersoptional: paraMap
default: none
type: string/string
Additional headers for the HTTP request.
expectedStatusoptional: paraVal
default: 200
type: int
The expected status code of the HTTP response."200" (OK) is used as default. If the response's status code does not match the expected code, an error occurs.
encodingoptional: paraVal
default: default encoding
type: string
The name of the character set that should be used to encode the request. The available values depend on the version and vendor of the JVM. Examples: UTF-8, ISO-8859-1, UTF-16LE

Example

The principles of function are the same for the RestDataSink and the RestDataSource plug-ins. Therefore, see RestDataSource for more examples.

Delete a resource identified by the id query parameter:

<dataSink type="RestDataSink">
<dp:paraVal name="connectionPool" value="${inst.httpConnection}"/>
<dp:paraVal name="url" value="http://localhost:44432/nevisdp/resttest/person"/>
<dp:paraMap name="queryParameters">
<value name="id" value="#{in.user.id}" />
</dp:paraMap>
<dp:paraVal name="command" value="DELETE" />
</dataSink>

Call a service using JSON and the PUT method:

<dataSink type="RestDataSink">
<dp:paraVal name="connectionPool" value="${inst.httpConnection}"/>
<dp:paraVal name="url" value="http://localhost:44432/nevisdp/resttest/person"/>
<dp:paraVal name="command" value="PUT" />
<dp:paraVal name="messageFormat" value="json"/>
<dp:paraList name="content"><value><![CDATA[{
"firstName":"#{in.user.firstname}",
"id":"#{in.user.id}",
"lastName":"#{in.opa.lastname}"}]]></value>
</dp:paraList>
</dataSink>

Debug

To get more detailed information about the sent requests, set the following log setting:

<category name="ch.adnovum.dataporter.util.RestHelper"> <priority value="DEBUG"/></category>