THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
One common practice to version web services is using XML namespaces to clearly delineate the versions of a document that are compatible. For example:
Code Block | ||||
---|---|---|---|---|
| ||||
<wsdl:types> <schema targetNamespace="http://apache.org/2007/03/21/hello_world_xml_http/mixed/types" xmlns="http://www.w3.org/2001/XMLSchema"> <element name="sayHi"> <complexType /> </element> .......... </schema> </wsdl:types> |
Among many different possible implementations of service routing, one simple way ("simple" in terms of amount of code you have to write, but it does require a certain extent of familiarity with CXF internal architecture) to do this is by writing a CXF interceptor that acts as a routing mediator.
...
Code Block | ||
---|---|---|
| ||
import javax.xml.ws.Endpoint; import org.apache.cxf.jaxws.EndpointImpl; import org.apache.cxf.testutil.common.AbstractBusTestServerBase; import org.apache.hello_world_mixedstyle.GreeterImplMixedStyle; public class Server extends AbstractBusTestServerBase { protected void run() { //implementor1 and implementor2 are published using local transport Object implementor1 = new GreeterImplMixedStyle(); String address1 = "local://SoapContext/version1/SoapPort"; Endpoint.publish(address1, implementor1); Object implementor2 = new GreeterImplMixedStyle(); String address2 = "local://SoapContext/version2/SoapPort"; Endpoint.publish(address2, implementor2); //A dummy service that acts as a routing mediator Object implementor = new GreeterImplMixedStyle(); String address = "http://localhost:9027/SoapContext/SoapPort"; javax.xml.ws.Endpoint jaxwsEndpoint = Endpoint.publish(address, implementor); //Register a MediatorInInterceptor on this dummy service EndpointImpl jaxwsEndpointImpl = (EndpointImpl)jaxwsEndpoint; org.apache.cxf.endpoint.Server server = jaxwsEndpointImpl.getServer(); org.apache.cxf.endpoint.Endpoint endpoint = server.getEndpoint(); endpoint.getInInterceptors().add(new MediatorInInterceptor()); } public static void main(String[] args) { try { Server s = new Server(); s.startrun(); } catch (Exception ex) { ex.printStackTrace(); System.exit(-1); } finally { System.out.println("done!"); } } } |
...