-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error with semmod:results-payload #50
Comments
Sounds like you are using the rest extension to execute sparql, but that should not be necessary. I'd compare with how ml-lodlive-ng configures ml-lodlive..
|
@grtjn I thought ml-lodelive-ng uses dbpedia and not an internal ML endpoint. |
It packages two pre-defined configs, one for dbpedia, one for marklogic.. |
but I guess it presumes that you're running on the same port? I have an app running on port 3000 trying to access ML on a different host. |
The profile factory in ml-lodlive-ng gives you a plain json config. You can patch it with straight js. You could also just compare the ml profile with what you are currently using. Just to see where it differs from the one in this project or what you were using yourself.. |
Yes, this is the relevant bit: MarkLogicProfile.connection = {
// http matches all http requests, so this will be the only connection settings used
'http:': {
endpoint: '/v1/graphs/sparql',
accepts: 'application/sparql-results+json',
description: {
en: 'MarkLogic LodLive'
}
}
}; This is what I have: var MyProfileObject = {};
MyProfileObject.endpoints = {};
MyProfileObject.connection = {
'http:': {
endpoint: 'http://192.168.56.200:8060/lodlive.xqy',
accepts: 'application/sparql-results+json'
}
}; Since I'm not running my app from the same machine where ML is, according to the documentation I need this lodlive.xqy file: "This can be loaded into MarkLogic as RDF triples and can the be exposed via a standard REST application in MarkLogic. If accessing this REST endpoint from a different host or port it will be necessary to install the lodlive.xqy module at the root of the /modules directory for that REST server. Additionally, update your lodlive profile so that the lodlive.xqy url is used as the base." |
I of course also have this added to the config: MyProfileObject.endpoints = {
all: '',
jsonp: true
}; |
I think the statement you need lodlive.xqy is wrong. Just prefix /v1/etc with host and port you need for you app.. |
I have done that. In that case the error changes to:
This is due to the fact that I am executing a JSONP request (because I am on different hosts) |
Yeah, dont think v1 sparql supports jsonp. Can you live without that? 😁 |
Nope 😢 I need JSONP support. The problem is in the lodlive.xqy file somewhere ... but since XQY is not my strong suite I can't really figure it out. I have managed to update the code so that it no longer throws the error mentioned in the subject to be the following: xquery version "1.0-ml";
import module namespace semmod = "http://marklogic.com/rest-api/models/semantics"
at "/MarkLogic/rest-api/models/semantics-model.xqy";
import module namespace eput = "http://marklogic.com/rest-api/lib/endpoint-util"
at "/MarkLogic/rest-api/lib/endpoint-util.xqy";
declare option xdmp:mapping "false";
let $params := map:map()
let $_ := for $i in xdmp:get-request-field-names() return map:put($params, $i, xdmp:get-request-field($i))
let $headers := eput:get-request-headers()
let $result := semmod:sparql-query($headers,$params,map:get($params, "query"))
let $response := semmod:results-payload($headers,$params,$result, ())
let $_ := xdmp:set-response-content-type($response[1])
return (
if (map:get($params, "callback")) then fn:concat(map:get($params, "callback"), "(") else (),
$response[2],
if (map:get($params, "callback")) then ")" else ()
) But this now throws the error of:
Which has lead me to the actual implementation of |
I'm on mobile unfortunately. Send me a mail on my work address as a reminder, i might have a spare moment tomorrow. Why are you stuck with jsonp? Never needed it myself.. 😉 |
I am running a Node.js app from where I would like to display a LodLive graph 😄 |
I just had an idea, I'll try to proxy my request ... 😄 |
Did proxying help? |
@grtjn - yes it did help. Thanks. But I'd still like to see a working version of this lodlive.xqy :) |
I can't get this to work as I am getting an error with the
semmod:results-payload
function:After checking the results-payload function signature, I can verify that it is expecting 4 arguments, the 4th argument being a 'callback'. I am using ML8 and EA4 ML9.
Any suggestions how I could fix this issue?
The text was updated successfully, but these errors were encountered: