Manjunath Manjunath - 1 year ago 92
reST (reStructuredText) Question

Jersey Jackson and Spring Service

We are using Jersey, Jackson and Spring service (@service) annotation to expose some REST based Web-Services. Request and response data are exchanged in JSON Format.

Below is the Service Request Object content:

public class ServiceRequest{
private RequestHeader requestHeader;
private List<BaseEntity> requestData;

All specific entities will extend from BaseEntity class. For example :

public class User extends BaseEntity{
private String userName;

For all service operation we accept only ServiceRequest Object by passing list of request data objects. Now when we try to call these operation from REST Client, these are failing with

userName is not found as part of BaseEntity.

This is because while converting, Jersey/Jackson tries to autodetect the incoming field names with the specified object's property.

I want to know is there any way, I can handle this in an intelligent way. We do not have an option to change the signature of the Service. Really appreciate your help on this.

Answer Source

The below link has the answer for my question. Thank you for the support.

Polymorphism in jackson annotations: @JsonTypeInfo usage

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download