Hi Rouble,
Basically you can get the base endpoint information on service side for
incoming message using WebServiceContext:
@WebService(name = Sample",
serviceName = "SampleService",
targetNamespace = "http://apache.org/sample")
public class SampleImpl implements Sample {
@Resource
private WebServiceContext context;
...
String endpoint =
context.getMessageContext().get("org.apache.cxf.request.url");
...
}
I would also suggest to evaluate Camel to implement such routing:
http://camel.apache.org/routing-slip.html.
Regards,
Andrei.
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of rouble
Sent: 25 May 2012 18:47
To: [email protected]
Subject: Change endpoint address of service
We have versioned services that runs on:
https://example.com:8443/v2/foo
https://example.com:8443/v4/foo
https://example.com:8443/v7/foo
Every time there is a backwards in-compatible change we leave the old service
in place, and create a new one. This supports older clients.
If the changes are backwards compatible, we only bump up the number in the URL.
We also have a mediator service that runs on:
https://example.com:8443/foo
We want all generated clients to come in through the mediator so we can route
them accordingly. So, I want to change the endpoint addresses in the WSDL of
the versioned services so that they all have the endpoint address of the
mediator service. This is necessary because if a version/URL is re-numbered
(because it is backwards compatible), I can route the older clients to the
newer service. So, in this example, I could route a v5 client to the service at
the v7 URL.
I have done some nifty spring EL like this right now, to set the
publishedEndpointUrl:
<bean id="localhost" class="java.net.InetAddress"
factory-method="getLocalHost" />
<bean id="publishedWebServiceUrl" class="java.lang.String">
<constructor-arg value="#{'http://' + localhost.hostName + '/foo'}" />
</bean>
<jaxws:endpoint
id="fooWS"
address="/v2/foo"
publishedEndpointUrl="#publishedWebServiceUrl"/>
But this does not get the port (in this case 8443), and it does not work if web
service is behind a proxy.
Instead of trying to re-build the endpoint address from scratch I was wondering
if there is a way to get the existing endpoint address at runtime, massage it a
little bit, and reset it - or something to that effect.
tia,
rouble