serialization options with jax-rx

Friday, 30 July 2010 · 4 messages · last reply 2 Aug 2010
MG
Maximilian Gärber30 Jul 2010 23:42 #
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=media-type%3Dapplication%2Fxhtml%2Bxml 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');
						});
				}
            } );
CG
Christian Grün31 Jul 2010 18:27 #
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
Quoted text · Maximilian Gärber · 55 lines
On Fri, Jul 30, 2010 at 11:42 PM, Maximilian Gärber <mgaerber at 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=media-type%3Dapplication%2Fxhtml%2Bxml > > 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 at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
MG
Maximilian Gärber1 Aug 2010 23:08 #
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 at gmail.com>:
Quoted text · Christian Grün · 11 lines
> 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 > >
CG
Christian Grün2 Aug 2010 11:21 #
Max,
Quoted text · Maximilian Gärber · 1 line
> 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.
Quoted text · Maximilian Gärber · 3 lines
> 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

⚡Generated with XQuery