Web services 从cxf web服务访问托管bean
公共类LoginCredentials{Web services 从cxf web服务访问托管bean,web-services,jsf-2,cxf,Web Services,Jsf 2,Cxf,公共类LoginCredentials{ @WebService(endpointInterface = "login") public class LoginService{ loginCredentials.login(); } 我不相信你想做的是明智的、最好的设计,甚至是合法的:。你可以从一个从WebServiceContext开始的链访问ServletContext 将对WebServiceContext的引用注入SIB @ManagedProperty(name = "appli
@WebService(endpointInterface = "login")
public class LoginService{
loginCredentials.login();
}
我不相信你想做的是明智的、最好的设计,甚至是合法的:。你可以从一个从WebServiceContext开始的链访问ServletContext 将对WebServiceContext的引用注入SIB
@ManagedProperty(name = "applicationBD", value = "#{applicationBD}")
private IApplication applicationBD; //This class is application scoped
How to access applicationBD in this layer?
//facescontext is null while calling this service from SOAP UI
ServletContext servletContext = (ServletContext)FacesContext.getCurrentInstance().getExternalContext()
.getContext();
servletContext.getAttribute("applicationStartupBD");
}
从WebServiceContext检索MessageContext,它比上一个上下文更接近webservices的SOAP负载处理结构
这是一种推荐的方法吗?不。您已经切换了依赖关系。webapp应该依赖于webservice,而不是相反。在我看来,webapp更容易更改,是堆栈中的第一层。我建议您在这两层之间保持松散耦合
@Resource
WebServiceContext ctxt;
MessageContext msgContext = ctxt.getMessageContext();
ServletContext servletContext = (ServletContext)msgContext.get(MessageContext.SERVLET_CONTEXT);
IApplication app = (IApplication) servletContext.getAttribute("applicationStartupBD"); //You can do whatever you please at this point