2017-05-14 10 views
0

SPARQL endpoint connector HTTP 요청에 사용자 지정 헤더를 추가하려고합니다. 커넥터 can use 사용자 정의 remote endpointApplyCustomRequestOptions 메소드를 상속받으며이를 대체 할 수 있습니다. 해당 방법에 대한 문서에 다음과 같이 표시됩니다.dotNetRdf의 원격 SPARQL 커넥터에 대한 사용자 지정 요청 옵션 적용

[...] 요청에 추가 사용자 지정 요청 옵션/헤더를 추가합니다.

그러나 내 재정의 된 메서드는 호출되지 않습니다. 따라서 내 사용자 지정 옵션이 적용되지 않으므로 헤더를 추가 할 수 없습니다.

using System; 
using System.Net; 
using VDS.RDF.Query; 
using VDS.RDF.Storage; 

class Program 
{ 
    static void Main(string[] args) 
    { 
     var endpointUri = new Uri("https://query.wikidata.org/sparql"); 

     var endpoint = new CustomEndpoint(endpointUri); 

     using (var connector = new SparqlConnector(endpoint)) 
     { 
      var result = connector.Query("SELECT * WHERE {?s ?p ?o} LIMIT 1"); 
     } 
    } 
} 

public class CustomEndpoint : SparqlRemoteEndpoint 
{ 
    public CustomEndpoint(Uri endpointUri) : base(endpointUri) { } 

    protected override void ApplyCustomRequestOptions(HttpWebRequest httpRequest) 
    { 
     // This is never executed. 
     base.ApplyCustomRequestOptions(httpRequest); 
     // Implementation omitted. 
    } 
} 

이이 방법을 사용하는 올바른 방법인가 : 예상대로

다음 코드는 내 ApplyCustomRequestOptions가 호출되지 않습니다 것을 제외하고, 작동? 그렇지 않다면 무엇입니까?

이것은 dotNetRdf 1.0.12, .NET 4.6.1입니다. 여러 SPARQL 끝점, 여러 쿼리 (SELECT & CONSTRUCT)와 SparqlConnector.Query의 여러 호출을 시도했습니다.

답변