我是 Java 新手。我想从 java 中读取 wsdl。我有 sample 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/"));
关于java - 如何使用java从url读取wsdl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37841745/