The RESTEasy component in SwitchYard provides REST-based binding support for services and references in SwitchYard.
Binding Services with RESTEasy
Composite-level services can be exposed as a REST-based service using the <binding.rest> binding definition. The following configuration options are available for binding.rest when binding services:
Here's an example of what a REST service binding looks like:
<sca:service name="OrderService" promote="OrderService/OrderService">
<rest:binding.rest>
<rest:interfaces>org.switchyard.quickstarts.rest.binding.OrderResource,org.switchyard.quickstarts.rest.binding.TestResource</rest:interfaces>
<rest:contextPath>rest-binding</rest:contextPath>
</rest:binding.rest>
</sca:service>
Binding References with RESTEasy
Binding a reference with REST can be used to make REST-based services available to SwitchYard services. The following configuration options are available for binding.rest when binding references:
-
interfaces : A comma seperated list of interfaces or abstract/empty classes with JAX-RS annotations.
-
address : A URL that points to the root path of resources. This is only applicable for Reference bindings. It is optional and if not specified will default to http://127.0.0.1:8080/.
-
timeout : The request's time-out value in milliseconds.
-
contextPath : Additional context path for the REST endpoint. Default is none.
-
proxy : HTTP Proxy settings for the endpoint.
-
basic/ntlm : authentication configuration for the endpoint.
Here's an example of what a REST reference binding looks like:
<sca:reference name="Warehouse" promote="OrderService/Warehouse" multiplicity="1..1">
<rest:binding.rest>
<rest:interfaces>org.switchyard.quickstarts.rest.binding.WarehouseResource</rest:interfaces>
<rest:address>http://localhost:8080</rest:address>
<rest:contextPath>rest-binding</rest:contextPath>
</rest:binding.rest>
</sca:reference>
In this example above the resource URLs will start from http://localhost:8080/rest-binding.
Proxy Configuration
If the REST reference needs to pass through a proxy server then the proxy server configuration can be provided using the proxy element. The following configuration options are available:
-
host : The proxy host.
-
port : The proxy port (optional).
-
user : The proxy user (optional).
-
password : The proxy password (optional).
<sca:reference name="Warehouse" promote="OrderService/Warehouse" multiplicity="1..1">
<rest:binding.rest>
<rest:interfaces>org.switchyard.quickstarts.rest.binding.WarehouseResource</rest:interfaces>
<rest:address>http://localhost:8080/rest-binding</rest:address>
<rest:proxy>
<rest:host>host</rest:host>
<rest:port>8090</rest:port>
<rest:user>Beal</rest:user>
<rest:password>conjecture</rest:password>
</rest:proxy>
</rest:binding.rest>
</sca:reference>
Authentication Configuration
If the REST reference endpoint is secured using BASIC/NTLM, then the authentication configuration can be provided using the basic or ntlm elements. The following configuration options are available:
-
user : The authentication user.
-
password : The authentication password.
-
realm/domain : The authentication realm or the Windows domain.
A sample NTLM authentication configuration:
<sca:reference name="Warehouse" promote="OrderService/Warehouse" multiplicity="1..1">
<rest:binding.rest>
<rest:interfaces>org.switchyard.quickstarts.rest.binding.WarehouseResource</rest:interfaces>
<rest:address>http://localhost:8080/rest-binding</rest:address>
<rest:ntlm>
<rest:user>user</rest:user>
<rest:password>password</rest:password>
<rest:domain>domain</rest:domain>
</rest:ntlm>
</rest:binding.rest>
</sca:reference>
SSL Configuration
If the REST reference endpoint is secured using SSL, the following optional configuration options are available:
-
verifier : Allowed options are ANY,STRICT or BROWSER. Please read Apache HTP component documentation for more info.
-
keystore : The SSL keystore.
-
keystorePass : The password for SSL keystore.
-
truststore : The SSL truststore.
-
truststorePass : The password for SSL truststore.
A sample configuration:
<sca:reference name="Warehouse" promote="OrderService/Warehouse" multiplicity="1..1">
<rest:binding.rest>
<rest:interfaces>org.switchyard.quickstarts.rest.binding.WarehouseResource</rest:interfaces>
<rest:address>https://localhost:8443/rest-binding</rest:address>
<rest:ssl>
<rest:verifier>ANY</rest:verifier>
<rest:keystore>https.jks</rest:keystore>
<rest:keystorePass>changeit</rest:keystorePass>
<rest:truststore>client.jks</rest:truststore>
<rest:truststorePass>changeit</rest:truststorePass>
</rest:ssl>
</rest:binding.rest>
</sca:reference>