我可以嵌套休息webservice或在webservice中打开一个链接

时间:2016-06-07 11:51:55

标签: java web-services restful-url

我试图从webservice打开一个链接可以这样做 或者我可以通过webservice调用webservice

@Path("/testUrl")
public class TestResource {

@GET
@Produces("text/plain")
public void callUrl() throws Exception  {

    open("http://www.goggle.com");
    open("http://www.goggle.com");
    Desktop desktop = java.awt.Desktop.getDesktop();
    URI url1 = new URI("http://www.google.com");
    URI url2 = new URI("http://www.yahoo.com");
    desktop.browse(url1);
    desktop.browse(url2);
}

private void open(String url) throws Exception  {
    URL siteURL = new URL(url);
    HttpURLConnection connection = (HttpURLConnection) siteURL.openConnection();
    connection.setRequestMethod("GET");
    connection.connect();

}
}

0 个答案:

没有答案