2 Replies Latest reply on Aug 27, 2012 3:43 AM by mleneveut

    How to access the request in a JAXWS webservice (JBoss 7.1.1) ?

    mleneveut

      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/")

      @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/", className = "fr.xxx.rechercheclient.ws.jaxws.Rechercher")

          @ResponseWrapper(localName = "rechercherResponse", targetNamespace = "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.