Hi Francesco,

Thanks for your response. No special reason not to use the Syncope client
API as such, the code just comes from when I used the CXF WebClient Object
originally to play around with Syncope's REST API. Here is the code snippet
if you can spot anything obviously wrong:

String address = "http://localhost:9080/syncope/rest/";;

WebClient client = WebClient.create(address, Collections.singletonList(new
JacksonJsonProvider())););
String authorizationHeader = "Basic " + Base64Utility.encode(("admin" + ":"
+ "password").getBytes());

client.header("Authorization", authorizationHeader);
// client.accept("application/xml"); // WORKS
client.accept("application/json"); // DOESN'T WORK

WebClient.getConfig(client).getInInterceptors().add(new
LoggingInInterceptor());

List<RoleTO> roles = new ArrayList<RoleTO>();

client = client.path("roles");

@SuppressWarnings("unchecked")
PagedResult<RoleTO> existingRoles =
(PagedResult<RoleTO>)client.get(PagedResult.class);


Colm.




On Sun, May 10, 2015 at 6:05 AM, Francesco Chicchiriccò <[email protected]
> wrote:

> On 10/05/2015 06:54, Francesco Chicchiriccò wrote:
>
>> On 08/05/2015 17:41, Colm O hEigeartaigh wrote:
>>
>>> Hi all,
>>>
>>> We have some test code that uses Apache CXF's WebClient class to retrieve
>>> roles from Syncope.
>>>
>>> With Syncope 1.1.x, we could retrieve all roles as follows:
>>>
>>> Collection<? extends RoleTO> existingRoles =
>>> client.getCollection(RoleTO.class);
>>>
>>> However, with Syncope 1.2.3 this does not work. I can get it working as
>>> follows when I'm using XML:
>>>
>>>   PagedResult<RoleTO> pagedResult = client.get(PagedResult.class);
>>>
>>> However, when using JSON (+ Jackson) I get the following error:
>>>
>>> Caused by: org.codehaus.jackson.map.JsonMappingException: Can not
>>> construct
>>> instance of org.apache.syncope.common.AbstractBaseBean, problem: abstract
>>> types can only be instantiated with additional type information
>>>   at [Source: java.io.SequenceInputStream@66c677a7; line: 1, column: 69]
>>> (through reference chain:
>>> org.apache.syncope.common.reqres.PagedResult["result"])
>>>
>>> Any ideas on how I can get the results here using JSON?
>>>
>>
>> Hi Colm,
>> any special reason for not using SyncopeClient?
>>
>> SyncopeClient client = new SyncopeClientFactoryBean().setAddress(ADDRESS)
>> Konsole output .create(ADMIN_UNAME, ADMIN_PWD);
>>
>
> Ops, it should have been:
>
> SyncopeClient client = new
> SyncopeClientFactoryBean().setAddress(ADDRESS).create(ADMIN_UNAME,
> ADMIN_PWD);
>
>
>  then
>>
>> PagedResult<RoleTO> roleTOs = client.getService(RoleService.class).list();
>>
>> This is by default using JSON.
>>
>> Alternatively, can you show how your client instance above is obtained?
>>
>> HTH
>> Regards.
>>
>>  --
> Francesco Chicchiriccò
>
> Tirasa - Open Source Excellence
> http://www.tirasa.net/
>
> Involved at The Apache Software Foundation:
> member, Syncope PMC chair, Cocoon PMC, Olingo PMC
> http://people.apache.org/~ilgrosso/
>
>


-- 
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com

Reply via email to