Note that there are some explanatory texts on larger screens.

plurals
  1. POCamel best practices for RESTfull web service exposing
    primarykey
    data
    text
    <p>I want to expose a RESTfull webservice using camel. I have used URI templates to define my service contracts. I want to know how should I route the requests to the relevant method of my ServiceProcessor based on the URI template.</p> <p>As an example, take the following two operations:</p> <pre><code> @GET @Path("/customers/{customerId}/") public Customer loadCustomer(@PathParam("customerId") final String customerId){ return null; } @GET @Path("/customers/{customerId}/accounts/") List&lt;Account&gt; loadAccountsForCustomer(@PathParam("customerId") final String customerId){ return null; } </code></pre> <p><strong>Following is the route I have used:</strong></p> <pre><code>&lt;osgi:camelContext xmlns="http://camel.apache.org/schema/spring"&gt; &lt;route trace="true" id="PaymentService"&gt; &lt;from uri="`enter code here`cxfrs://bean://customerCareServer" /&gt; &lt;process ref="customerCareProcessor" /&gt; &lt;/route&gt; &lt;/osgi:camelContext&gt; </code></pre> <p>Is there any way that I can match the uri header(Exchange.HTTP_PATH) to an existing template uri in my service definition?</p> <p><strong>Following is the Service Contract for my service:</strong></p> <pre><code>@Path("/customercare/") public class CustomerCareService { @POST @Path("/customers/") public void registerCustomer(final Customer customer){ } @POST @Path("/customers/{customerId}/accounts/") public void registerAccount(@PathParam("customerId") final String customerId, final Account account){ } @PUT @Path("/customers/") public void updateCustomer(final Customer customer){ } @PUT @Path("/accounts/") public void updateAccount(final Account account){ } @GET @Path("/customers/{customerId}/") public Customer loadCustomer(@PathParam("customerId") final String customerId){ return null; } @GET @Path("/customers/{customerId}/accounts/") List&lt;Account&gt; loadAccountsForCustomer(@PathParam("customerId") final String customerId){ return null; } @GET @Path("/accounts/{accountNumber}") Account loadAccount(@PathParam("accountNumber") final String accountNumber){ return null; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload