Hi I have got the webservice up and running , i have used jax ws. I have used Spring to be able to use beans with Autowired and stuff that spring gives like property value i
It is answered here. Ultimately nothing worked other than adding below code to service impl.
@PostConstruct
public void init() {
SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
}
Your TestService (which is annotated with @WebService) should extend "SpringBeanAutowiringSupport" class to kick start spring binding.
Please have a look at the duffmo mentioned points as well.
I think it's more likely that your Spring context has not be loaded and made available to the web service. How have you done that?
You should have a ContextLoaderListener
configured in the web.xml
for the WAR in which the web service is deployed. Did you tell it where to load the Spring context? Are you using component scan?
http://renidev.wordpress.com/2009/02/02/how-to-use-springs-context-component-scan-and-annotation/
No Need to use ApplicationContext as well, if you do the following things
Please have a look at the following snippet.
@org.springframework.stereotype.Service
@javax.jws.WebService (endpointInterface="a.b.c.MyPort",
targetNamespace="http://a.b.co.in/Retail/MyService/V1",
serviceName="MyService",
portName="MyServicePort",
wsdlLocation="wsdl/MyService.wsdl")
public class MyServiceBindingImpl extends org.springframework.web.context.support.SpringBeanAutowiringSupport{
I got the same issue, to resolve it I started the jaxws listener after the spring listener:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
Hope it helps
You misses the configuration for webservice inject. So put more inside the web.xml
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
Please don't forget the order. Because you need to init the bean for the autowired field first
Thanks