[jboss-dev-forums] [JBoss AS 7 Development] - How to access the request in a JAXWS webservice (JBoss 7.1.1) ?
Michaël Leneveut
do-not-reply at jboss.com
Fri Aug 24 09:12:52 EDT 2012
Michaël Leneveut [https://community.jboss.org/people/mleneveut] created the discussion
"How to access the request in a JAXWS webservice (JBoss 7.1.1) ?"
To view the discussion, visit: https://community.jboss.org/message/755785#755785
--------------------------------------------------------------
Hi all,
I have a working WS on JBoss 7.1.1, using JAX-WS. But when I try to use a javax.xml.ws.WebServiceContext, the messageContext in it is null. It has not been injected by JBoss.
How to access the request in a webservice ?
> public class CommonWSActivityBean extends BaseFrameworkObject {
> @Resource
> private WebServiceContext context;
>
> @PostConstruct
> @WebMethod(exclude = true)
> public void init() throws RemoteException {
> MessageContext messageContext = context.getMessageContext(); //IllegalStateException thrown
> HttpServletRequest request = (HttpServletRequest) messageContext.get(MessageContext.SERVLET_REQUEST);
The error :
> > java.lang.IllegalStateException
> > at org.jboss.ws.common.injection.ThreadLocalAwareWebServiceContext.getWebServiceContext(ThreadLocalAwareWebServiceContext.java:88)
> > at org.jboss.ws.common.injection.ThreadLocalAwareWebServiceContext.getMessageContext(ThreadLocalAwareWebServiceContext.java:69)
> > at fr.xxx.fwmc.arch.isolation.wsserver.bean.CommonWSActivityBean.init(CommonWSActivityBean.java:88)
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
The Webservice :
> @WebService(name = "RechercheClient", targetNamespace = " http://ws.rechercheclient.xxx.fr/ http://ws.rechercheclient.xxx.fr/")
> @SOAPBinding(style = Style.DOCUMENT, use = Use.LITERAL, parameterStyle = ParameterStyle.WRAPPED)
> public class RechercheClient extends CommonWSActivityBean {
> @WebMethod(action = "rechercher")
> @WebResult(name = "listeClientsWS")
> @RequestWrapper(localName = "rechercher", targetNamespace = " http://ws.rechercheclient.xxx.fr/ http://ws.rechercheclient.xxx.fr/", className = "fr.xxx.rechercheclient.ws.jaxws.Rechercher")
> @ResponseWrapper(localName = "rechercherResponse", targetNamespace = " http://ws.rechercheclient.xxx.fr/ http://ws.rechercheclient.xxx.fr/", className = "fr.xxx.rechercheclient.ws.jaxws.RechercherResponse")
> public ClientWSDataBean[] rechercher(@WebParam(name = "clientWSParametre")
> ClientWSParametreDataBean parametre) throws WSException {
> return RechercheClientHelper.doRecherche(parametre, this.getUserContext());
> }
Thanks for your help.
PS : I tried to set the @Resource on the setter, to remove the "private". The standalone.xml has the "org.jboss.as.webservices" module.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/755785#755785]
Start a new discussion in JBoss AS 7 Development at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20120824/7ce53176/attachment.html
More information about the jboss-dev-forums
mailing list