2013-12-15 3 views
0

Restlet을 사용하여 안정적인 웹 서비스를 사용하려고합니다. 이 서비스는 JSON을 제공하므로 JSONRepresentation 객체를 사용하여 가져 오지만 작동하지 않습니다. jsonRepresentation.getJsonObject()을 호출하면 null 포인터 예외가 발생합니다.Restlet으로 JSON 웹 서비스를 소비하는 방법은 무엇입니까?

ClientResource resource = 
    new ClientResource("https://api.prosper.com/api/Listings?$top=3"); 
resource.setChallengeResponse(
    ChallengeScheme.HTTP_BASIC, 
    "username", 
    "password"); 
try { 
    JsonRepresentation jsonRepresentation = 
     new JsonRepresentation(resource.getResponse().getEntity()); 
    jsonRepresentation.getJsonObject(); 
} catch (Exception e) { } 

문제가 될 수있는 어떤 생각이나 방법을 내가 할 수있는 문제가 촬영이 : 여기

내 코드?
ClientResource resource = (...) 
(...) 
Representation repr = resource.get(); 
JsonRepresentation jsonRepresentation = new JsonRepresentation(repr); 
JSONObject jsonObj = jsonRepresentation.getJsonObject(); 

가 당신을 도움이되기를 바랍니다 :

+0

resource.getResponse()의 내용을 디버깅하십시오. 인증이 잘못되거나 비슷하다고 생각합니다. – tom

답변

2

난 당신이 서비스에 전화를받지 못한 생각합니다. Thierry