Hi all,
I am doing some tests with the jax-rx api - using static html files and a little jquery.
I placed the html file in the \basex-api\etc directory and wanted to use the run command to let jetty deliver the html document:
http://localhost:8984/basex/jax-rx?run=QueryTest.html&wrap=no&output...
The deliverd file will always be text/plain, however. Is there anything I am missing, or will the media-type option currently not affect the response Content-Type?
Regards, Max
For completeness, this is the ajax call:
var data1 = '<query xmlns="http://jax-rx.sourceforge.net"><text>for $f in //file return $f/type</text><parameter name="count" value="5"/><parameter name="wrap" value="yes"/></query>';
var url1 = "http://localhost:8984/basex/jax-rx/Applications";
$.ajax( { url: url1, data: data1, type: "POST", processData: false, contentType: "application/query+xml", timeout: 10000, dataType: "xml", error: function(){ alert('Error loading XML document'); }, success: function(xml){ //alert(xml); $(xml).find('type').each(function(){ var item_text = $(this).text();
$('<li></li>') .html(item_text) .appendTo('#list'); }); } } );
Hi Max,
currently, the Content-Type is always set to text/plain if "wrap" is set to "no". Otherwise (depending on the evaluated query), the returned results might not always be well-formed. – We might change this in future, however, as your request sounds quite reasonable.
Best, Christian
On Fri, Jul 30, 2010 at 11:42 PM, Maximilian Gärber mgaerber@arcor.de wrote:
Hi all,
I am doing some tests with the jax-rx api - using static html files and a little jquery.
I placed the html file in the \basex-api\etc directory and wanted to use the run command to let jetty deliver the html document:
http://localhost:8984/basex/jax-rx?run=QueryTest.html&wrap=no&output...
The deliverd file will always be text/plain, however. Is there anything I am missing, or will the media-type option currently not affect the response Content-Type?
Regards, Max
For completeness, this is the ajax call:
var data1 = '<query xmlns="http://jax-rx.sourceforge.net"><text>for $f in //file return $f/type</text><parameter name="count" value="5"/><parameter name="wrap" value="yes"/></query>';
var url1 = "http://localhost:8984/basex/jax-rx/Applications";
$.ajax( { url: url1, data: data1, type: "POST", processData: false, contentType: "application/query+xml", timeout: 10000, dataType: "xml", error: function(){ alert('Error loading XML document'); }, success: function(xml){ //alert(xml); $(xml).find('type').each(function(){ var item_text = $(this).text();
$('<li></li>') .html(item_text) .appendTo('#list'); }); } } ); _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Hi Christian,
I guess serving static xhtml is not so common but I was thinking about generating the xhtml using xquery, so there would still be the need to modify the Content-Type.
This scenario would allow for a pure xhtml/javascript/xquery application.
Btw, are there any objections about publicly exposing the jax-rx api in a real world application? What security options would I have besides database user/password?
Best regards,
Max
2010/7/31 Christian Grün christian.gruen@gmail.com:
Hi Max,
currently, the Content-Type is always set to text/plain if "wrap" is set to "no". Otherwise (depending on the evaluated query), the returned results might not always be well-formed. – We might change this in future, however, as your request sounds quite reasonable.
Best, Christian
Max,
This scenario would allow for a pure xhtml/javascript/xquery application.
True – I'm pretty sure this will be changed in the next release. As I discovered, the current issue is that the serialization parameters are interpreted by the implementation (i.e., BaseX) and not the JAX-RX API itself, whereas the content type is set by JAX-RX. As a consequence, the change will have effects on the API as well.
Btw, are there any objections about publicly exposing the jax-rx api in a real world application? What security options would I have besides database user/password?
I asked Lukas, our JAX-RX expert, on this, he'll give you an answer soon.
Best, Christian
basex-talk@mailman.uni-konstanz.de