Friday, October 28, 2011

Parsing WSDL with Java

The Membrane SOA Model makes it easy to parse a WSDL. See listing 1 for an example. It parses a WSDL document and prints out the interface of the service with its operations.
01.package sample.wsdl;
02. 
03.import com.predic8.wsdl.*;
04. 
05.public class ListWSDLOperations {
06. 
07.public static void main(String[] args) {
08.WSDLParser parser = new WSDLParser();
09. 
10.Definitions defs = parser
12. 
13.for (PortType pt : defs.getPortTypes()) {
14.System.out.println(pt.getName());
15.for (Operation op : pt.getOperations()) {
16.System.out.println(" -" + op.getName());
17.}
18.}
19.}
20.}
Listing 1: ListWSDLOperations.java
In listing 2 you can see the output.
01.XWebBlogInterface
02.-LoadEntry
03.-LoadBlog
04.-LoadBlogPaged
05.-GetNewEntryID
06.-AddEntry
07.-UpdateEntry
08.-DeleteEntry
09.-LoadBlogByDateRange
10.-LoadBlogByDateRangePaged
11.-ProcessEntry
12.-AddReply
13.-UpdateReply
14.-DeleteReply
15.-ProcessReply
16.-GetNewReplyID
17.-LoadReply
 
http://www.membrane-soa.org/parse-wsdl-java-api.htm
 

1 comment:

  1. Hi, is there a way to get also the parameters of an operation?

    ReplyDelete

Blog Archive