1 package org.apache.beehive.wsm.wsdl; 2 3 22 23 import java.io.IOException ; 24 import java.io.InputStream ; 25 import java.lang.reflect.Array ; 26 27 import javax.xml.namespace.QName ; 28 29 import org.xmlsoap.schemas.wsdl.DefinitionsDocument; 30 import org.xmlsoap.schemas.wsdl.TPort; 31 import org.xmlsoap.schemas.wsdl.TService; 32 import org.xmlsoap.schemas.wsdl.TTypes; 33 import org.xmlsoap.schemas.wsdl.soap.TAddress; 34 35 import org.apache.xmlbeans.SchemaType; 36 import org.apache.xmlbeans.XmlException; 37 import org.apache.xmlbeans.XmlObject; 38 39 import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument; 40 import org.apache.xmlbeans.impl.xb.xsdschema.TopLevelComplexType; 41 import org.apache.xmlbeans.impl.xb.xsdschema.TopLevelElement; 42 import org.apache.xmlbeans.impl.xb.xsdschema.TopLevelSimpleType; 43 44 public class WSDLParser { 45 46 47 InputStream stream; 48 DefinitionsDocument defDoc; 49 TTypes tt; 50 Schema schema; 51 TService[] services; 52 53 60 public WSDLParser(InputStream stream) throws XmlException, IOException , IllegalAccessException , NoSuchFieldException { 61 super(); 62 this.stream = stream; 63 64 defDoc = DefinitionsDocument.Factory.parse(stream); 65 tt = defDoc.getDefinitions().getTypesArray(0); 66 schema = new Schema(tt); 67 services = defDoc.getDefinitions().getServiceArray(); 68 69 } 70 73 public Schema getSchema() { 74 return schema; 75 } 76 77 public String getSoapAddressLocation() throws IllegalAccessException { 78 String location = null; 79 if (services.length > 0) { 80 TPort port = services[0].getPortArray(0); 81 if(null != port) { 82 try { 83 TAddress[] soapAddress = Utilities.selectChildren(port, TAddress.class); 84 if(soapAddress.length > 0) { 85 location = soapAddress[0].getLocation(); 86 } 87 } catch (NoSuchFieldException e) { 88 } 90 } 91 } 92 return location; 93 } 94 95 96 97 98 } 99 | Popular Tags |