eXist as web application platform?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

eXist as web application platform?

Martynas Jusevicius
Hi all,

I was thinking of building a framework for publishing/consuming REST webservices and I am looking for the best tool to implement it. Since that involves HTTP and XML as core, the tool should handle them both equally well.
My main "suspects" are Java Servlets and XQuery (as a servlet). Since work with XML in Java is pain in the ass compared to XQuery, I would go for XQuery, most probably running on eXist.
But I wonder, how powerfull XQuery in eXist is in dealing with HTTP? Is it able to handle and invoke methods different than GET? How much of Java's HttpServlet/HttpServletRequest/HttpServletResponse functionality does it cover?

Thanks

Martynas
Reply | Threaded
Open this post in threaded view
|

Re: eXist as web application platform?

wolfgangmm
Hi,

> My main "suspects" are Java Servlets and XQuery (as a servlet). Since work
> with XML in Java is pain in the ass compared to XQuery, I would go for
> XQuery, most probably running on eXist.
> But I wonder, how powerfull XQuery in eXist is in dealing with HTTP? Is it
> able to handle and invoke methods different than GET? How much of Java's
> HttpServlet/HttpServletRequest/HttpServletResponse
> functionality does it cover?

eXist already provides a range of different methods to invoke XQueries
via HTTP, e.g. the XQueryServlet, the REST-style API which now
includes the ability to execute stored XQueries through a GET request,
and the XQueryGenerator. The code behind those servlets is rather
small, so if you can't use any of them directly, you should be able to
write your own.

Servlet request, response and session are passed to the XQuery engine.
The function library allows access to most methods and properties
exposed by these objects. Request handling should thus be covered
quite well.

Invoking HTTP methods from within XQuery is not yet supported, though
I thought about adding HTTP client functionality recently. Anyway,
adding your own functions is rather easy through extension modules.

I would say that eXist is well suited if your services rely on data
that needs to be stored persistently on a server. Otherwise, an
in-memory XQuery engine might be a choice as well.

Wolfgang


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: eXist as web application platform?

Martynas Jusevicius
Thanks,

XQueryServlet seems to be what I was looking for.
But eXist's "request" module is just not adequate for normal servlet-like use, if I'm getting everything right.
Why come up with some new functions, when methods of the full HttpServletRequest/HttpServletResponse could be adopted instead?
XQueryServlet could pass the request/response as global parameters, and Java binding could be used to process them.
In fact, there is a very similar-sounding quote in eXist's documentation:

"How do the functions in this module access the HTTP request and session objects? The XQueryServlet and the XQueryGenerator both export a number of global variables to the XQuery script: $request, $response and $session. These variables store the corresponding HTTP objects as passed by the servlet engine (or Cocoon). The functions in the library module just access these variables."

But how do I access these variables? My attempts failed. Or am I missing something again? :/

Martynas

On 10/10/05, Wolfgang Meier < [hidden email]> wrote:
Hi,

> My main "suspects" are Java Servlets and XQuery (as a servlet). Since work
> with XML in Java is pain in the ass compared to XQuery, I would go for
> XQuery, most probably running on eXist.
> But I wonder, how powerfull XQuery in eXist is in dealing with HTTP? Is it
> able to handle and invoke methods different than GET? How much of Java's
> HttpServlet/HttpServletRequest/HttpServletResponse
> functionality does it cover?

eXist already provides a range of different methods to invoke XQueries
via HTTP, e.g. the XQueryServlet, the REST-style API which now
includes the ability to execute stored XQueries through a GET request,
and the XQueryGenerator. The code behind those servlets is rather
small, so if you can't use any of them directly, you should be able to
write your own.

Servlet request, response and session are passed to the XQuery engine.
The function library allows access to most methods and properties
exposed by these objects. Request handling should thus be covered
quite well.

Invoking HTTP methods from within XQuery is not yet supported, though
I thought about adding HTTP client functionality recently. Anyway,
adding your own functions is rather easy through extension modules.

I would say that eXist is well suited if your services rely on data
that needs to be stored persistently on a server. Otherwise, an
in-memory XQuery engine might be a choice as well.

Wolfgang
Reply | Threaded
Open this post in threaded view
|

Re: eXist as web application platform?

Martynas Jusevicius
In reply to this post by wolfgangmm
Thanks,

XQueryServlet seems to be what I was looking for.
But eXist's "request" module is just not adequate for normal
servlet-like use, if I'm getting everything right.
Why come up with some new functions, when methods of the full
HttpServletRequest/HttpServletResponse could be adopted instead?
XQueryServlet could pass the request/response as some global
variables, and Java binding could be used to process them.
In fact, there is a very similar-sounding quote in eXist's documentation:

