新手在這裏。我有一個REST服務,看起來像這樣:JerseyClient webResource問題
@GET
@PATH("/{id}/headerinfo")
@Produces({ JSON, XML})
public Response getRequestHEADER(@PathParam("id") long id) {
Request result = em.find(Request.class, id);
...
return Response.ok(entity).build();
這裏是我的電話吧,這是給我的問題:
@Path("") //what should go here?
public class AaRestCall
public static String subTrackNum (String trackNum) throws IOException {
try {
Client client = Client.create();
WebResource webResource = client.
resource("https://url/rest/request/" + trackNum);
ClientResponse response = webResource.
accept("application/json").get(ClientResponse.class);
String output = response.getEntity(String.class);
return output;
}
catch some stuff here
}
我有幾個問題:
1)善有善報在@Path參數?
2)webResource給我一個錯誤,它被調用爲webResource.accept時無法解析。我不清楚爲什麼。
3)任何額外的提示將不勝感激,因爲這是我第一次REST通話和第一次使用澤西島。
請參閱本作pathparam例子之一:[http://stackoverflow.com/questions/24994599/expected-output-is-not - 顯示/ 24994861#24994861](http://stackoverflow.com/questions/24994599/expected-output-is-not-displaying/24994861#24994861) – 2014-08-28 15:13:54