Wrong Content Type returned by SPARQL Endpoint

Matters relating to SOA, SOAP, REST, BPEL, HTTP/WebDAV, VSP/VSPX Programming etc.

Wrong Content Type returned by SPARQL Endpoint

Postby RobV on Tue Aug 11, 2009 6:05 am

I've noticed that if I make a SPARQL DESCRIBE to the DBPedia endpoint http://dbpedia.org/sparql that although the endpoint returns Turtle the Content Type header is set to application/json

I assume this is something to do with your content negotiation and the Accept header I'm sending

My Accept header is as follows (removing the quality parameters has no effect). Previously my code couldn't handle RDF/JSON and when the MIME type for JSON wasn't present the code worked fine.
Code: Select all
application/rdf+xml,text/n3,text/rdf+n3,text/turtle,application/x-turtle,application/turtle,text/plain,application/json;q=0.9,*/*;q=0.8

My SPARQL Query is simply
Code: Select all
DESCRIBE <http://dbpedia.org/resource/Southampton>

Could you take a look at this and see if it's an issue with Virtuoso or an issue with my requests?
RobV
 
Posts: 12
Joined: Thu Aug 06, 2009 8:04 am

Re: Wrong Content Type returned by SPARQL Endpoint

Postby hwilliams on Tue Aug 11, 2009 8:33 am

Hi Rob,

How exactly is your query being executed when observing this issue ? As using curl I get data in the format requested and the correct Content Type reported :

Code: Select all
$ curl -I  "http://dbpedia.org/sparql?&query=DESCRIBE%20%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2FSouthampton%3E"
HTTP/1.1 200 OK
Server: Virtuoso/06.00.3121 (Solaris) x86_64-sun-solaris2.10-64  VDB
Connection: Keep-Alive
Date: Tue, 11 Aug 2009 13:21:02 GMT
Accept-Ranges: bytes
Content-Type: application/rdf+xml; charset=UTF-8
Content-Length: 184667

$ curl -I  "http://dbpedia.org/sparql?&format=application/x-turtle&query=DESCRIBE%20%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2FSouthampton%3E"
HTTP/1.1 200 OK
Server: Virtuoso/06.00.3121 (Solaris) x86_64-sun-solaris2.10-64  VDB
Connection: Keep-Alive
Date: Tue, 11 Aug 2009 13:22:14 GMT
Accept-Ranges: bytes
Content-Type: application/x-turtle; charset=UTF-8
Content-Length: 65278

$ curl "http://dbpedia.org/sparql?&format=application/x-turtle&query=DESCRIBE%20%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2FSouthampton%3E"
@prefix dbpprop:        <http://dbpedia.org/property/> .
@prefix dbpedia:        <http://dbpedia.org/resource/> .
<http://dbpedia.org/resource/1938_Jersey_Airport_disaster>      dbpprop:plane1Destination       dbpedia:Southampton .
dbpedia:Benny_Hill      dbpprop:birthPlace      dbpedia:Southampton .
@prefix dbpedia-owl:    <http://dbpedia.org/ontology/> .
dbpedia:Benny_Hill      dbpedia-owl:birthplace  dbpedia:Southampton .
<http://dbpedia.org/resource/2008_English_cricket_season>       dbpprop:round8Property21        dbpedia:Southampton .
dbpedia:Didier_Pironi   dbpprop:deathPlace      dbpedia:Southampton .
@prefix rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ns4:    <http://dbpedia.org/class/yago/> .
dbpedia:Southampton     rdf:type        ns4:Village108672738 ,
                dbpedia-owl:Place ,
                dbpedia-owl:Area ,
                ns4:CoastalCities ,
                ns4:PortsAndHarboursOfHampshire ,
                ns4:TownsInHampshire ,
                ns4:PortCitiesAndTownsInTheUnitedKingdom ,
                dbpedia-owl:Resource ,
                dbpedia-owl:PopulatedPlace ,
                ns4:PortsAndHarboursOfTheEnglishChannel ,
                ns4:CitiesInEngland ;
        dbpprop:areaMagnitude   "1 E7"@en ;
        dbpprop:janHi_percent_C2_percent_B0f    46 ;
        dbpprop:febHi_percent_C2_percent_B0f    46 ;
        dbpprop:junHi_percent_C2_percent_B0f    66 ;
        dbpprop:augHi_percent_C2_percent_B0f    69 ;
        dbpprop:aprLo_percent_C2_percent_B0f    41 ;
        dbpprop:mayLo_percent_C2_percent_B0f    46 ;
        dbpprop:julLo_percent_C2_percent_B0f    54 ;
        dbpprop:novLo_percent_C2_percent_B0f    41 ;
        dbpprop:marPrecipInch   2.6 ;
        dbpprop:sepPrecipInch   2.6 ;
        dbpprop:decPrecipInch   3.5 ;
        dbpedia-owl:establishedTitle    "Settled" ,
                "Unitary Authority" ,
                "City Status" ;
        dbpedia-owl:leaderTitle "Leadership" ,
                "Executive" ,
                "MPs" ,
                "Governing&nbsp;body" ;
        dbpedia-owl:populationMetro     "1000000" ;
        dbpedia-owl:populationTotal     "89" ,
                "1691001" ,
                "228600" ;
        dbpedia-owl:populationUrbanTotal        "304400" ;
        dbpedia-owl:type        dbpedia:Unitary_authority ,
                dbpedia:City_status_in_the_United_Kingdom ;
        dbpprop:disambiguates   <http://dbpedia.org/resource/Southampton%2C_Houston%2C_Texas> ,
                <http://dbpedia.org/resource/Southampton%2C_St._Louis> ,
                <http://dbpedia.org/resource/Southampton%2C_Massachusetts> ,
                <http://dbpedia.org/resource/Southampton%2C_New_Jersey> ,
                <http://dbpedia.org/resource/Southampton%2C_New_York> ,
                <http://dbpedia.org/resource/Southampton_County%2C_Virginia> ,
                <http://dbpedia.org/resource/Southampton_%28UK_Parliament_constituency%29> ,
                dbpedia:Southampton ,
                <http://dbpedia.org/resource/Southampton_F.C.> ,
                dbpedia:Southampton_Island ,
                <http://dbpedia.org/resource/Southampton%2C_Ontario> ,
                <http://dbpedia.org/resource/Southampton%2C_New_Brunswick> ,
                <http://dbpedia.org/resource/Southampton_Township%2C_Pennsylvania> ,
                <http://dbpedia.org/resource/Southampton%2C_Nova_Scotia> ,
                <http://dbpedia.org/resource/Southampton%2C_Pennsylvania> ,
                <http://dbpedia.org/resource/Southampton_Parish%2C_Bermuda> .
@prefix ns5:    <http://dbpedia.org/resource/Template:> .
dbpedia:Southampton     dbpprop:wikiPageUsesTemplate    ns5:audio ,
                ns5:openstreetmapthumb ,
                ns5:infobox_settlement ,
                ns5:coord ,
                ns5:infobox_weather ;
        dbpprop:name    "Southampton"@en ;
        dbpprop:officialName    "Southampton"@en ;
        dbpprop:utcOffsetDst    1 ;
        dbpprop:imageBlankEmblem        <http://upload.wikimedia.org/wikipedia/en/7/7e/Crt_logo_southamptoncitycou.jpg> .


Please let me know ...

Best Regards
Hugh Williams
OpenLink Software
hwilliams
 
Posts: 258
Joined: Thu Mar 06, 2008 4:30 am

Re: Wrong Content Type returned by SPARQL Endpoint

Postby RobV on Tue Aug 11, 2009 9:19 am

My query is being executed using System.Net.HttpWebRequest from the .Net Framework 3.5 SP1

Debug trace that I've output is as follows:
Code: Select all
# HTTP DEBUGGING #
HTTP Request to http://dbpedia.org/sparql?query=DESCRIBE <http://dbpedia.org/resource/Southampton>&default-graph-uri=http://dbpedia.org

Accept:application/rdf+xml,text/n3,text/rdf+n3,text/turtle,application/x-turtle,application/turtle,text/plain,application/json;q=0.9,*/*;q=0.8

