我想通过 SPARQLs marmotta webservice 从 AngularJS 控制器执行 apache marmotta 的示例 SPARQL 查询。示例代码:
var url = "http://localhost:8080/marmotta/";
var query = "SELECT * WHERE { ?subject ?property ?object }"
$http.post(url+"sparql/select",{
'output': "json",
'query': query
} ).then(function(data){
$scope.hello = data;
}).catch(function(error){
alert(error);
});
我收到“不支持查询”,然后收到 500 SyntaxError:
SyntaxError:在默认HttpResponseTransform(http://localhost:63342/ws/)的fromJson( http ://localhost:63342/ws/app/script/angular.js:1075:14)的Object.parse(本机)的意外令牌q app/script/angular.js:8650:16 ) 在http://localhost:63342/ws/app/script/angular.js:8735:12在 forEach ( http://localhost:63342/ws/app/script /angular.js:326:20 ) 在 transformData ( http://localhost:63342/ws/app/script/angular.js:8734:3 ) 在 transformResponse ( http://localhost:63342/ws/app/script /angular.js:9464:23 ) 在 processQueue ( http://localhost:63342/ws/app/script/angular.js:13292:27 ) 在http://localhost:63342/ws/app/script/angular .js:13308:27在 Scope.$get.Scope.$eval ( http://localhost:63342/ws/app/script/angular.js:14547:28 )
或者当我使用这样的代码时:
var url = "http://localhost:8080/marmotta/";
var query = "SELECT * WHERE { ?subject ?property ?object }";
$http.get(url+"sparql/select/query="+query+"&output='json'")
.then(function(data){
$scope.hello = data;
}).catch(function(error){
$scope.hello = error.stack;
});
我得到一个 404。任何想法如何正确使用 SPARQL WS API?