/** * Old REST client uses old REST service */ public void useOldRESTService() throws Exception { List<Object> providers = createJAXRSProviders(); com.example.customerservice.CustomerService customerService = JAXRSClientFactory .createFromModel("http://localhost:" + port + "/examples/direct/rest", com.example.customerservice.CustomerService.class, "classpath:/model/CustomerService-jaxrs.xml", providers, null); System.out.println("Using old RESTful CustomerService with old client"); customer.v1.Customer customer = createOldCustomer("Smith Old REST"); customerService.updateCustomer(customer); customer = customerService.getCustomerByName("Smith Old REST"); printOldCustomerDetails(customer); }
/** * Old REST client uses new REST service with the * redirection to the new endpoint and transformation * on the server side */ public void useNewRESTServiceWithOldClientAndRedirection() throws Exception { List<Object> providers = createJAXRSProviders(); com.example.customerservice.CustomerService customerService = JAXRSClientFactory .createFromModel("http://localhost:" + port + "/examples/old/rest-endpoint", com.example.customerservice.CustomerService.class, "classpath:/model/CustomerService-jaxrs.xml", providers, null); System.out.println("Using new RESTful CustomerService with old client and the redirection"); customer.v1.Customer customer = createOldCustomer("Smith Old to New REST With Redirection"); customerService.updateCustomer(customer); customer = customerService.getCustomerByName("Smith Old to New REST With Redirection"); printOldCustomerDetails(customer); }
/** * Old REST client uses new REST service */ public void useNewRESTServiceWithOldClient() throws Exception { List<Object> providers = createJAXRSProviders(); com.example.customerservice.CustomerService customerService = JAXRSClientFactory .createFromModel("http://localhost:" + port + "/examples/direct/new-rest", com.example.customerservice.CustomerService.class, "classpath:/model/CustomerService-jaxrs.xml", providers, null); // The outgoing old Customer data needs to be transformed for // the new service to understand it and the response from the new service // needs to be transformed for this old client to understand it. ClientConfiguration config = WebClient.getConfig(customerService); addTransformInterceptors(config.getInInterceptors(), config.getOutInterceptors(), false); System.out.println("Using new RESTful CustomerService with old Client"); customer.v1.Customer customer = createOldCustomer("Smith Old to New REST"); customerService.updateCustomer(customer); customer = customerService.getCustomerByName("Smith Old to New REST"); printOldCustomerDetails(customer); }