当前位置: 动力学知识库 > 问答 > 编程问答 >

java - What is the best way to read a WSDL file?

问题描述:

Which method or class should I use to read a WSDL. I see there are multiple options for reading a file, but to be able to read the WSDL file and be able to change the element's name, the port, or host name, etc... might end up being difficult.

Here is an example of reading a file using BufferedReader.

 try {

BufferedReader br = new BufferedReader(new FileReader("default.wsdl"));

String line;

while((line = br.readLine()) != null){

if (line.contains("example"));

// this is where I would change the element's name, port, etc...

}

} catch (FileNotFoundException ex) {

Logger.getLogger(From_scratch.class.getName()).log(Level.SEVERE, null, ex);

} catch (IOException ex) {

Logger.getLogger(From_scratch.class.getName()).log(Level.SEVERE, null, ex);

}

}

The try/catch are used for protection of reading a file.

I was thinking of using a BufferedReader, while loop, and several if, else statements to look for what I want to change, but I am not sure how I write that so it would work. Can anyone give me an example? Or is there a way I could use readWSDL or another similar method specifically for reading a wsdl file?

网友答案:

You can treat a WSDL file as any other XML file. This will open up various solutions for your specific problem.

You can parse the wsdl using JDOM and then edit it by using the java Document api or using XPath, or you can transform the wsdl file using XSLT.

分享给朋友:
您可能感兴趣的文章:
随机阅读: