/** * New REST client uses new REST service */ public void useNewRESTService(String address) throws Exception { List<Object> providers = createJAXRSProviders(); org.customer.service.CustomerService customerService = JAXRSClientFactory .createFromModel(address, org.customer.service.CustomerService.class, "classpath:/model/CustomerService-jaxrs.xml", providers, null); System.out.println("Using new RESTful CustomerService with new client"); customer.v2.Customer customer = createNewCustomer("Smith New REST"); customerService.updateCustomer(customer); customer = customerService.getCustomerByName("Smith New REST"); printNewCustomerDetails(customer); }
/** * 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); }
customer.v2.Customer customer = createNewCustomer("Smith New to Old REST, XPath"); client.path("customer"); client.type("application/xml");