You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Mickael Goujon <go...@ebi.ac.uk> on 2008/04/01 15:27:27 UTC

JAX-RS: HttpServletRequest resource injection

Hi,

I currently use the JAX-WS WebServiceContext resource injection in my
service bean to be able to access the HttpServletRequest in my SOAP web
services and this works well:

@Resource
private WebServiceContext context;

I now need to implement the same web service as a REST service. CXF
2.1-incubator is great because it includes the JAX-RS frontend, but resource
injection doesn't seem to work. 
Form the 0.6 specs, in section 5.1, I should be able to access the
HttpServletRequest:

"The javax.annotation.Resource annotation can be used to indicate a
dependency on a Servlet-defined resource. An implementation MUST support
injection of the following types: ServletConfig, ServletContext,
HttpServletRequest and HttpServletResponse."

I thought this simple code would be sufficiant, but apparently it isn't:

@Resource
private HttpServletRequest request;

Resource injection is quite new to me, so maybe I'm doing something wrong.
Can somebody help?

Cheers,

Mickael
-- 
View this message in context: http://www.nabble.com/JAX-RS%3A-HttpServletRequest-resource-injection-tp16418423p16418423.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: CXF via https - Client can't send message ( simple frontend java configuration ServerFactoryBean/ClientProxyFactoryBean)

Posted by Daniel Kulp <dk...@apache.org>.
On Tuesday 01 April 2008, Alpin, Luba wrote:
> I need a help with client side.
> In 'apache-cxf-2.0.5-incubator\samples' directory doesn't exist sample
> of using https with configuration of simple frontend. And existing
> sample I can't do working.
> Please help me with working example.
> Regards,
> Luba.

I'm not sure if it works from configuration.   You SHOULD be able to get 
it working from API's though.  

  Client client = ClientProxy.getClient(proxy);
  HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
  TLSClientParameters tlsParams = new TLSClientParameters();
  tlsParams.setSecureSocketProtocol("SSL");
  .....set more TLS things.....
  httpConduit.setTlsClientParameters(tlsParams);



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog

Re: CXF via https - Client can't send message ( simple frontend java configuration ServerFactoryBean/ClientProxyFactoryBean)

Posted by Glen Mazza <gl...@verizon.net>.
I don't know if that is supported (or even if it should be for that
matter).  Being informally defined, the simple front end is not very
secure, and wanting to use HTTPS on top of it is somewhat of a
contradiction.  So if you want to use HTTPS, I think you should learn
the JAXWS front end.  Like learning Ant and Maven, it is time well
spent, and this way you can switch over to Metro or possibly Axis
quickly if you come across a bad bug in CXF.  (The simple frontend isn't
supported anywhere outside of CXF.)

Glen


Am Dienstag, den 01.04.2008, 16:30 +0100 schrieb Alpin, Luba:
> I need a help with client side.
> In 'apache-cxf-2.0.5-incubator\samples' directory doesn't exist sample
> of using https with configuration of simple frontend. And existing
> sample I can't do working.
> Please help me with working example.
> Regards,
> Luba.


CXF via https - Client can't send message ( simple frontend java configuration ServerFactoryBean/ClientProxyFactoryBean)

Posted by "Alpin, Luba" <Lu...@lsi.com>.
I need a help with client side.
In 'apache-cxf-2.0.5-incubator\samples' directory doesn't exist sample
of using https with configuration of simple frontend. And existing
sample I can't do working.
Please help me with working example.
Regards,
Luba.

Re: JAX-RS: HttpServletRequest resource injection

Posted by Sergey Beryozkin <se...@iona.com>.
Hi

We don't support that yet. We do support the injection of @HttpContext fileds, such as UriInfo, HttpHeaders and SecurityContext. Is there any chance you can get what you need from HttpServletRequest from either of those JAX-RS types ?
When I get a chance I'll update the code which deals with @HttpContext fileds to also check for @Resource annotated fields...

Cheers, Sergey



> 
> Hi,
> 
> I currently use the JAX-WS WebServiceContext resource injection in my
> service bean to be able to access the HttpServletRequest in my SOAP web
> services and this works well:
> 
> @Resource
> private WebServiceContext context;
> 
> I now need to implement the same web service as a REST service. CXF
> 2.1-incubator is great because it includes the JAX-RS frontend, but resource
> injection doesn't seem to work. 
> Form the 0.6 specs, in section 5.1, I should be able to access the
> HttpServletRequest:
> 
> "The javax.annotation.Resource annotation can be used to indicate a
> dependency on a Servlet-defined resource. An implementation MUST support
> injection of the following types: ServletConfig, ServletContext,
> HttpServletRequest and HttpServletResponse."
> 
> I thought this simple code would be sufficiant, but apparently it isn't:
> 
> @Resource
> private HttpServletRequest request;
> 
> Resource injection is quite new to me, so maybe I'm doing something wrong.
> Can somebody help?
> 
> Cheers,
> 
> Mickael
> -- 
> View this message in context: http://www.nabble.com/JAX-RS%3A-HttpServletRequest-resource-injection-tp16418423p16418423.html
> Sent from the cxf-user mailing list archive at Nabble.com.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland