Hi all,
As far as I've been able to trace, it looks like the
WebServiceContextImpl threadlocal is only set for regular web
services, not for services implemented using jaxrs. Is that on purpose
or might it be added in a future version?
This is what I'm trying to do. I have a service:
@Path("/surveyservice/1.0")
@ProduceMime("application/xml")
public class SurveyWebServiceImpl ...
...
private WebServiceContext context;
@Resource
public void setContext(WebServiceContext context) {
this.context = context;
}
and then later in a service method I'm trying to get the servlet request:
HttpServletRequest request =
(HttpServletRequest)context.getMessageContext().get(MessageContext.SERVLET_REQUEST);
The service is configured using Spring:
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-jaxws.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<bean id="surveyWebService"
class="ts4.component.survey.ws.v1_0.SurveyWebServiceImpl"
autowire="autodetect"></bean>
<jaxrs:server id="surveyWebServiceRs" address="/">
<jaxrs:serviceBeans>
<ref bean="surveyWebService" />
</jaxrs:serviceBeans>
</jaxrs:server>
And I have the CXFServlet configured etc.
The injection of the context works fine, but as the thread local in
the WebServiceContextImpl (the only implementation of the
WebServiceContext interface I could find) is never set for services
over REST, the context object is quite useless :-)
Is there another way to get the HttpServletRequest (or HttpSession, as
that's what I'm really after)?
Also, I thought the @HttpSessionScope and @Stateful annotations as
described here:
http://weblogs.java.net/blog/ramapulavarthi/archive/2007/02/useful_goodies.html
are an elegant solution for what I'm trying to do (implementing
conversational web services). Does anyone here know what the status is
on that, particularly in CXF?
Cheers,
Eelco