Configure REST DSL (REST)
Configuring with Java
In Java, we are able to configure the REST DSL using the restConfiguration()
builder API. To configure the REST DSL to use the Servlet component as the underlying implementation, we would do the following:
restConfiguration().component("servlet").bindingMode("json").port("8181")
.contextPath("/camel-example-servlet-rest-blueprint/rest");
Configuring with XML
In XML, we are able to configure the REST DSL using the restConfiguration
element. To configure the REST DSL to use the Servlet component as the underlying implementation, we would do the following:
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
...
<restConfiguration component="servlet"
bindingMode="json"
contextPath="/camel-example-servlet-rest-blueprint/rest"
port="8181">
<dataFormatProperty key="prettyPrint" value="true"/>
</restConfiguration>
...
</camelContext>
Configuration Options
Java DSL | XML DSL | Description |
---|---|---|
|
| Specifies the Camel component to use as the REST transport (for example, |
|
| The protocol to use for exposing the REST service. Depends on the underlying REST implementation, but |
|
| Hostname to use for exposing the REST service. |
|
| Port number to use for exposing the REST service. |
|
| The leading context path for the REST services. This can be used with components such as Servlet, where the deployed Web application is deployed using a |
|
| If a hostname is not set explicitly, this resolver determines the host for the REST service. |
|
| Enables binding mode for JSON or XML format messages. (ie. possible values are: |
|
| Specifies whether to skip binding on output, if there is a custom HTTP error code header. Allows you to build custom error messages that do not bind to JSON or XML. Default is |
|
| Specifies the component that Camel uses to implement the JSON data format. Possible values are: |
|
| Specifies the component that Camel uses to implement the XML data format. Possible value is: |
|
| Enables you to set arbitrary component level properties on the underlying REST implementation. |
|
| Enables you to set arbitrary endpoint level properties on the underlying REST implementation. |
|
| Enables you to set arbitrary consumer endpoint properties on the underlying REST implementation. |
|
| Set arbitrary properties on the underlying data format component (for example, Jackson or JAXB). |