2009-07-13

how to programmaticaly change jaxws service endpoint

sometimes there is a need to override an endpoint address whom default value is specified in wsdl resource. everything works fine by doing something like:
SomeServicePort ssp = service.getSomeServicePort();
BindingProvider proxy = (BindingProvider) ssp;
proxy.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://ep");

if an protocol of endpoint address differes in wsdl and its java implementation it could be a problem.
the solution is to use a value in wsdl which doesn't contain protocol specification e.g. REPLACE_WITH_ACTUAL_URL.