Code Monkey home page Code Monkey logo

Comments (9)

frmichel avatar frmichel commented on July 26, 2024

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.

from sparql-micro-service.

kleegrewec avatar kleegrewec commented on July 26, 2024

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

from sparql-micro-service.

frmichel avatar frmichel commented on July 26, 2024

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.

from sparql-micro-service.

kleegrewec avatar kleegrewec commented on July 26, 2024

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

assets.zip
config.ini.txt
service.php.txt

from sparql-micro-service.

frmichel avatar frmichel commented on July 26, 2024

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.

from sparql-micro-service.

kleegrewec avatar kleegrewec commented on July 26, 2024

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

from sparql-micro-service.

frmichel avatar frmichel commented on July 26, 2024

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.

from sparql-micro-service.

kleegrewec avatar kleegrewec commented on July 26, 2024

from sparql-micro-service.

frmichel avatar frmichel commented on July 26, 2024

Ok cool, thx for the information.

from sparql-micro-service.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.