0
全部,是否有可能將Jersey JSP模板響應重新路由到InputStream?
我使用Java/Jersey 1.9創建生成XML的Web服務。我使用JSP模板生成XML(顯式地通過Viewable類)。有什麼方法可以將JSP結果重新路由到本地InputStream進行進一步處理?目前我實際上是從另一種方法調用我自己的XML Web服務作爲http環回(localhost)。
感謝您的任何見解,
伊恩
@GET @Path("kml")
@Produces("application/vnd.google-earth.kml+xml")
public Viewable getKml(
@QueryParam("lat") double lat,
@QueryParam("lon") double lon,
@QueryParam("alt") double alt) {
overflights = new SatelliteOverflightModel(
context, new SatelliteOverflightModel.Params(lat, lon, alt)
).getOverflights();
return new Viewable("kml", this);
}
@GET @Path("kmz")
@Produces("application/vnd.google-earth.kmz")
public InputStream getKmz(@Context UriInfo uriInfo,
@QueryParam("lat") double lat,
@QueryParam("lon") double lon,
@QueryParam("alt") double alt)
throws IOException {
Client client = Client.create();
WebResource webr =
client.resource(uriInfo.getBaseUri()+"overflights/kml");
InputStream result =
webr.queryParams(uriInfo.getQueryParameters()).get(InputStream.class);
// Do something with result; e.g., add to ZIP archive and return
return result;
}
謝謝馬丁!我仍然在搞清楚澤西島並且喜歡它的多功能性,但是我花了數小時尋找這個沒有潛力的線索。您的兩個解決方案都讓人大開眼界,我會像您所建議的那樣首先嚐試過濾器。再次感謝。 – ianmstew