Changes

Jump to navigation Jump to search
1,070 bytes removed ,  11:22, 22 October 2018
no edit summary
This page is part of the [[Getting Started]] Section. It describes how BaseX can be used to both provide simple APIs and build complex web applications. The following three HTTP services are availableprovided:
* [[REST]] offers a straightforward RESTful API for accessing database resources via URLs,{| class="wikitable" |- valign="top"! Name! Standard Path! Description|- valign="top"* | [[RESTXQ]] allows you to write more complex | <code>/</code>| Write enriched APIs and full web applications with XQuery, .|- valign="top"| [[WebSockets]]| <code>ws/</code>| Bidirectional client/server communication.|- valign="top"| [[REST]]| <code>rest/</code>| Straightforward access to XML databases andits resources.* |- valign="top"| [[WebDAV]] gives | <code>webdav/</code>| Database access to databases via the file system.|- valign="top"| Default| <code>static/</code>| Access to static server resources (HTML, JavaScript, CSS, images, …).|}
==Deployment== This article describes different ways of deploying and configuring these services. The services BaseX can be deployed as follows:
* as standalone application, by running the [[Startup#HTTP Server|BaseX HTTP Server]],
* as web servlet in a [[#Servlet Container|Servlet Container]], and
* as web servlet, using [[#Maven|Maven]].
 
Authentication:
 
* If a user is defined in the <code>web.xml</code> file via the key <code>org.basex.user</code>, no password must be specified.
* If the <code>admin</code> user is specified for an API, all features will be available without restriction.
* Predefined authentication methods and default users cannot be overwritten by client.
<br/>
=Servlet Container=
==Configuration==
All Initial database options can be specified in the {{Code|web.xml}} file. They need to be defined as context parameters and prefixed with {{Code|org.basex.}}. The most important options for the web application context are as follows:
{| class="wikitable"
|}
Path Local file paths in options may contain an be absolute or relative path. If a relative path is specified, its root will be the servlet ({{Code|webapp}}) path:
<pre class="brush:xml">
<context-param> <param-name>org.basex.dbpath</param-name> <!-- will be rewritten to ..../webapp/WEB-INF/data --> <param-value>WEB-INF/data</param-value> </context-param> <context-param> <param-name>org.basex.repopath</param-name> <!-- will be kept as is --> <param-value>f:/basex/repository</param-value> </context-param>
</pre>
Context parameters can be requested from XQuery via [[Process_Module#proc:property-names|proc:property-names]] and [[Process_Module#proc:property|proc:property]]. How to set these options is specific to the servlet container. For example, in Jetty it can be done by [http://www.eclipse.org/jetty/documentation/current/override-web-xml.html overriding the web.xml] file. Another option is to directly edit the {{Code|WEB-INF/web.xml}} file in the WAR archive (WAR files are simple ZIP files). Refer to the sample [https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/webapp/WEB-INF/web.xml web.xml] of the basex-api package.
To enable or disable a specific service, the corresponding servlet entry in the {{Code|web.xml}} file needs to be removed/commented. ==Authentication== Different credentials can be assigned to the REST and WebDAV a service by specifying local init parameters. In the following example, an alternative user is specified for the REST service:
<pre class="brush:xml">
<servlet> <servlet-name>REST</servlet-name> <servlet-class>org.basex.http.rest.RESTServlet</servlet-class> <init-param> <param-name>org.basex.user</param-name> <param-value>rest-user</param-value> </init-param> </servlet>
</pre>
==Available Services==If the HTTP server is started with no pre-defined user, the credentials must be passed on by the client via [http://en.wikipedia.org/wiki/Basic_access_authentication Basic Authentication] or [http://en.wikipedia.org/wiki/Digest_authentication Digest Authentication] (depending on the server setting).
To enable or disable one of With cURL, internet browsers, and other tools, you can specify basic authentication credentials within the provided servicesrequest string as plain text, using the corresponding servlet entry in the {{Code|web.xml}} file needs to be removedformat <code>USER:PASSWORD@URL</commentedcode>. The default URL paths are listed in the following tableAn example:
{| class="wikitable" |- valign="top"! Service! URL! Usage|- valign="top"| Default web server| {{Code|: <code>http://[host]admin:admin@localhost:[port]8984/[servlet_context_path]</static}}code>| Access your standard web files (e.g. HTML, JavaScript or CSS).|- valign="top"| [[RESTXQ]]| Users are specified in a {{Code|http://[host]:[port]/[servlet_context_path]}}| Create XQuery web services and applicationsusers.|- valign="top"| [[REST]]| {{Code|http://[host]:[port]/[servlet_context_path]/restxml}}| Access XML file, which is stored in the database and its resources.|- valign="top"| [[WebDAV]]| {{Code|http://directory (see [host]:[portUser Management]/[servlet_context_path]/webdav}} or<br/>{{Code|webdav://[host]:[port]/[servlet_context_path]/webdav}} (depending on clientfor more information)| Access databases via the filesystem.|}
=Maven=
The same options as in the case of deployment apply in a servlet container. In this case, however, there is no WAR archive. Instead, Jetty looks up all files in the directory <code>[https://github.com/BaseXdb/basex/tree/master/basex-api/src/main/webapp basex-api/src/main/webapp]</code>. Jetty and servlet options can be configured in the {{Code|jetty.xml}} and {{Code|web.xml}} files as described above in the [[#Configuration|Servlet Container Configuration]]. The Jetty stop port can be changed in the [http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin Maven Jetty Plugin] sesion in the {{Code|pom.xml}} file.
=User ManagementChangelog=
By default, RESTXQ uses the admin user, whereas the REST and WebDAV services require client-side authentication;Version 9.0A default user can be specified via [[Command-Line Options#BaseX HTTP Server|command-line arguments]]. In the * Updated: <code>webjetty.xml</code> configuration file, both a global and a servlet-specific user can be added (see above). If the HTTP server is started with no pre-defined user, the credentials must be passed on by the client via [http://en.wikipedia.org/wiki/Basic_access_authentication Basic Authentication] or [http://en.wikipedia.org/wiki/Digest_authentication Digest Authentication] (depending on the server setting). With cURL, internet browsers, and other tools, you can specify basic authentication credentials within the request string as plain text, using the format <code>USER:PASSWORD@URL</code>. An example: : <code>http://admin:admin@localhost:8984/</code> Users are specified in a {{Code|users.xml}} file, which is stored in the database directory (see [[User Management]] required for more informationJetty 9). =Changelog=
;Version 8.6
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu