/** * New REST client uses old REST service */ public void useOldRESTServiceWithNewClient() throws Exception { List<Object> providers = createJAXRSProviders(); org.customer.service.CustomerService customerService = JAXRSClientFactory .createFromModel("http://localhost:" + port + "/examples/direct/rest", org.customer.service.CustomerService.class, "classpath:/model/CustomerService-jaxrs.xml", providers, null); // The outgoing new Customer data needs to be transformed for // the old service to understand it and the response from the old service // needs to be transformed for this new client to understand it. ClientConfiguration config = WebClient.getConfig(customerService); addTransformInterceptors(config.getInInterceptors(), config.getOutInterceptors(), true); System.out.println("Using old RESTful CustomerService with new client"); customer.v2.Customer customer = createNewCustomer("Smith New to Old REST"); customerService.updateCustomer(customer); customer = customerService.getCustomerByName("Smith New to Old REST"); printNewCustomerDetails(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); }
addTransformInterceptors(config.getInInterceptors(), config.getOutInterceptors(), true);