I have designed the needed REST Service with JERSEY 1.5, using declared interface like:
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public IMyDTO doIt(ICustomer customer) {
return MySupport.createDTO(customer);
}
If i trying to call this service, using JERSEY 1.5 Client API, the following error occured:
Can not construct instance of test.ICustomer, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information
Currently i specify such parameter by client:
ClientConfig clientConfig = new DefaultClientConfig();
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
Boolean.TRUE);
Client client = Client.create(clientConfig);
WebResource webResource = client.resource(restResource);
ClientResponse response = webResource.path(restResourcePath)
.type(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.post(ClientResponse.class, customer);
if (response != null) {
if (response.hasEntity()) {
result = response.getEntity(IMytDTO.class);
}
....
.
The ICustomer and IMyDTO are java interfaces without any jackson annotation. The implementations have no jackson annotations too.
My Question: how to (de) serialize the objects , if REST Service (Client) are used?
I would not change the java interfaces and use the implementations on service and client side...