package example; import edu.uga.cs.lsdis.sawsdl.util.SAWSDLUtility; import edu.uga.cs.lsdis.sawsdl.*; import javax.xml.namespace.QName; import java.io.File; import java.util.Map; import java.util.List; /** * A complete example that demonstrates the use of the * SAWSDL API */ public class SAWSDLExampler { /** * The main method - assumes that there is only one argument * passed * Note - Needs Java 5 or higher * @param args * @throws Exception */ public static void main(String[] args) throws Exception{ if (args.length >1 || args.length <1){ System.out.println("Only one argument is accepted - that should be the file name!"); return; } // get the definition System.setProperty("javax.wsdl.factory.WSDLFactory", "edu.uga.cs.lsdis.sawsdl.impl.factory.WSDLFactoryImpl"); File wsdlURI = new File(args[0]); Definition definition = SAWSDLUtility.getDefinitionFromFile(wsdlURI); assert(definition!=null); System.out.println("Definition created Successfully!"); //get and print the porttypes and their relevant operations Map portTypes = definition.getPortTypes(); for (Object key:portTypes.keySet()){ PortType semanticPortType = definition.getSemanticPortType((QName)key); System.out.println("Porttype QName ->" + semanticPortType.getQName()); System.out.println("Model References ->" + semanticPortType.getModelReferences() ); List operations = semanticPortType.getOperations(); for (Object operation : operations) { System.out.println("Operation ->" + ((Operation) operation).getName()); } } //get and print the messages Map messages = definition.getMessages(); for (Object key:messages.keySet()){ Message semanticMessage = definition.getSemanticMessage((QName)key); System.out.println("Message QName ->" + semanticMessage.getQName()); Map parts = semanticMessage.getParts(); for (Object partKey : parts.keySet()) { Part semanticPart = semanticMessage.getSemanticPart((String) partKey); System.out.println("part ->" + semanticPart); System.out.println("part model references ->" + semanticPart.getModelReferences()); } } } }