Closed kleegrewec closed 3 years ago
Hi Christian, tricky indeed.
I copied the JSON content (from the log) to a separate file, and manually ran a script that uses the ML/JsonLD library (that is being used by the SPARQL micro-services). That worked fine, the JSON was converted to JSON-LD. So the JSON returned by the API is ok.
My guess is about an encoding issue in the response from the API. For instance it may not be UTF-8.
Could you please rerun the curl command to the API, but with the --verbose option, to see all the HTTP headers together with the content?
Franck.
Hi Frank,
First of all thanks for taking care of my problem. The problem seems not to be related to string encoding. Doing the curl with a --verbose did not result in some strange characters in my result and not in any errors. So I added some print statements to the Processor.php and found that the string that should be parsed is not my service response but some different string that looks like the contents of my profile.jsonld.
I the function parse in Processor.php where the exception is thrown I added a print statement.
/**
* Parses a JSON-LD document to a PHP value
* @param string $document A JSON-LD document.
* @return mixed A PHP value.
* @throws JsonLdException If the JSON-LD document is not valid.
*/
public static function parse($document)
{
print("Following document was returned\n");
print($document);
.....
This gives me the following output:
---------------8<--------------- Following document was returned { "@context": { "@base": "http://ns.inria.fr/sparql-micro-service/item/", "@vocab": "http://ns.inria.fr/sparql-micro-service/api#", } }
So it seems as if I try to parse the content of my profile.jsonld file and not the response returned by the server.
Any ideas?
best, Christian
Yes weird indeed.
Just a check: you mentioned earlier that you created files config.ini, profile.jsonld and service.php.
Why do you need the service.php file? This is normally used only when specific action must be taken. But in the most common case, you should not need it. A config.ini + profile.jsonld is sufficient to get the SPARQL micro-service to work. Later, if you need specific mapping, you may also create the optional construct.sparql file.
I'm concerned that your service.php would do a wrong manipulation and return the profile instead of the API repsonse.
Franck.
Hi Frank I removed the service.php from all my services and the problem remains. I have attached a service configuration (service.zip) and my config.ini and service.php from the src/sparqlms directory.
best, Christian
The function Processor::parse() where you added a print is called when loading the profile.jsonld, so the trace you get is normal.
But that also means that the failure occurs as soon as the profile is loaded, before we even try to process the API response.
In the profile.jsonld, I can see an extra comma at the end of the line "@vocab": "http://ns.inria.fr/sparql-micro-service/api#", Can you remove it and retry?
Franck.
Hi frank,
finally removiing the comma in the jsonld file did the trick. Now I get the desired results. In fact I never looked at this file carefully since it was copied from the manual_config_example folder. So it might be good to correct this in the next relase.
thank you for taking care, Christian
Thx @kleegrewec,
Indeed I've seen this mistake manual_config_example, sorry about that, I'll commit this fix soon. I've double-checked with other services where I did not see the error.
It is also a pb that the error message says "could not load the Web API response", whereas the error was in the profile. But this is coded in the JsonLD package that I used.
Anyway, I would appreciate if you can let me know (by personal email if you prefer) what you use SPARQL microservices for, just for information.
Regards, Franck.
Hi Frank
We evaluate sparql microservice because we need a lean and cost efficient (in this case free) solution to integrate legacy data services with a central graph database. The legacy services do not offer standard query interfaces. Data is frequently updated and the underlying data model is simple. Since the easiest way to create a standard interface for the legacy services is to implement a REST interface we decided to evaluate and possibly use sparql microservice to be used as federation layer for the legacy services.
Best regards,
Christian
Siemens AG T RDA BAM SMR-DE Otto-Hahn-Ring 6 81739 München, Deutschland Tel.: +49 89 636-633785 Mobil: +49 152 54914768 mailto:christian.kleegrewe@siemens.com mailto:christian.kleegrewe@siemens.com https://siemens.com www.siemens.com
Siemens Aktiengesellschaft: Vorsitzender des Aufsichtsrats: Jim Hagemann Snabe; Vorstand: Joe Kaeser, Vorsitzender; Roland Busch, Klaus Helmrich, Cedrik Neike, Matthias Rebellius, Ralf P. Thomas, Judith Wiese; Sitz der Gesellschaft: Berlin und München, Deutschland; Registergericht: Berlin-Charlottenburg, HRB 12300, München, HRB 6684; WEEE-Reg.-Nr. DE 23691322
Von: Franck Michel notifications@github.com Gesendet: Freitag, 26. Februar 2021 16:22 An: frmichel/sparql-micro-service sparql-micro-service@noreply.github.com Cc: Kleegrewe, Christian (T RDA BAM SMR-DE) christian.kleegrewe@siemens.com; Mention mention@noreply.github.com Betreff: Re: [frmichel/sparql-micro-service] Problem parsing json response of (#16)
Indeed I've seen this mistake manual_config_example, sorry about that, I'll commit this fix soon. I've double-checked with other services where I did not see the error.
It is also a pb that the error message says "could not load the Web API response", whereas the error was in the profile. But this is coded in the JsonLD package that I used.
Anyway, I would appreciate if you can let me know (by personal email if you prefer) what you use SPARQL microservices for, just for information.
Regards, Franck.
You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.co m%2Ffrmichel%2Fsparql-micro-service%2Fissues%2F16%23issuecomment-786711834&d ata=04%7C01%7Cchristian.kleegrewe%40siemens.com%7C4f3aa7b39a0c41be65b808d8da 6a3527%7C38ae3bcd95794fd4addab42e1495d55a%7C1%7C0%7C637499496984071519%7CUnk nown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXV CI6Mn0%3D%7C1000&sdata=FzlvY00gmrPu35xOK4vRsFwudVxBaKEAWQOQfn%2Budjc%3D&rese rved=0 , or unsubscribe https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.co m%2Fnotifications%2Funsubscribe-auth%2FAG4VZYRFMZPHVYEMDCV6JE3TA637ZANCNFSM4 YE66HQA&data=04%7C01%7Cchristian.kleegrewe%40siemens.com%7C4f3aa7b39a0c41be6 5b808d8da6a3527%7C38ae3bcd95794fd4addab42e1495d55a%7C1%7C0%7C637499496984071 519%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1h aWwiLCJXVCI6Mn0%3D%7C1000&sdata=isAeio%2BuMW6IKryJ2rpCk0iJ00K7RNiAbRn8yWLuRS k%3D&reserved=0 .
Ok cool, thx for the information.
Hello,
I have problems using sparql-micro-service with my own REST Service. The scenario is the following:
I have set up a REST service at localhost:8080. One of the API calls lists a number of assets as a json list. Each asset consists of a name, type and id.
Now I wanted to query the REST service using sparql-micro-services. Therefor I:
----- file config.ini 8<----------------
; Service custom parameters custom_parameter[] =
; Web API query string api_query = "http://service:8080/SDSP-SwitchingService/SDSP/assetList"
; Maximum time (in seconds) to cache responses from the Web API. Default: 2592000 = 30 days cache_expires_after = 2592000
; Add provenance information to the graph generated at each invocation. Default: false add_provenance = false
----- end file 8<-------------------
Now I change the docker compose instructions so that the new service is published in the /var/www/html/sparql-ms/services and in the corese image in /sparql-micro-service/services. In addition I add a new container to the deployment that is named service an that hosts the REST service.
I now start the deployment using docker-compose up and the containers all start with no error.
Now I use the following curl command to test the service:
curl --data-urlencode "query=SELECT * WHERE { ?s ?p ?o }" http://localhost/service/assets/assetList
The response is: Internal error: Cannot query the Web API or transform its response to JSON-LD.
I tried to access the REST service from inside the sparql-micro-service container and get the following result:
root@ba90376da655:/sparql-micro-service# curl http://service:8080/SDSP-SwitchingService/SDSP/assetList {"assetList":[{"id":"0","name":"Trafo_0","type":"Trafo"},{"id":"1","name":"Trafo_1","type":"Trafo"},{"id":"2","name":"Trafo_2","type":"Trafo"},{"id":"3","name":"Trafo_3","type":"Trafo"},{"id":"4","name":"Trafo_4","type":"Trafo"},{"id":"5","name":"Trafo_5","type":"Trafo"},{"id":"6","name":"Trafo_6","type":"Trafo"},{"id":"7","name":"Trafo_7","type":"Trafo"},{"id":"8","name":"Trafo_8","type":"Trafo"},{"id":"9","name":"Trafo_9","type":"Trafo"}]}
Inside the log file of sms i see the same result but somehow the JSON-LD cannot be created. The error in the log file is:
Syntax error, malformed JSON.
but the json is valid.
Do you have any ideas what is going wrong here?
thanks, Christian
sms-2021-02-24.log