First, we create a class that helps us deal with the responses:
public class GatewayResponse { private String response; private String from; public String getResponse() { return response; } public void setResponse(String response) { this.response = response; } public String getFrom() { return from; } public void setFrom(String from) { this.from = from; }}
Then, we create our gateway service:
@Consumes(MediaType.APPLICATION_JSON)@Path("gatewayResource")@RequestScopedpublic class GatewayResource { private final String hostURI = "http://localhost:8080/"; private Client client; private WebTarget targetUser; private WebTarget targetAddress; @PostConstruct public void init() { client = ClientBuilder.newClient(); targetUser ...