Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Resource
- private WebServiceContext context;
- ServletContext servletContext =
- (ServletContext) context.getMessageContext().get(MessageContext.SERVLET_CONTEXT);
- import javax.annotation.Resource;
- import javax.jws.WebService;
- import javax.servlet.ServletContext;
- import javax.xml.ws.WebServiceContext;
- import javax.xml.ws.handler.MessageContext;
- import org.springframework.web.context.WebApplicationContext;
- import org.springframework.web.context.support.WebApplicationContextUtils;
- @WebService
- public class MyWebService {
- // boilerplate code begins :(
- @Resource
- private WebServiceContext context;
- private WebApplicationContext webApplicationContext = null;
- /**
- * @return
- * @throws IllegalStateException
- */
- private WebApplicationContext getWebApplicationContext()
- throws IllegalStateException {
- if (webApplicationContext != null)
- return webApplicationContext;
- ServletContext servletContext =
- (ServletContext) context.getMessageContext().get(
- MessageContext.SERVLET_CONTEXT);
- webApplicationContext =
- WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
- return webApplicationContext;
- }
- }
Add Comment
Please, Sign In to add comment