Written by ilgrosso
Starting with recent SNAPSHOTs releases of 1.2.0, it has become fairly easy to call Apache Syncope via REST from your Java application.
Basically, all you need is to obtain a SyncopeClient instance via the following statement in order to set the base REST URL and credentials:
SyncopeClient client = new SyncopeClientFactoryBean(). setAddress("http://localhost:9080/syncope/rest/"). create("username", "password");
and you get enabled for any kind of REST service interaction with Apache Syncope; for example (retrieving an user given his username):
UserTO anyUser = client.getService(UserService.class).read("anyUser");
There are of course many other options to customize the client configuration, including the content-type to be used for data exchange, JSON (default) or XML.
The only Maven dependency needed is:
<dependency> <groupId>org.apache.syncope</groupId> <artifactId>syncope-client</artifactId> <version>1.2.0-SNAPSHOT</version> </dependency>