2017-02-09 44 views
0

我正在嘗試使用HTTP標頭,以便我可以驗證我的應用程序以查詢ORCID(http://orcid.org)公共API。我創建這樣的標題:如何將http標頭添加到Apache Jena QueryEngineHTTP查詢?

HttpOptions httpOptions = new HttpOptions(); 
Header contentTypeHeader = new BasicHeader("Content-Type", "application/orcid+json"); 
Header authorizationHeader = new BasicHeader("Authorization", "Bearer 5266384f-0567-43f0-9cd4-bc6f6a5dc3ea"); 
Header[] headers = new Header[2]; 
headers[1] = contentTypeHeader; 
headers[2] = authorizationHeader; 
httpOptions.setHeaders(headers); 

但我不知道如何將這些標題放到我的查詢中。我在寫我的查詢是這樣的:

QueryExecution execution = new QueryEngineHTTP(endpoint, query); 

使用org.apache.jena.sparql.engine.http.QueryEngineHTTP

回答

0

阿帕奇現在耶拿(V3.1.1及更高版本)提供的手段來傳遞在具有必要安全設置的HttpClient中。

Docmentation

... set up an appropriate HttpClient for authentication .... 

QueryExecution execution = QueryExecutionFactory.sparqlService(... , httpClient) 
相關問題