Changes

Jump to navigation Jump to search
1,992 bytes added ,  15:46, 12 November 2019
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.  =Startup= * Run one of the {{Code|basexhttp}} or {{Code|basexhttp.bat}} scripts. Call the script with the {{Code|stop}} keyword to gracefully shut down the server.* If you have installed BaseX on ''Windows'', click on the '''BaseX HTTP Server (Start)''' icon. Various [[Command-Line_Options#HTTP Server|command-line options]] are available to simplify batch processing. The [[Start_Scripts|start script]] can be adjusted for individual purposes (e.g. if the default memory limit is too restrictive). An instance of the [https://www.eclipse.org/jetty/ Jetty Web Server] will be started, which by default listens to the port {{Code|8984}}. Additionally, the BaseX [[Database Server]] will be started, accessible on port {{Code|1984}}. The command-line output will look something like that (the JSP warning message [http://stackoverflow.com/questions/3521654/missing-jsp-support-in-jetty-or-confusing-log-message can be ignored]): <pre class="brush:xml">BaseX [HTTP Server][main] INFO org.eclipse.jetty.util.log - Logging initialized @375ms to org.eclipse.jetty.util.log.Slf4jLog[main] INFO org.eclipse.jetty.server.Server - jetty-9.4.21.v20190926; built: 2019-09-26T16:41:09.154Z; git: 72970db61a2904371e1218a95a3bef5d79788c33; jvm 13+33[main] INFO org.eclipse.jetty.webapp.StandardDescriptorProcessor - NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet...Server was started (port: 1984).HTTP Server was started (port: 8984).HTTP STOP Server was started (port: 8985).</pre> After startup, you can access an HTML welcome page via http://localhost:8984. The Jetty logging level can be adjusted by adding the following properties to the start script: <pre class="brush:xml">-Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog -D{classref}.LEVEL=DEBUG</pre> BaseX can also be deployed as web servlet in a servlet container or with Maven: ==Servlet Container== In order to deploy BaseX HTTP Services in a servlet container, you can download the WAR distribution of BaseX from the [http://basex.org/download download site], or compile it by calling <code>mvn compile war:war</code> in the <code>basex-api</code> directory. The WAR file can then be deployed following the instructions of the corresponding servlet container ([http://www.eclipse.org/jetty/documentation/current/quickstart-deploying-webapps.html jetty], [http://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html tomcat], etc.). You can configure the port, context path, etc. by following the instructions of the corresponding servlet container. This is needed if you want to replace the default URL path (e.g. http://localhost:8080/rest) with a custom one (e.g. http://localhost:8984/basex/rest). If you use Jetty (which is the default HTTP server of BaseX), the server configuration is available via the {{Code|jetty.xml}} file, which is stored in the {{Code|WEB-INF}} directory next to the {{Code|web.xml}}. For detailed configuration refer to the [http://www.eclipse.org/jetty/documentation/current/jetty-xml-config.html Jetty Documentation]. To run on [http://tomcat.apache.org/ Apache Tomcat], start the Tomcat server and add any <code>*.war</code> distribution to deploy via the Tomcat web interface. By default, the interface is accessible via http://localhost:8080/manager/html/. ==Maven== Check out the BaseX sources via [[Developing with Eclipse|Eclipse]] or [[Git]]. Execute <code>mvn install</code> in the main project directory and then <code>mvn install jetty:run</code> in the <code>basex-api</code> sub-directory. This will start a Jetty instance in which the servlets will be deployed. 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. =Services= The following services are providedavailable and enabled by default:
{| class="wikitable"
|- valign="top"
! Name
! Standard Path
! Description
|- valign="top"
|- valign="top"
| [[WebSockets]]
| <code>ws/ws</code>
| Bidirectional client/server communication.
|- valign="top"
| [[REST]]
| <code>rest/rest</code>
| Straightforward access to XML databases and its resources.
|- valign="top"
| [[WebDAV]]
| <code>webdav/rest</code>
| Database access via the file system.
|- valign="top"
| Default
| <code>static/static</code>
| Access to static server resources (HTML, JavaScript, CSS, images, …).
|}
==Deployment==The [[DBA]] is a web-based database administration interface written in RESTXQ. It allows you to create and administrate databases, evaluate queries in realtime, view log files, manage users, etc. It is embedded in the full distributions of BaseX, and it can be accessed after startup via http://localhost:8984/dba/.
This article describes different ways of deploying and configuring these services. BaseX can be deployed as follows:=Configuration=
* Unless BaseX is deployed as standalone applicationservlet, by running the [[Startup#HTTP Server|BaseX HTTP Server]],* as location of the web servlet in a [[#Servlet Containerapplication directory can be adjusted via the {{Option|Servlet Container]]WEBPATH}} option, and* as web servlet, using [[#Mavencompression of HTTP responses can be enabled via the {{Option|Maven]]GZIP}} option.
=Servlet Container= In order to deploy BaseX HTTP Services in a servlet container, you can download the WAR distribution of BaseX from the [http://basex.org/download download site], or compile it by calling <code>mvn compile war:war</code> in the <code>basex-api</code> directory. The WAR file can then be deployed following the instructions of the corresponding servlet container ([http://www.eclipse.org/jetty/documentation/current/quickstart-deploying-webapps.html jetty], [http://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html tomcat], etc.). You can configure the port, context path, etc. by following the instructions of the corresponding servlet container. This is needed if you want to replace the default URL path (e.g. http://localhost:8080/rest) with a custom one (e.g. http://localhost:8984/basex/rest). If you use Jetty (which is the default HTTP server of BaseX), the server configuration is available via the {{Code|jetty.xml}} file, which is stored in the {{Code|WEB-INF}} directory next to the {{Code|web.xml}}. For detailed configuration refer to the [http://www.eclipse.org/jetty/documentation/current/jetty-xml-config.html Jetty Documentation]. To run on [http://tomcat.apache.org/ Apache Tomcat], start the Tomcat server and add any <code>*.war</code> distribution to deploy via the Tomcat web interface. By default, the interface is accessible via http://localhost:8080/manager/html/. ==Configuration== Initial Further database options can be specified defined as context parameters 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"
! Description
|-
|<code>[[Options#USER{{Option|USER]]</code>}}
|{{Code|admin}}
| If a user is specified, no credentials must be passed on by the client.
|-
|<code>[[Options#HTTPLOCAL{{Option|HTTPLOCAL]]</code>}}
|{{Code|false}}
|Operation mode. By default, a database server instance will be started, as soon as the first HTTP service is called. The database server can be disabled by setting this flag to {{Code|true}}.
|-
|<code>[[Options#RESTXQPATH{{Option|RESTXQPATH]]</code>}}
|{{Code|.}}
|Relative or absolute directory referencing the [[RESTXQ]] modules. By default, the option points to the standard web application directory.
|-
|<code>[[Options#RESTPATH{{Option|RESTPATH]]</code>}}
|{{Code|.}}
|Relative or absolute directory referencing queries and command-scripts that can be invoked via the [[REST#GET_Requests|run operation]] of REST. By default, the option points to the standard web application directory.
|-
|<code>[[Options#AUTHMETHOD{{Option|AUTHMETHOD]]</code>}}
|{{Code|Basic}}
|The default authentication method proposed by the server. The available methods are {{Code|Basic}} and {{Code|Digest}}.
|}
All options are prefixed with {{Code|org.basex.}}. Local file paths in options may be absolute or relative. If a relative path is specified, its root will be the servlet servlet’s ({{Code|webapp}}) path:
<pre class="brush:xml">
Users are specified in a {{Code|users.xml}} file, which is stored in the database directory (see [[User Management]] for more information).
 
=Maven=
 
Check out the BaseX sources via [[Developing with Eclipse|Eclipse]] or [[Git]]. Execute <code>mvn install</code> in the main project directory and then <code>mvn install jetty:run</code> in the <code>basex-api</code> sub-directory. This will start a Jetty instance in which the servlets will be deployed.
 
==Configuration==
 
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.
=Changelog=
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu