返回的端点Content-Type:text/html,SELECT查询无法识别该文本/html [英] Endpoint returned Content-Type: text/html which is not rcognized for SELECT queries

查看:85
本文介绍了返回的端点Content-Type:text/html,SELECT查询无法识别该文本/html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是原始问题(这是第二部分).

我正在使用 HyperGraphQL 查询当我执行此GraphQL查询以检索 GO_0044727 的父母时:

When I execute this GraphQL query to retrieve the parents of GO_0044727 :

{
  Class_GET_BY_ID(uris:[
    "http://purl.obolibrary.org/obo/GO_0044727"]) {
    id
    label
    subClassOf {
      id
      label
      subClassOf {
        id
        label
        subClassOf {  # <--- 4th sub level
          id
          label
        }
      }
    }
  }
}

我没有结果:

{
  "extensions": {},
  "data": {
    "@context": {
      "_type": "@type",
      "_id": "@id",
      "label": "http://www.w3.org/2000/01/rdf-schema#label",
      "id": "http://www.geneontology.org/formats/oboInOwl#id",
      "Class_GET_BY_ID": "http://hypergraphql.org/query/Class_GET_BY_ID",
      "subClassOf": "http://www.w3.org/2000/01/rdf-schema#subClassOf"
    },
    "Class_GET_BY_ID": []
  },
  "errors": []
}

在日志中,我得到了错误:

In the logs I got the error:

java.util.concurrent.ExecutionException: org.apache.jena.query.QueryException: Endpoint returned Content-Type: text/html which is not rcognized for SELECT queries
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.hypergraphql.datafetching.services.SPARQLEndpointService.iterateFutureResults(SPARQLEndpointService.java:86)
    at org.hypergraphql.datafetching.services.SPARQLEndpointService.executeQuery(SPARQLEndpointService.java:69)
    at org.hypergraphql.datafetching.ExecutionTreeNode.generateTreeModel(ExecutionTreeNode.java:357)
    at org.hypergraphql.datafetching.FetchingExecution.call(FetchingExecution.java:21)
    at org.hypergraphql.datafetching.FetchingExecution.call(FetchingExecution.java:8)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.jena.query.QueryException: Endpoint returned Content-Type: text/html which is not rcognized for SELECT queries
    at org.apache.jena.sparql.engine.http.QueryEngineHTTP.execResultSetInner(QueryEngineHTTP.java:377)
    at org.apache.jena.sparql.engine.http.QueryEngineHTTP.execSelect(QueryEngineHTTP.java:344)
    at org.hypergraphql.datafetching.SPARQLEndpointExecution.call(SPARQLEndpointExecution.java:81)
    at org.hypergraphql.datafetching.SPARQLEndpointExecution.call(SPARQLEndpointExecution.java:33)
    ... 4 more

根据上面的GraphQL查询生成的SPARQL查询:

The SPARQL query generated based on the GraphQL query above:

SELECT * 
WHERE { 
    GRAPH <http://rdf.ebi.ac.uk/dataset/go> { 
        VALUES ?x_1 { <http://purl.obolibrary.org/obo/GO_0044727> } 
        ?x_1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . 
        OPTIONAL { 
            ?x_1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?x_1_1 .?x_1_1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . 
            OPTIONAL { ?x_1_1 <http://www.w3.org/2000/01/rdf-schema#label> ?x_1_1_1 . }  
                OPTIONAL { ?x_1_1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?x_1_1_2 .?x_1_1_2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . 
                OPTIONAL { ?x_1_1_2 <http://www.geneontology.org/formats/oboInOwl#id> ?x_1_1_2_1 . }  
                OPTIONAL { 
                    ?x_1_1_2 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?x_1_1_2_2 .?x_1_1_2_2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> . 
                    OPTIONAL { ?x_1_1_2_2 <http://www.w3.org/2000/01/rdf-schema#label> ?x_1_1_2_2_1 . }  
                    OPTIONAL { ?x_1_1_2_2 <http://www.geneontology.org/formats/oboInOwl#id> ?x_1_1_2_2_2 . }  
                }  
                OPTIONAL { ?x_1_1_2 <http://www.w3.org/2000/01/rdf-schema#label> ?x_1_1_2_3 . }  
            }  
            OPTIONAL { ?x_1_1 <http://www.geneontology.org/formats/oboInOwl#id> ?x_1_1_3 . }  
        }  
        OPTIONAL { ?x_1 <http://www.w3.org/2000/01/rdf-schema#label> ?x_1_2 . }  
        OPTIONAL { ?x_1 <http://www.geneontology.org/formats/oboInOwl#id> ?x_1_3 . }  
    }  
}

我通过在 config中添加?force 来尝试@AKSW回答此处.json 文件(行:"url":"http://www.ebi.ac.uk/rdf/services/sparql?force" ),但它没有用.

I tried @AKSW answer here by adding ?force in the config.json file (line: "url": "http://www.ebi.ac.uk/rdf/services/sparql?force") but it didn't work.

我认为查询时间可能太长,但是当我

I thought that maybe the query is too long but when I tested the query, it didn't give any error.

推荐答案

我发现的唯一解决方案是使用本地RDF文件:

The only solution I found is to query the Gene ontology using a local RDF file:

  1. 我下载了 go.owl 文件.
  2. 使用本体转换器将其转换为Turtle.
  1. I Downloaded go.owl file.
  2. Converted it to Turtle using the Ontology Converter.
 java -jar ont-converter.jar -i go.owl -o go_ont.ttl -of ttl -v

  • 配置的HyperGraphQL:

  • Configured HyperGraphQL:

    goconfig.json 文件:

    {
        "name": "go-hgql",
        "schema": "schemas/goschema.graphql",
        "server": {
            "port": 8082,
            "graphql": "/graphql",
            "graphiql": "/graphiql"
        },
        "services": [
            {
                "id": "go-local",
                "type": "LocalModelSPARQLService",
                "filepath": "go_ont.ttl",  # <----- the TTL file
                "filetype": "TTL"
            }
        ]
    }
    

    goschema.graphql :

    type __Context {
        Class:          _@href(iri: "http://www.w3.org/2002/07/owl#Class")
        id:             _@href(iri: "http://www.geneontology.org/formats/oboInOwl#id")
        label:          _@href(iri: "http://www.w3.org/2000/01/rdf-schema#label")
        subClassOf:     _@href(iri: "http://www.w3.org/2000/01/rdf-schema#subClassOf")
    }
    
    type Class @service(id:"go-local") {
        id: [String] @service(id:"go-local")
        label: [String] @service(id:"go-local")
        subClassOf: [Class] @service(id:"go-local")
    }
    

  • 使用配置文件启动HyperGraphQL:

  • Started HyperGraphQL using the config file:

    java -jar build/libs/hypergraphql-1.0.3-exe.jar --config hgql/config/goconfig.json
    

  • 然后执行查询,一切顺利,没有问题,我可以根据需要添加任意多个子级别.
  • 这篇关于返回的端点Content-Type:text/html,SELECT查询无法识别该文本/html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