AJAX call inside SPINx function

29 views
Skip to first unread message

ing.anton...@gmail.com

unread,
Apr 22, 2015, 5:12:54 AM4/22/15
to topbrai...@googlegroups.com
Hi all,

Im wondering if is possible to implement an AJAX GET or POST call inside a SPINx function.
I tried this but is not working:

var url = MYLOCALURL

var params = MYPARAMS;

http.open("GET", url, true);


//Send the proper header information along with the request

http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

http.setRequestHeader("Content-length", params.length);

http.setRequestHeader("Connection", "close");


http.onreadystatechange = function() {//Call a function when the state changes.

if(http.readyState == 4 && http.status == 200) {

return (http.responseText);

}

}

http.send(params);


Also wondering if we can implement JAVA code using SPINx


Thanks


Antonino Lo Bue


Holger Knublauch

unread,
Apr 22, 2015, 7:23:49 PM4/22/15
to topbrai...@googlegroups.com
Hi Antonino,

the JavaScript support in TopBraid's SPINx feature is based on Mozill Rhino, so the first thing to check would be whether Rhino supports such http requests. My second suspicion is that the function below would not work because it doesn't block on read - it sends out the request and then finishes, while the return statement is in a callback that is called asynchronously. So overall I don't think JavaScript would work for your scenario.

To issue GET requests as part of SPARQL functions, you have several other options, including definition of functions using SPARQLMotion (which can then call sml:PostRequest or sml:ImportTextFromURL etc) and functions based on SWP. But these require TBC-ME (I can provide details if you can confirm that TBC-ME is an option for you).

The ultimate fallback is to use SPARQL functions based on Java, against the Jena API. Details can be found at

    Extending TopBraid Suite > Adding SPARQL Functions to TopBraid

in the TBC Help.

HTH
Holger
--
You received this message because you are subscribed to the Google Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary Network (EVN), Reference Data Manager (RDM), TopBraid Composer, TopBraid Live, TopBraid Insight, SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to topbrai...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ing.anton...@gmail.com

unread,
Apr 27, 2015, 6:38:03 AM4/27/15
to topbrai...@googlegroups.com
Thanks a lot Holger
Reply all
Reply to author
Forward
0 new messages