Skip to content

Instantly share code, notes, and snippets.

@whaley
Created July 18, 2011 22:06
Show Gist options
  • Save whaley/1090795 to your computer and use it in GitHub Desktop.
Save whaley/1090795 to your computer and use it in GitHub Desktop.
public <T> T publishEndpointAndReturnProxy(Class<T> jaxWsAnnotatedInterface, T serviceImplementation) {
if (jaxWsAnnotatedInterface.isInterface() &&
jaxWsAnnotatedInterface.getAnnotation(WebService.class) != null &&
jaxWsAnnotatedInterface.isInstance(serviceImplementation)) {
String endpointUrl = getAvailableEndpointUrl();
endpoint = Endpoint.publish(endpointUrl, serviceImplementation);
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(jaxWsAnnotatedInterface);
factory.setAddress(endpointUrl);
T serviceProxy = (T) factory.create();
return serviceProxy;
} else {
throw new IllegalArgumentException("Passed in interface class type must be annotated with @WebService " +
"and object reference must be an implementing class of that interface.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment