I have a situation where one of our applications is getting decommissioned shortly. However, there is another application that is built from it (in spring boot) which is already created. The problem is, that the upstream system sends us an XML request and the new application only consumes JSON. However, the upstream system doesn't have the bandwidth now to change their code to align to our new JSON service before the dead line of decommissioning occurs, so I need to create a XML JSON wrapper.
My question:
What ways can spring boot handle this scenario? For example, in the Controller class validate to see first if the request is XML, if it is then convert it as a JSON request which will hit my new service. What other options are there for this scenario?
@Validated
@RestController
@RequestMapping(path="/ccc")
public class CustomerCommGatewayInterface {
@Autowired
CCCatewayService gatewayService;
@RequestMapping(method=RequestMethod.POST, value="/comm-history")
public HistoryResponse getCustomerCommunicationHistory(@Valid
@RequestBody HistoryRequest request) {
return gatewayService.getHistory(request);
}
}
POJO Class
public class ServiceRequest {
@NotNull(message = "{error.application.id.invalid}")
@NotBlank(message = "{error.application.id.invalid}")
private String applicationId;
@NotNull(message = "{error.requestTypes.null}")
@RequestTypes(acceptedValues={"Stuff", "More stuff"})
private List<String> requestTypes;
@Pattern(regexp = "(Retrieve)|(Contacts)|(Documents)$", message = "{error.subService.invalid}")
private String subService;
@Pattern(regexp = "(\\d{1,10})", message = "{error.customer.id.invalid}")
private String customerId;
@Pattern(regexp = "(\\d{5})", message = "{error.account.number.invalid}")
private String accountNumber;
@Pattern(regexp = "(\\d{10})", message = "{error.mtn.invalid}")
private String number;
@EmailId()
private String emailAddress;
private String category;
private String categoryKeyword;
private String preOrderNumber;
private String requestCategory;
private String channelType;
private String ecpdId;
private String subscriberId;
private String returnCountLimit;
@Pattern(regexp = "((0?[1-9]|1[012])/(0?[1-9]|[12][0-9]|3[01])/(19|20)\\d\\d)|(^()$)", message = "{error.date.invalid}")
private String startDate;
@Pattern(regexp = "((0?[1-9]|1[012])/(0?[1-9]|[12][0-9]|3[01])/(19|20)\\d\\d)|(^()$)", message = "{error.date.invalid}")
private String endDate;
private String includeDismissedCards;
...
//getters and setters
}