Database Reference
In-Depth Information
You might be rightfully worried now about how your URLs are
going to look when you're building an application in eXist. The /
exist/rest looks awful! Don't worry: you can tune the URLs to your
liking; Chapter 9 explains how to do this.
The database operations are, like in a true REST interface, mapped to the HTTP
request methods GET , PUT , DELETE , and POST . Most often used is GET .
Security
Of course, everything you do through the REST interface is subject to the strict secu‐
rity rules of eXist. For instance, if you're not allowed to see a file (that is, you have no
read permission), it will not show up when you request the contents of the containing
collection in a GET request.
The default identity when you're firing a request through this interface is the limited
guest account. HTTP authentication is supported to change identity (see, for
instance, http://www.httpwatch.com/httpgallery/authentication/ ) .
Even with eXist's strict security in place, allowing REST access on a production server
can be scary: it is a powerful tool with lots of opportunities for misuse or inadvertent
damage. You can turn it off completely, which is probably something you'd want to
do on production servers (unless you really need direct REST access). See “Disabling
direct access to the REST Server” on page 180 for more information.
GET Requests
HTTP GET requests are the workhorses for accessing data and for XQuery scripts.
Using GET requests is probably the most convenient way to execute queries stored in
the database and/or retrieve XML and other contents from it: you can simply do it
from your web browser.
For an HTTP GET request, eXist examines the remainder of the URL (by default the
part after /exist/rest ) and reacts in one of the following ways:
• If a _query URL parameter is present (see the following), it will use this as the
XQuery to execute and will return its result.
• If the remainder of the URL points to a collection, it will return an XML frag‐
ment describing its content. For instance:
<exist:result xmlns:exist= "http://exist.sourceforge.net/NS/exist" >
<exist:collection name= "/db/test"
created= "2012-09-13T08:18:02.35+02:00"
owner= "guest"
group= "guest" permissions= "rwxr-xr-x" >
<exist:resource name= "test.xml"
Search WWH ::




Custom Search