I'm using spring and in my client, a web app, I need to interact with a Jax-WS webservice. I currently have it working via annotating the service interface with the @WebServiceRef annotation. However, I need the wsdlLocation property to be injected because, obviously Sun Microsystems or Oracle, the web service wsdl location in production will be different to what's being used during development.
How can I inject the wsdlLocation?
Here's an extremely simplified version of the code:
//This client service lives in the web app. wsimport used to generate artifacts.
@Component
public class MyClientServiceImpl implements MyClientService {
@WebServiceRef(wsdlLocation = "http://localhost:8080/ws/MyOtherService/the.wsdl", value = MyOtherServiceService.class)
//Interface generated by wsimport
private MyOtherService otherService;
@Override
public List<SomeSearchData> search(String searchString) {
return otherService.search(searchString);
}
}
You can use LocalJaxWsPortProxyFactoryBean. You can configure WSDL URL (among other things) via this factory bean. Here is a configuration snippet from the official documentation:
Then you can let Spring autowire this dependency into your target bean (e.g.
MyClientServiceImpl
).This is semi outlined in the JAX-WS FAQ. You need to inject the endpoint string as a standard member variable and then use...