"How do the functions in this module access the HTTP request and
session objects? The XQueryServlet and the XQueryGenerator both export
a number of global variables to the XQuery script: $request, $response
and $session. These variables store the corresponding HTTP objects as
passed by the servlet engine (or Cocoon). The functions in the library
module just access these variables."

But how do I access these variables? My attempts failed. Or am I
missing something again? :/

Martynas

On 10/10/05, Wolfgang Meier < [hidden email]> wrote:

> Hi,
>
> > My main "suspects" are Java Servlets and XQuery (as a servlet). Since work
> > with XML in Java is pain in the ass compared to XQuery, I would go for
> > XQuery, most probably running on eXist.
> > But I wonder, how powerfull XQuery in eXist is in dealing with HTTP? Is it
> > able to handle and invoke methods different than GET? How much of Java's
> > HttpServlet/HttpServletRequest/HttpServletResponse
> > functionality does it cover?
>
> eXist already provides a range of different methods to invoke XQueries
> via HTTP, e.g. the XQueryServlet, the REST-style API which now
> includes the ability to execute stored XQueries through a GET request,
> and the XQueryGenerator. The code behind those servlets is rather
> small, so if you can't use any of them directly, you should be able to
>  write your own.
>
> Servlet request, response and session are passed to the XQuery engine.
> The function library allows access to most methods and properties
> exposed by these objects. Request handling should thus be covered
> quite well.
>
> Invoking HTTP methods from within XQuery is not yet supported, though
> I thought about adding HTTP client functionality recently. Anyway,
> adding your own functions is rather easy through extension modules.
>
> I would say that eXist is well suited if your services rely on data
> that needs to be stored persistently on a server. Otherwise, an
> in-memory XQuery engine might be a choice as well.
>
> Wolfgang


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: eXist as web application platform?

Adam Retter-7
In reply to this post by Martynas Jusevicius
I dont think eXist is meant to be a Java Servlet, what you are looking
to do is use XQuery which is what exist provides.

I would suggest that if you need full access to HttpServletRequest then
you could either develop the appropriate XQuery functions (see below) or
you could develop your own Java Servlet that makes calls to eXist to
process XQuery through it's Java API.

I recently implemented request:get-session-id() so I could also probably
implement get-headers(), get-method() and get-locale() if there was
enough interest?




On Fri, 2005-10-14 at 09:31 +0100, Martynas Jusevicius wrote:

> But there is just not enough of request functions! How about
> get-headers(), get-method(), get-locale() etc.?
> I understand how the request module works, but I don't think it is a
> convenient way. IMHO, eXist should mimick Java Servlets as much as
> possible here.
> If there would be direct access to somehow predefined $request, then
> there would be no need for the request module at all and Java binding
> could be used instead, like this:
>
> declare namespace
> request="java:javax.servlet.http.HttpServletRequest";
>
> <p>
> Request Method: { request:get-method($request) }
> </p>
>
> or smth like that. Am I not right? Documentation says "Instance
> methods are called by supplying a valid Java object as first
> parameter".
> Can I achieve this writing my own module?
> I would really like to start using XQuery on the web, but I just
> can't
> grasp it enough.
>
>
> On 10/14/05, Adam Retter <[hidden email]> wrote:
> > You dont access $session, $request and $response directly from
> XQuery,
> > you access the XQuery functions in request namespace etc. and those
> > functions written in Java manipulate $session, $request and
> $response.
> >
> > You can write your own functions in Java that can be called from
> XQuery,
> > either by extending one of the existing namespaces with further
> > functions (if appropriate) or you can write your own module which
> has
> > its own namespace and contains your functions.
>


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: eXist as web application platform?

wolfgangmm
In reply to this post by Martynas Jusevicius
Hi,

> Why come up with some new functions, when methods of the full
> HttpServletRequest/HttpServletResponse could be adopted instead?
> XQueryServlet could pass the request/response as some global
> variables, and Java binding could be used to process them.

That's correct, though using the Java binding requires some experience
with Java, which you cannot expect from all users.

> But how do I access these variables? My attempts failed. Or am I
> missing something again? :/

Contrary to the documentation, the variables are now declared within
the module namespace. The variables are thus called: $request:request,
$request:response and $request:session. Please note that, in order to
account for differences between normal servlets and Cocoon, these
objects are wrappers around HttpServletRequest. Check
org.exist.http.servlets.RequestWrapper, ResponseWrapper and
SessionWrapper.

Wolfgang


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open