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 ) ; }
Old REST client uses new REST service