on 07-28-2015 10:45 AM
Hello Experts,
I am using SAP HANA SPS 09 and want to do text mining using XS API. I have created below .xsjs file in which I have used $.db.textmining.Session. I want to know how I can connect the xsjs file to the database, whether I have to create .sqlcc configuration
or any other type to connect to database ??
While running the text mining file it is giving error as Possible Web Forgery Attack.
XSJS file for Text Mining :-
function displayResults(results)
{
var propName = null;
var propNames = [];
var result = null;
var row = 0;
var col = 0;
if (results.length === 0)
{
output += "<p>(empty result table)</p>";
return;
}
output += "<table border='1'>";
// Get and save property names from first result row and put in the table header.
output += "<tr>";
for (propName in results[0])
{
if (results[0].hasOwnProperty(propName))
{
propNames[propNames.length] = propName;
output += "<th>" + propName + "</th>";
}
}
output += "</tr>";
// For each result row, put in the table property values.
for (row = 0; row < results.length; ++row)
{
result = results[row];
output += "<tr>";
for (col = 0; col < propNames.length; ++col)
{
output += "<td>" + result[propNames[col]].slice(0,50) + "</td>";
}
output += "</tr>";
}
output += "</table>";
}
try
{
output += "<p>create session</p>";
// var conn = $.db.getConnection();
var TM = new $.db.textmining.Session
({
referenceTable: "TEXT_MINING:TEST",
referenceColumn: "TEXT",
// connection: conn
});
output += "<p>initialize</p>";
var init = TM.initialize({ });
output += "<p>getRelatedTerms</p>";
var termResults = TM.getRelatedTerms
({
top: 16,
inputTermText: "animal",
});
displayResults(termResults);
output += "<p>Done -- no errors detected.</p>";
}
catch(err)
{
output += "<p>" + err + "</p>";
}
//-----------------------------------------------------------------------------
output += "</body>";
$.response.contentType = "text/html";
$.response.setBody(output);
Can you share your project here? Maybe I can find time and try it internally.
BRs,
Lucas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Deepak,
Your code is just a copy of the one from the SAP HANA Tutorial for Text Mining so it should work.
I believe the error you're facing is related to the option for automatic prevention of cross-site request forgery. Check your .xsaccess file. Value prevent_xsrf should be true (which is a good thing).
There's probably a point of your code allowing that sort of attack...
Of course, for the sake of *testing* you could deactivate that and keep working on your tests.
BRs,
Lucas de Oliveira
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.