Topic on Extension talk:LinkedWiki

Fail to insert to SPARQL endpoint

8
ACastro24 (talkcontribs)

Hello,

I am quite new to LinkedWiki, but have been playing with it in localhost MW instance, along with Fuseki. It is really interesting combination. Ultimately I would like to "mirror" all the semantic property:value pairs on to a Fuseki dataset, but at the moment I am struggling to do inserts from MW to the Fuseki SPARQL endpoint. an I wondering if I could get some help here :)

I am running:

  • MediaWiki 1.34.1
  • PHP 7.3.14-1~deb10u1 (apache2handler)
  • MariaDB 10.3.22-MariaDB-0+deb10u1
  • Semantic MediaWiki3.1.6

In the Special:SparqlQuery I can perform SELECT queries no problem.

However, when I try to perform the following insert, I get Error message: Sorry, you have not configure the endpoint to update the database.

Which is strange since the same statement run just fine in the SPARQL Flint editor

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
DELETE
{ foaf:Person foaf:name "Sara" . }
INSERT
{ foaf:Person foaf:name "Zara" . }
WHERE { foaf:Person foaf:name "Sara" . }

Or with a POST request via curl

curl http://localhost:3030/beerwiki/ -X POST --data 'update=%0APREFIX+foaf%3A+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0A%0ADELETE%0A%7B%0A++++foaf%3APerson+foaf%3Aname+%22Sara%22+.+%0A%7D%0AINSERT%0A%7B%0A%09foaf%3APerson+foaf%3Aname+%22Zara%22+.+++%0A%7D%0AWHERE+%7B%0A%09foaf%3APerson+foaf%3Aname+%22Sara%22+.+++%0A%7D' -H 'Accept: text/plain,*/*;q=0.9'


Here is my InterWiki setting in LocalSettings.php

wfLoadExtension( 'LinkedWiki' );

$wgAutoloadClasses['BeerwikiStorageMethod'] = "$IP/extensions/LinkedWiki/storageMethod/BeerwikiStorageMethod.php";

$wgLinkedWikiConfigSPARQLServices["http://localhost/beerwiki"] = array(
	"debug" => true,
	"isReadOnly" => false,
	"typeRDFDatabase" => "fuseki",
	"endpointRead" => "http://localhost:3030/beerwiki/",
	"endpointWrite" => "http://localhost:3030/beerwiki/",
	"login" => "admin",
	"password" => "pw123",
	"HTTPMethodForRead" => "POST",
	"HTTPMethodForWrite" => "POST",
	"lang" => "en",
	"nameParameterRead" => "query",
	"nameParameterWrite" => "update",
    "storageMethodClass" => "BeerwikiStorageMethod"
);

$wgLinkedWikiSPARQLServiceSaveDataOfWiki= "http://localhost:3030/beerwiki/";


And the BeerwikiStorageMethod.php

<?php

class BeerwikiStorageMethod extends StorageMethodAbstract {
    /**
     * @return string
     */

    private $graphNamed = "http://localhost/beerwiki"; 

    public function getQueryReadStringWithTagLang() {
        return <<<EOT
SELECT DISTINCT  ?value
WHERE
        {
            ?subject ?property ?value .
            FILTER ( lang(?value) = ?lang )
        }
EOT;
    }

    /**
     * @return string
     */
    public function getQueryReadStringWithoutTagLang() {
        return <<<EOT
SELECT DISTINCT  ?value
WHERE
        {
            ?subject ?property ?value .
            FILTER ( lang(?value) = "" )
        }
EOT;
    }

    /**
     * @return string
     */
    public function getQueryReadValue() {
        return <<<EOT
SELECT DISTINCT  ?value
WHERE
        {
            ?subject ?property ?value .
        }
EOT;
    }

    /**
     * @return string
     */
    public function getQueryInsertValue() {
        return <<<EOT
INSERT DATA
    {
            ?subject ?property ?value .
    }
EOT;
    }

    /**
     * @return string
     */
    public function getQueryDeleteSubject() {
        return <<<EOT
DELETE
        { ?subject ?property ?value . }
WHERE
        { ?subject ?property ?value . }

EOT;
    }

    /**
     * @param string $url
     * @return string
     */
    public function getQueryLoadData( $url ) {
        return "";
    }

}
Karima Rafes (talkcontribs)
ACastro24 (talkcontribs)

Thank you Karima, That makes sense. I changed it, but I am still getting the same error message.


Here is the section of LocalSettings.php concerning LinkedWiki, as it stands:


wfLoadExtension( 'LinkedWiki' );

$wgAutoloadClasses['BeerwikiStorageMethod'] = "$IP/extensions/LinkedWiki/storageMethod/BeerwikiStorageMethod.php";

$wgLinkedWikiConfigSPARQLServices["http://localhost/beerwiki"] = array(
	"debug" => true,
	"isReadOnly" => false,
	"typeRDFDatabase" => "fuseki",
	"endpointRead" => "http://localhost:3030/beerwiki/",
	"endpointWrite" => "http://localhost:3030/beerwiki/",
	"login" => "admin",
	"password" => "pw123",
	"HTTPMethodForRead" => "POST",
	"HTTPMethodForWrite" => "POST",
	"lang" => "en",
	"nameParameterRead" => "query",
	"nameParameterWrite" => "update",
    "storageMethodClass" => "BeerwikiStorageMethod"
);

$wgLinkedWikiSPARQLServiceSaveDataOfWiki= "http://localhost/beerwiki";


Karima Rafes (talkcontribs)

In the special page about the LinkedWiki configuration, all is ok ?

In the http errors, there is nothing ?

Karima Rafes (talkcontribs)

Try also without the parameter : "typeRDFDatabase" => "fuseki"

ACastro24 (talkcontribs)

Thank you Karima.

commenting <code>"typeRDFDatabase" => "fuseki"</code> did not change anything

The special page about the LinkedWiki configuration seems OK. Here is a screen capture of the config for that endpoint.

http://artserver.org/publicfiles/Screenshot_2020-05-18%20LinkedWiki%20configuration%20-%20beerwiki.png


This is the error I get:

Error endpoint: Error http_response_code: 0 Error message: Sorry, you have not configure the endpoint to update the database.

It does not seem to get any response from the SPARQL endpoint.

In Fuseki call the update POST also does not get acknowledged, which makes me think that the issue might be in how LinkedWiki is trying to "talk" to fuseki on update posts.

Is there a way I can debugg the POST calls that LinkedWiki is making to the SPARQL endpoint?


Karima Rafes (talkcontribs)
Karima Rafes (talkcontribs)

I pushed a new version. There are a bug in the special page RDFUnit and refresh database for the version 1.34.1. I don't know if your problem is related.

NB: You need to change a little your localsettings (new installation about PushAll and of NamespaceData)

Reply to "Fail to insert to SPARQL endpoint"