HTTP Response from http://dbpedia.org/sparql?query=DESCRIBE <http://dbpedia.org/resource/Southampton>&default-graph-uri=http://dbpedia.org
HTTP/1.1 200 OK

Connection:Keep-Alive
X-SPARQL-default-graph:http%3A%2F%2Fdbpedia.org
Accept-Ranges:bytes
Content-Length:69800
Content-Type:application/json; charset=UTF-8
Date:Tue, 11 Aug 2009 14:05:25 GMT
Server:Virtuoso/06.00.3121 (Solaris) x86_64-sun-solaris2.10-64  VDB

# END HTTP DEBUGGING #


Note that URIs are all properly encoded just when you do ToString() on a Uri object in .Net it unescapes the encoding

I haven't posted the full response as it was too long, mine seems to differ from yours in that it has all the special characters escpaed e.g. \n,\r,\t and all the Unicode stuff escaped to \u escapes
RobV
 
Posts: 12
Joined: Thu Aug 06, 2009 8:04 am

Re: Wrong Content Type returned by SPARQL Endpoint

Postby hwilliams on Tue Aug 11, 2009 6:51 pm

Hi Rob,

Do you have a sample application we can compile and run to see this issue first hand, as I am wondering if this might be specific to the .Net layer, possibly in the ADO.Net Provider or the System.Net.HttpWebRequest class.

