Ok, so here's something I've been googling for for hours with no success... Finally i can only hope some Spring-magician reads and answers this question. :)
I'm upgrading an old web application (Spring 2.x-based) to Spring 4.2.x and while adding new features I've decided to completely move away from XML-based config. (Again: i don't want to have any Spring XML files in the project!)
I've converted pretty much everything, but the last thing i can't resolve is finding the correct Java-config counterpart of:
<ws:service id="MySoapService" bean="#ServiceImpl" />
<wss:binding service="#MySoapService" url="/1.0/soap" />
ws/wss namespaces come from:
xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
So what i'm trying to do is exporting @WebService
annotated classes, but with Java-config instead of XML.
Additional infos:
I've tried using SimpleJaxWsServiceExporter
, but that one leaves me with a "java.net.BindException: Address already in use: bind", regardless of what port i'm using...
The application has two servlets: one is a normal Spring MVC Dispatcher for the new REST API and another com.sun.xml.ws.transport.http.servlet.WSSpringServlet
which should make the above mentioned JAX-WS service available.
I'm trying to resolve things with pure JAX-WS RI, no CXF or any other library. The application is huge enough already... :(
You can achieve this by injecting your endpoint and the following helper method (note that my approach uses a base class BaseEndpoint
for each endpoint):
@Configuration
public WebserviceConfiguration {
@Inject
private FooEndpoint fooEndpoint;
@Bean
public SpringBinding fooEndpoint() throws Exception {
return bind(fooEndpoint, "ws/bar");
}
private SpringBinding bind(BaseEndpoint endpoint, String url) throws Exception {
SpringService springService = new SpringService();
springService.setBean(endpoint);
SpringBinding binding = new SpringBinding();
binding.setService(springService.getObject());
binding.setUrl(url);
return binding;
}
}