You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Phil Wilson <p....@bath.ac.uk> on 2007/03/09 18:45:28 UTC

REST service inside Servlet

Hi,

I've been writing a REST-basd service based on the cxf-rest sample, and it all works just 
fine.

I want to start authenticating this service and for my needs the best way seems to be by 
using HTTP Digest (which then authenticates against an LDAP realm).

I'm guessing the best way, since Jetty already appears to be in use, to do this is to 
embed my services inside a servlet and rely on the container's native Digest and realm 
support, but I don't see how to do it. I've looked at the CXFServlet code and samples and 
don't immediately see how these could be configured for my needs.

Am I going about this the right way? If so, what should I be doing to get things running 
how I want?

Any help welcomed,

Phil Wilson

Re: REST service inside Servlet

Posted by Phil Wilson <p....@bath.ac.uk>.
Sorry about the delay in replying, just been thinking it over.

> Re: wrapping - did you see the documentation I wrote at the bottom of the
> document here - http://cwiki.apache.org/CXF20DOC/http-binding.html ?

Yes.

> Can you rephrase your second question? I don't understand what you're
> asking.  :-\

If your HelloWorld example did not use the convenience Server.java and returned a Hello 
object (containing a single, String property with a pre-set value), which responded to a 
simple GET, where would I configure wrapping to be on or off?

Or if the HelloWorld example returned a JSON serialisation in response to a simple GET 
with no parameters, where would I map the namespace?

> We have one servlet for both SOAP & REST based services.

OK, that was what I thought, thanks.

> (sorry for the lag btw)

Ditto,

Cheers,

Phil

Re: REST service inside Servlet

Posted by Dan Diephouse <da...@envoisolutions.com>.
Hi Phil,

On 3/15/07, Phil Wilson <p....@bath.ac.uk> wrote:
>
> Hi Dan,
>
> Sorry, I phrased my question badly. I don't know if this one will be much
> better ;)
>
> I'm unclear on a couple of points:
>
> * whether using CXFServlet means I can embed in a separate container
> rather than the
> bundled Jetty (I think yes)


Yes, definitely!

* how the REST endpoints get configured i.e. where things like
> .setWrapped(false)  and
> configuring the JSON namespace mapping happen if the endpoints are being
> exposed directly
> via the implementing class using either XML or using Endpoint.create()


Re: wrapping - did you see the documentation I wrote at the bottom of the
document here - http://cwiki.apache.org/CXF20DOC/http-binding.html ?

Can you rephrase your second question? I don't understand what you're
asking.  :-\

I know how to authenticate URL resources using normal Jetty. I just don't
> quite understand
> how to publish my REST services inside a servlet.
>
> I have read http://cwiki.apache.org/CXF20DOC/servlet-transport.html and
> looked at the
> samples, but they didn't really clear anything up for me. All of the
> servlet examples
> appear to be SOAP-based services and non-portable to REST-based services
> as far as I can see.


We have one servlet for both SOAP & REST based services.

I just checked in an example to SVN which shows how use CXF with the
servlet, maybe that will help?

http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/spring_http/

I don't think we have published a new snapshot yet with it in it, but I will
see if I can get one pushed out myself in the next 24 hours.

(sorry for the lag btw)

- Dan

-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog

Re: REST service inside Servlet

Posted by Phil Wilson <p....@bath.ac.uk>.
Hi Dan,

Sorry, I phrased my question badly. I don't know if this one will be much better ;)

I'm unclear on a couple of points:

* whether using CXFServlet means I can embed in a separate container rather than the 
bundled Jetty (I think yes)

* how the REST endpoints get configured i.e. where things like .setWrapped(false)  and 
configuring the JSON namespace mapping happen if the endpoints are being exposed directly 
via the implementing class using either XML or using Endpoint.create()

I know how to authenticate URL resources using normal Jetty. I just don't quite understand 
how to publish my REST services inside a servlet.

I have read http://cwiki.apache.org/CXF20DOC/servlet-transport.html and looked at the 
samples, but they didn't really clear anything up for me. All of the servlet examples 
appear to be SOAP-based services and non-portable to REST-based services as far as I can see.

Cheers,

Phil

Dan Diephouse wrote:
> Hi Phil,
> 
> I am not sure how to configure the Jetty transport to use authentication,
> but if you use the servlet transport it is a matter of configuring your
> servlet container. I would recommend that you look at your servlet
> container's documentation for guidance on how to do this. For example:
> http://docs.codehaus.org/display/JETTY/Realms
> 
> Regards,
> - Dan
> 
> On 3/9/07, Phil Wilson <p....@bath.ac.uk> wrote:
>>
>> Hi,
>>
>> I've been writing a REST-basd service based on the cxf-rest sample, 
>> and it
>> all works just
>> fine.
>>
>> I want to start authenticating this service and for my needs the best way
>> seems to be by
>> using HTTP Digest (which then authenticates against an LDAP realm).
>>
>> I'm guessing the best way, since Jetty already appears to be in use, 
>> to do
>> this is to
>> embed my services inside a servlet and rely on the container's native
>> Digest and realm
>> support, but I don't see how to do it. I've looked at the CXFServlet code
>> and samples and
>> don't immediately see how these could be configured for my needs.
>>
>> Am I going about this the right way? If so, what should I be doing to get
>> things running
>> how I want?
>>
>> Any help welcomed,
>>
>> Phil Wilson
>>
> 
> 
> 


Re: REST service inside Servlet

Posted by Dan Diephouse <da...@envoisolutions.com>.
Hi Phil,

I am not sure how to configure the Jetty transport to use authentication,
but if you use the servlet transport it is a matter of configuring your
servlet container. I would recommend that you look at your servlet
container's documentation for guidance on how to do this. For example:
http://docs.codehaus.org/display/JETTY/Realms

Regards,
- Dan

On 3/9/07, Phil Wilson <p....@bath.ac.uk> wrote:
>
> Hi,
>
> I've been writing a REST-basd service based on the cxf-rest sample, and it
> all works just
> fine.
>
> I want to start authenticating this service and for my needs the best way
> seems to be by
> using HTTP Digest (which then authenticates against an LDAP realm).
>
> I'm guessing the best way, since Jetty already appears to be in use, to do
> this is to
> embed my services inside a servlet and rely on the container's native
> Digest and realm
> support, but I don't see how to do it. I've looked at the CXFServlet code
> and samples and
> don't immediately see how these could be configured for my needs.
>
> Am I going about this the right way? If so, what should I be doing to get
> things running
> how I want?
>
> Any help welcomed,
>
> Phil Wilson
>



-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog