RESTXQ path resolution
Monday, 13 July 2020 · 4 messages · last reply 31 Jul 2020
BP
Ben Pracht13 Jul 2020 02:31 #
Hi,
I'm trying to resolve a 404 with a RESTXQ service, and got to wondering if it's possible to show the directories it's looking for things, ideally fully qualified paths. Is it possible to turn on logging so much that it shows all the XQ files it found, then show the ones it actually matched?
In my case, I put the hello-world service in the main project directory, in the modules directory where the
RESTXQPATH and in the RESTPATH. I've tried renaming the hello-world to .xq, .xqm and .xqy. In all cases, it does not find the .xq file.
Best Regards,
Ben Pracht
919.809.2439
ben.pracht at gmail.comMS
Michael Seiferle13 Jul 2020 09:35 #
Hi Ben,
Make sure to first read my previous mail, because you need a working restxq-Setup ;-)
Theres the „
rest:wadl()“ function, that generates a representation of all available endpoints.
I added it to my example project, feel free to check it out here:Quoted text · Ben Pracht · 1 line
> https://git.basex.io/basex-public/mailinglist-autocomplete/-/commit/84fda246ca3d1dfe7319ff4a401aa1504feee48a
The result will look something like this:
[…]
<wadl:resource path="/search/{$what}">
<wadl:param name="what" style="template"/>
<wadl:method name="GET">
<wadl:request/>
<wadl:response>
<wadl:representation mediaType="application/json"/>
</wadl:response>
</wadl:method>
</wadl:resource>
[…]Hope this helps :-)
Michael
Quoted text · Ben Pracht · 9 lines
> Am 13.07.2020 um 00:31 schrieb Ben Pracht <ben.pracht at gmail.com>: > > > > In my case, I put the hello-world service in the main project directory, in the modules directory where the RESTXQPATH and in the RESTPATH. I've tried renaming the hello-world to .xq, .xqm and .xqy. In all cases, it does not find the .xq file. > > Best Regards, > Ben Pracht > 919.809.2439
BP
Ben Pracht31 Jul 2020 00:24 #
Michael,
Thank you immensely for your help. I didn't even think to update web.xml and so had no chance of this working. I know have a service in a distinct directory and static pages in a different directory, and I can at least control where they go.
Having said that, I found some things on startup that I didn't anticipate:
* From testing, it appears that the basexhttp server also starts the database server. From the options available in .basex, I was under the impression I had to start basexserver separately, but when I tried to run basexserver and subsequently basexhttp, the basexhttp server said the port was already in use.
* It's probably obvious to people who write RESTXQ code readily, but it seems worthwhile to note that the services run on the basexhttp server JVM, and not the basexserver JVM. Because I anticipate needing multiple databases, I'm trying to set up the server so that it can fork work over to the appropriate database. It would be nice if I could have XQUERY code running at the basexserver JVM.
* In my .basex file, I specify
HOST=localhost
PORT=1984
SERVERPORT=1984
SERVERHOST=localhost
Since it's the basexhttp that starts the basexserver, it's not clear to me which is considered the server, but nonetheless, somehow I'm able to get the above to at least partially function, though I'm confident that I did this wrong.
* I noticed there's a REST and a RESTXQ, for most part would I always want to use RESTXQ?
I hope those who write the documentation do not take offense to my questions. I'm not sure I would have thought to document it or how to write it in such a way that it doesn't get asked. This project is one of the best documented in the OSS community, and even better than some products for which money changes hands.
Thanks,
Ben
Best Regards,
Ben Pracht
ben.pracht at gmail.com
Quoted text · Michael Seiferle · 48 lines
On Mon, Jul 13, 2020 at 3:35 AM Michael Seiferle <ms at basex.org> wrote: > Hi Ben, > > Make sure to first read my previous mail, because you need a working > restxq-Setup ;-) > > Theres the „rest:wadl()“ function, that generates a representation of all > available endpoints. > > I added it to my example project, feel free to check it out here: > > > https://git.basex.io/basex-public/mailinglist-autocomplete/-/commit/84fda246ca3d1dfe7319ff4a401aa1504feee48a > > > The result will look something like this: > […] > <wadl:resource path="/search/{$what}"> > <wadl:param name="what" style="template"/> > <wadl:method name="GET"> > <wadl:request/> > <wadl:response> > <wadl:representation mediaType="application/json"/> > </wadl:response> > </wadl:method> > </wadl:resource> > […] > > Hope this helps :-) > > Michael > > > Am 13.07.2020 um 00:31 schrieb Ben Pracht <ben.pracht at gmail.com>: > > > > In my case, I put the hello-world service in the main project directory, > in the modules directory where the RESTXQPATH and in the RESTPATH. I've > tried renaming the hello-world to .xq, .xqm and .xqy. In all cases, it > does not find the .xq file. > > Best Regards, > Ben Pracht > 919.809.2439 > > >
MS
Michael Seiferle31 Jul 2020 11:47 #
Hi Ben,
Quoted text · Ben Pracht · 3 lines
> Am 30.07.2020 um 22:23 schrieb Ben Pracht <ben.pracht at gmail.com>: > > * From testing, it appears that the basexhttp server also starts the database server. From the options available in .basex, I was under the impression I had to start basexserver separately, but when I tried to run basexserver and subsequently basexhttp, the basexhttp server said the port was already in use.
Yes that is right; it will start both the HTTP-Server and the BaseX Server https://docs.basex.org/wiki/Web_Application <https://docs.basex.org/wiki/Web_Application>
Quoted text · Ben Pracht · 3 lines
>> An instance of the Jetty Web Server <https://www.eclipse.org/jetty/> will be started, which by default listens to the port 8984. Additionally, the BaseX Database Server <https://docs.basex.org/wiki/Database_Server> will be started, accessible on port 1984. The command-line output will look something like that (the JSP warning message can be ignored <https://stackoverflow.com/questions/3521654/missing-jsp-support-in-jetty-or-confusing-log-message>): > > * It's probably obvious to people who write RESTXQ code readily, but it seems worthwhile to note that the services run on the basexhttp server JVM, and not the basexserver JVM. Because I anticipate needing multiple databases, I'm trying to set up the server so that it can fork work over to the appropriate database. It would be nice if I could have XQUERY code running at the basexserver JVM.
This might be a little more work, you could start multiple BaseXServer Instances and use the client module [1] to connect to these instances and run queries on them. https://docs.basex.org/wiki/Client_Module <https://docs.basex.org/wiki/Client_Module>
So you’d basically have an restxq endpoint, and the endpoint decides which query to send to which basexserver via the client module.
Quoted text · Ben Pracht · 8 lines
> > * In my .basex file, I specify > HOST=localhost > PORT=1984 > SERVERPORT=1984 > SERVERHOST=localhost > > Since it's the basexhttp that starts the basexserver, it's not clear to me which is considered the server, but nonetheless, somehow I'm able to get the above to at least partially function, though I'm confident that I did this wrong.
The options are explained here,
https://docs.basex.org/wiki/Options#Client.2FServer_Architecture <https://docs.basex.org/wiki/Options#Client.2FServer_Architecture>
basexclient uses these options:
Quoted text · Ben Pracht · 2 lines
>> HOST: This host name is used by the client when connecting to a server. >> PORT: This port is used by the client when connecting to a server.
basexserver uses these options:
Quoted text · Ben Pracht · 2 lines
>> SERVERPORT: This is the port the database server will be listening to. >> SERVERHOST: This is the host name or ip address the server is bound to
IIRC these Options originated in the times before basexhttp / RestXQ :-)
Quoted text · Ben Pracht · 2 lines
> > * I noticed there's a REST and a RESTXQ, for most part would I always want to use RESTXQ?
RestXQ is way more flexible (in my opinion ;-)) and a lot more developer accessible (again in my opinion) for building web applications.
Quoted text · Ben Pracht · 2 lines
> > I hope those who write the documentation do not take offense to my questions.
Not at all :)
Quoted text · Ben Pracht · 1 line
> I'm not sure I would have thought to document it or how to write it in such a way that it doesn't get asked.
I think the many possibilities and features make it very hard to convey all the information needed at any time :-)
Quoted text · Ben Pracht · 1 line
> This project is one of the best documented in the OSS community, and even better than some products for which money changes hands.
Thank you very much! :)
Quoted text · Ben Pracht · 3 lines
> > Thanks, > Ben
Hope this helps!
Michael
Written for BaseX 9.3, 9.4. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery