Replies: 3 comments 4 replies
-
This is not a bug in RDF4J, but a problem in the SPARQL endpoint that you're querying. And it does not appear to be related to the presence or absence of username/password in the url, either. If we do a direct curl request with the same url and a simple sparql query, we see the following:
Note that the HTTP status response is 200 (meaning "Ok"), but that the body of the response indicates an error. Also note that the response does not contain a Content-Type header. This is why RDF4J gets a little confused processing the response: the status code says all is well, but then there is no content-type header so we can't parse the response (and even if we could, the response is not actually anything that we can do anything with). I have not been able to determine why the SPARQL endpoint responds with this error. The request as RDF4J (and indeed curl) sends it is syntactically correct. However, I did note something curious, which is that if I change the request URL by one character, we suddenly do get a correct response:
The only thing different here is that I've replaced the character in front of the query parameter: in the original URL it was a '?', in the replacement it is an '&'. It should be noted that the first URL is factually the correct one: the '?' character indicates the start of the list of parameters in a url, the '&' is only a separator between different params. It looks as if the endpoint software is not parsing the request parameters correctly. |
Beta Was this translation helpful? Give feedback.
-
As a workaround: I've noticed that if you use a POST request instead of a GET request to evaluate the query, the endpoint does respond correctly. RDF4J uses HTTP GET by default for SPARQL queries unless the request url gets too long, but you can force it to always use HTTP POST by setting the environment variable |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for trying that with curl and GET. Strange difference because both endpoints are made with absolutely the same software, just deployed to different machines. This query evaluation should be in both cases always be performed by a POST. The fact that using curl with GET the characters "?" and "&" are interpreted differently is not an issue, since the software does some URL rewriting for user convenience. [But the behaviour of the same software must be the same independently of the server executing it.] Wontfix? Is in your good right. BUT The fact that RDF4j gets confused "could" result at least in a more solid RDF4j reaction "I am confused". At least a check to one missing header like you think - could help (others) seeing what is missing. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Using eclipse-rdf4j-3.7.1-onejar.jar
and the code:
with as query
Everything is working fine and the code is delivering the first selected triple.
PROBLEMS arise when another URI "it.semweb.ch" instead of the uri "semwebs.com" is used in the query:
Both services (under it.semweb.ch and semwebs.com) deliver correct SPARQL results in case the query be executed e.g. inside some other SPARQL engine like GraphDB.
Unfortunately the second expression delivers - when executed by the above java code belonging to rdf4j - an exception because the java evaluate() code does not properly evaluate the SERVICE expression having this URI (it.semweb.ch with one subdomain AND login:password)
I suppose some regex inside fails to parse properly the whole URI https://demo2:[email protected]/S2Mapi/thesaurus/ASSEMBLY/sparql/ and the evaluation fails - since null results are delivered.
Please would you fix this?
The URI inside the SERVICE expression needs to include user:password credentials - since the data are protected.
Here some lines of the thrown exception:
Beta Was this translation helpful? Give feedback.
All reactions