if you specify just "application/rdf+xml" in your Accept header, what content type is returned ?

Best Regards
Hugh Williams
OpenLink Software
hwilliams
 
Posts: 258
Joined: Thu Mar 06, 2008 4:30 am

Re: Wrong Content Type returned by SPARQL Endpoint

Postby RobV on Wed Aug 12, 2009 3:01 am

If I only specify application/rdf+xml I get exactly that and if I remove application/json from my original accept header I get text/rdf+n3

I can put together a sample app if you want but it'll take me a day or so as I have more pressing work to get done
RobV
 
Posts: 12
Joined: Thu Aug 06, 2009 8:04 am

Re: Wrong Content Type returned by SPARQL Endpoint

Postby hwilliams on Wed Aug 12, 2009 4:03 am

Hi Rob,

What about if you just specify "application/json" in your accept header, do you the expected json output return and expected "application/json" Content type return ?

Regards
Hugh
hwilliams
 
Posts: 258
Joined: Thu Mar 06, 2008 4:30 am

Re: Wrong Content Type returned by SPARQL Endpoint

Postby jhand on Tue Aug 18, 2009 7:59 am

Hi Rob,

It looks like the issue is at the DBpedia end of things. There seems to be a problem with Virtuoso's handling of the Accept headers. We will be looking into this. In the mean time you can work around this by specifying an &format in the request. Something like:

"http://dbpedia.org/sparql?&format=application/x-turtle&query=DESCRIBE%20%3Chttp%3A%2F%2Fdbpedia.org%2Fresource%2FSouthampton%3E"

Hope this helps.

Best Regards
Jacqui Hand
OpenLink Software
jhand
 
Posts: 4
Joined: Mon Aug 17, 2009 5:21 am

Re: Wrong Content Type returned by SPARQL Endpoint

Postby chas on Thu Oct 15, 2009 12:19 pm

Maybe my problem is related, but I'm having trouble getting JSON results back from a SPARQL endpoint. For example, this command,

curl "http://[host]:8890/sparql?format=application/sparql-results+json&" --data-urlencode query@browseJSON

returns results in XML. According to the documentation I have, the above (or something like it) should work. Am I doing something incorrect, or is in fact JSON output not yet supported by the SPARQL endpoint for "select" queries?

Thanks.
chas
 
Posts: 4
Joined: Wed Jul 22, 2009 12:51 pm

Re: Wrong Content Type returned by SPARQL Endpoint

Postby chas on Thu Oct 15, 2009 3:26 pm

Looking at the documentation for another triplestore, which cites what works with Virtuoso, I tried the following instead of "format=application/sparql-results+json":

output=json

That works.
chas
 
Posts: 4
Joined: Wed Jul 22, 2009 12:51 pm

Re: Wrong Content Type returned by SPARQL Endpoint

Postby hwilliams on Thu Oct 15, 2009 4:44 pm

Hi

That is correct as detailed at:

http://docs.openlinksw.com/virtuoso/rdf ... ofprotocol

Best Regards
Hugh Williams
OpenLink Software
hwilliams
 
Posts: 258
Joined: Thu Mar 06, 2008 4:30 am


Return to Virtuoso - Web Services Platform

Who is online

Users browsing this forum: No registered users and 1 guest

cron