Source Code Cross Referenced for WsdlParser.java in  » IDE-Netbeans » identity.kit » org » netbeans » modules » identity » profile » ui » support » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » identity.kit » org.netbeans.modules.identity.profile.ui.support 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.identity.profile.ui.support;
043:
044:        /**
045:         * Custom parser for a wsdl file.
046:         *
047:         * Created on April 18, 2006, 1:29 PM
048:         *
049:         * @author Srividhya Narayanan
050:         */
051:
052:        import java.io.BufferedReader;
053:        import java.io.File;
054:        import java.io.FileReader;
055:        import java.io.IOException;
056:        import java.util.ArrayList;
057:        import javax.xml.parsers.SAXParserFactory;
058:        import javax.xml.parsers.SAXParser;
059:        import javax.xml.parsers.ParserConfigurationException;
060:        import org.xml.sax.Attributes;
061:        import org.xml.sax.helpers.DefaultHandler;
062:        import org.xml.sax.SAXException;
063:        import org.xml.sax.InputSource;
064:
065:        public class WsdlParser {
066:            public static final String TNS = "targetNamespace"; // NOI18N
067:            public static final String ADDRESS = "soapAddress"; // NOI18N
068:            public static final String PORT = "port"; // NOI18N
069:
070:            /** Creates a new instance of XMLParser */
071:            public WsdlParser() {
072:            }
073:
074:            public static WsdlData parseWSDLFile(File xmlFile, String svc)
075:                    throws IOException {
076:                BufferedReader br = new BufferedReader(new FileReader(xmlFile));
077:                InputSource is = new InputSource(br);
078:                try {
079:                    return parseWSDLFile(is, svc);
080:                } finally {
081:                    br.close();
082:                }
083:            }
084:
085:            public static WsdlData parseWSDLFile(InputSource xmlFile, String svc)
086:                    throws IOException {
087:                WsdlData wsdlData = null;
088:                try {
089:                    SAXParserFactory saxFactory = SAXParserFactory
090:                            .newInstance();
091:                    saxFactory.setNamespaceAware(true);
092:                    SAXParser parser = saxFactory.newSAXParser();
093:                    WsdlHandler handler = new WsdlHandler(svc);
094:                    parser.parse(xmlFile, handler);
095:                    wsdlData = handler.getWsdlData();
096:                } catch (ParserConfigurationException excp) {
097:                    IOException ioe = new IOException();
098:                    ioe.initCause(excp);
099:                    throw ioe;
100:                } catch (SAXException excp) {
101:                    IOException ioe = new IOException();
102:                    ioe.initCause(excp);
103:                    throw ioe;
104:                }
105:                return wsdlData;
106:            }
107:
108:            public static ArrayList getWsdlSvcNames(File xmlFile)
109:                    throws IOException {
110:                BufferedReader br = new BufferedReader(new FileReader(xmlFile));
111:                InputSource is = new InputSource(br);
112:                try {
113:                    return getWsdlSvcNames(is);
114:                } finally {
115:                    br.close();
116:                }
117:            }
118:
119:            public static ArrayList getWsdlSvcNames(InputSource xmlFile)
120:                    throws IOException {
121:                try {
122:                    SAXParserFactory saxFactory = SAXParserFactory
123:                            .newInstance();
124:                    saxFactory.setNamespaceAware(true);
125:                    SAXParser parser = saxFactory.newSAXParser();
126:                    SvcNameHandler handler = new SvcNameHandler();
127:                    parser.parse(xmlFile, handler);
128:                    return handler.getWsdlSvcNames();
129:                } catch (ParserConfigurationException excp) {
130:                    IOException ioe = new IOException();
131:                    ioe.initCause(excp);
132:                    throw ioe;
133:                } catch (SAXException excp) {
134:                    IOException ioe = new IOException();
135:                    ioe.initCause(excp);
136:                    throw ioe;
137:                }
138:            }
139:
140:            private static class WsdlHandler extends DefaultHandler {
141:                private static final String W3C_WSDL_SCHEMA = "http://schemas.xmlsoap.org/wsdl"; // NOI18N
142:                private static final String W3C_WSDL_SCHEMA_SLASH = "http://schemas.xmlsoap.org/wsdl/"; // NOI18N
143:
144:                private String svcName;
145:                WsdlData wsdlData = new WsdlData();
146:                boolean found = false;
147:
148:                public WsdlHandler(String svc) {
149:                    super ();
150:                    svcName = svc;
151:                }
152:
153:                public WsdlData getWsdlData() {
154:                    return wsdlData;
155:                }
156:
157:                public void startDocument() {
158:                }
159:
160:                public void endDocument() {
161:                }
162:
163:                public void startElement(String uri, String localName,
164:                        String qName, Attributes attributes) {
165:                    if (W3C_WSDL_SCHEMA.equals(uri)
166:                            || W3C_WSDL_SCHEMA_SLASH.equals(uri)) {
167:                        if (localName.equals("definitions")) { // NOI18N
168:                            wsdlData.setTargetNameSpace(attributes
169:                                    .getValue("targetNamespace")); // NOI18N
170:                        }
171:                        if (localName.equals("service")) { // NOI18N
172:                            if (svcName.equalsIgnoreCase(attributes
173:                                    .getValue("name"))) { // NOI18N
174:                                found = true;
175:                            }
176:                        }
177:                        if (found && localName.equals("port")) { // NOI18N
178:                            wsdlData.setPort(attributes.getValue("name")); // NOI18N
179:                        }
180:                    }
181:                    if (found && localName.equals("address")) { // NOI18N
182:                        wsdlData.setAddress(attributes.getValue("location")); // NOI18N
183:                        found = false;
184:                    }
185:                }
186:
187:                public void endElement(String uri, String localName,
188:                        String qName) {
189:                }
190:            }
191:
192:            private static class SvcNameHandler extends DefaultHandler {
193:                private static final String W3C_WSDL_SCHEMA = "http://schemas.xmlsoap.org/wsdl"; // NOI18N
194:                private static final String W3C_WSDL_SCHEMA_SLASH = "http://schemas.xmlsoap.org/wsdl/"; // NOI18N
195:
196:                ArrayList wsdlSvcNames = new ArrayList();
197:
198:                public SvcNameHandler() {
199:                    super ();
200:                }
201:
202:                public ArrayList getWsdlSvcNames() {
203:                    return wsdlSvcNames;
204:                }
205:
206:                public void startDocument() {
207:                }
208:
209:                public void endDocument() {
210:                }
211:
212:                public void startElement(String uri, String localName,
213:                        String qName, Attributes attributes) {
214:                    if (W3C_WSDL_SCHEMA.equals(uri)
215:                            || W3C_WSDL_SCHEMA_SLASH.equals(uri)) {
216:                        if (localName.equals("service")) { // NOI18N
217:                            String name = attributes.getValue("name"); // NOI18N
218:                            wsdlSvcNames.add(name);
219:                        }
220:                    }
221:                }
222:
223:                public void endElement(String uri, String localName,
224:                        String qName) {
225:                }
226:            }
227:        }
ww_w___.___ja_v___a_2___s_._c__o___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.