我是Java新手。我想从java中读取wsdl。我有示例Northwind服务http://services.odata.org/Northwind/Northwind.svc/$元数据
我想读取上述url的输出xml。我试过不同的方法,但没用。

    URL oracle = new URL("http://services.odata.org/Northwind/Northwind.svc/$metadata");
    BufferedReader in = new BufferedReader(
    new InputStreamReader(oracle.openStream()));

    String inputLine;
    while ((inputLine = in.readLine()) != null)
        System.out.println(inputLine);
    in.close();

方法2
private static void readHttp() {
    Charset charset = Charset.forName("US-ASCII");
    Path file = Paths.get("http://services.odata.org/Northwind/Northwind.svc/$metadata");
    try (BufferedReader reader = Files.newBufferedReader(file, charset)) {
        String line = null;
        while ((line = reader.readLine()) != null) {
            System.out.println(line);
        }
    } catch (IOException x) {
        System.err.format("IOException: %s%n", x);
    }
}

有人能给我建议一下怎么做吗?
谢谢,

最佳答案

使用org.apache.commons.io.IOUtils

IOUtils.toString(new URL("http://services.odata.org/Northwind/Northwind.svc/"));

10-07 19:22