KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > wsm > wsdl > WSDLParser


1 package org.apache.beehive.wsm.wsdl;
2
3 /*
4  *
5  * Copyright 2001-2004 The Apache Software Foundation.
6  *
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  *
21  */

22
23 import java.io.IOException JavaDoc;
24 import java.io.InputStream JavaDoc;
25 import java.lang.reflect.Array JavaDoc;
26
27 import javax.xml.namespace.QName JavaDoc;
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 JavaDoc stream;
48     DefinitionsDocument defDoc;
49     TTypes tt;
50     Schema schema;
51     TService[] services;
52  
53     /**
54      * @param stream
55      * @throws IOException
56      * @throws XmlException
57      * @throws NoSuchFieldException
58      * @throws IllegalAccessException
59      */

60     public WSDLParser(InputStream JavaDoc stream) throws XmlException, IOException JavaDoc, IllegalAccessException JavaDoc, NoSuchFieldException JavaDoc {
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     /**
71      * @return Returns the schema.
72      */

73     public Schema getSchema() {
74         return schema;
75     }
76     
77     public String JavaDoc getSoapAddressLocation() throws IllegalAccessException JavaDoc {
78         String JavaDoc 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 JavaDoc e) {
88                     // just return null
89
}
90             }
91         }
92          return location;
93     }
94     
95     
96
97
98 }
99
Popular Tags