Source Code Cross Referenced for WSDLParser.java in  » 6.0-JDK-Modules » jax-ws-tools » com » sun » tools » ws » wsdl » parser » 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 » 6.0 JDK Modules » jax ws tools » com.sun.tools.ws.wsdl.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003:         * 
0004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005:         * 
0006:         * The contents of this file are subject to the terms of either the GNU
0007:         * General Public License Version 2 only ("GPL") or the Common Development
0008:         * and Distribution License("CDDL") (collectively, the "License").  You
0009:         * may not use this file except in compliance with the License. You can obtain
0010:         * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
0011:         * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
0012:         * language governing permissions and limitations under the License.
0013:         * 
0014:         * When distributing the software, include this License Header Notice in each
0015:         * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
0016:         * Sun designates this particular file as subject to the "Classpath" exception
0017:         * as provided by Sun in the GPL Version 2 section of the License file that
0018:         * accompanied this code.  If applicable, add the following below the License
0019:         * Header, with the fields enclosed by brackets [] replaced by your own
0020:         * identifying information: "Portions Copyrighted [year]
0021:         * [name of copyright owner]"
0022:         * 
0023:         * Contributor(s):
0024:         * 
0025:         * If you wish your version of this file to be governed by only the CDDL or
0026:         * only the GPL Version 2, indicate your decision by adding "[Contributor]
0027:         * elects to include this software in this distribution under the [CDDL or GPL
0028:         * Version 2] license."  If you don't indicate a single choice of license, a
0029:         * recipient has the option to distribute your version of this file under
0030:         * either the CDDL, the GPL Version 2 or to extend the choice of license to
0031:         * its licensees as provided above.  However, if you add GPL Version 2 code
0032:         * and therefore, elected the GPL Version 2 license, then the option applies
0033:         * only if the new code is made subject to such option by the copyright
0034:         * holder.
0035:         */
0036:
0037:        package com.sun.tools.ws.wsdl.parser;
0038:
0039:        import com.sun.tools.ws.api.wsdl.TWSDLExtensible;
0040:        import com.sun.tools.ws.api.wsdl.TWSDLExtensionHandler;
0041:        import com.sun.tools.ws.resources.WsdlMessages;
0042:        import com.sun.tools.ws.util.xml.XmlUtil;
0043:        import com.sun.tools.ws.wscompile.ErrorReceiverFilter;
0044:        import com.sun.tools.ws.wscompile.WsimportOptions;
0045:        import com.sun.tools.ws.wsdl.document.Binding;
0046:        import com.sun.tools.ws.wsdl.document.BindingFault;
0047:        import com.sun.tools.ws.wsdl.document.BindingInput;
0048:        import com.sun.tools.ws.wsdl.document.BindingOperation;
0049:        import com.sun.tools.ws.wsdl.document.BindingOutput;
0050:        import com.sun.tools.ws.wsdl.document.Definitions;
0051:        import com.sun.tools.ws.wsdl.document.Documentation;
0052:        import com.sun.tools.ws.wsdl.document.Fault;
0053:        import com.sun.tools.ws.wsdl.document.Import;
0054:        import com.sun.tools.ws.wsdl.document.Input;
0055:        import com.sun.tools.ws.wsdl.document.Message;
0056:        import com.sun.tools.ws.wsdl.document.MessagePart;
0057:        import com.sun.tools.ws.wsdl.document.Operation;
0058:        import com.sun.tools.ws.wsdl.document.OperationStyle;
0059:        import com.sun.tools.ws.wsdl.document.Output;
0060:        import com.sun.tools.ws.wsdl.document.Port;
0061:        import com.sun.tools.ws.wsdl.document.PortType;
0062:        import com.sun.tools.ws.wsdl.document.Service;
0063:        import com.sun.tools.ws.wsdl.document.WSDLConstants;
0064:        import com.sun.tools.ws.wsdl.document.WSDLDocument;
0065:        import com.sun.tools.ws.wsdl.document.jaxws.JAXWSBindingsConstants;
0066:        import com.sun.tools.ws.wsdl.document.schema.SchemaConstants;
0067:        import com.sun.tools.ws.wsdl.document.schema.SchemaKinds;
0068:        import com.sun.tools.ws.wsdl.framework.Entity;
0069:        import com.sun.tools.ws.wsdl.framework.ParserListener;
0070:        import com.sun.tools.ws.wsdl.framework.TWSDLParserContextImpl;
0071:        import com.sun.xml.ws.util.ServiceFinder;
0072:        import org.w3c.dom.Attr;
0073:        import org.w3c.dom.Document;
0074:        import org.w3c.dom.Element;
0075:        import org.w3c.dom.Node;
0076:        import org.w3c.dom.NodeList;
0077:        import org.xml.sax.InputSource;
0078:        import org.xml.sax.Locator;
0079:        import org.xml.sax.SAXException;
0080:
0081:        import java.io.IOException;
0082:        import java.util.ArrayList;
0083:        import java.util.HashMap;
0084:        import java.util.Iterator;
0085:        import java.util.Map;
0086:
0087:        /**
0088:         * A parser for WSDL documents. This parser is used only at the tool time.
0089:         * Extensions should extend TWSDLExtensionHandler, so that it will be called during
0090:         * parsing wsdl to handle wsdl extenisbility elements. Generally these extensions
0091:         * will effect the artifacts generated during WSDL processing.
0092:         *
0093:         * @see com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser which will be used for WSDL parsing
0094:         * at runtime.
0095:         *
0096:         * @author WS Development Team
0097:         */
0098:        public class WSDLParser {
0099:            private final ErrorReceiverFilter errReceiver;
0100:            private WsimportOptions options;
0101:            private MetadataFinder forest;
0102:
0103:            //wsdl extension handlers
0104:            private final Map extensionHandlers;
0105:
0106:            private ArrayList<ParserListener> listeners;
0107:
0108:            public WSDLParser(WsimportOptions options,
0109:                    ErrorReceiverFilter errReceiver) {
0110:                this .extensionHandlers = new HashMap();
0111:                this .options = options;
0112:                this .errReceiver = errReceiver;
0113:
0114:                // register handlers for default extensions
0115:                register(new SOAPExtensionHandler(extensionHandlers));
0116:                register(new HTTPExtensionHandler(extensionHandlers));
0117:                register(new MIMEExtensionHandler(extensionHandlers));
0118:                register(new JAXWSBindingExtensionHandler(extensionHandlers));
0119:                register(new SOAP12ExtensionHandler(extensionHandlers));
0120:                register(new MemberSubmissionAddressingExtensionHandler(
0121:                        extensionHandlers, errReceiver));
0122:                register(new W3CAddressingExtensionHandler(extensionHandlers,
0123:                        errReceiver));
0124:
0125:                for (TWSDLExtensionHandler te : ServiceFinder
0126:                        .find(TWSDLExtensionHandler.class)) {
0127:                    register(te);
0128:                }
0129:
0130:            }
0131:
0132:            private void register(TWSDLExtensionHandler h) {
0133:                extensionHandlers.put(h.getNamespaceURI(), h);
0134:            }
0135:
0136:            public void addParserListener(ParserListener l) {
0137:                if (listeners == null) {
0138:                    listeners = new ArrayList<ParserListener>();
0139:                }
0140:                listeners.add(l);
0141:            }
0142:
0143:            public WSDLDocument parse() throws SAXException, IOException {
0144:                forest = new MetadataFinder(new WSDLInternalizationLogic(),
0145:                        options, errReceiver);
0146:                forest.parseWSDL();
0147:                if (forest.isMexMetadata)
0148:                    errReceiver.reset();
0149:
0150:                // parse external binding files
0151:                for (InputSource value : options.getWSDLBindings()) {
0152:                    errReceiver.pollAbort();
0153:                    Document root = forest.parse(value, false);
0154:                    if (root == null)
0155:                        continue; // error must have been reported
0156:                    Element binding = root.getDocumentElement();
0157:                    if (!fixNull(binding.getNamespaceURI()).equals(
0158:                            JAXWSBindingsConstants.NS_JAXWS_BINDINGS)
0159:                            || !binding.getLocalName().equals("bindings")) {
0160:                        errReceiver.error(forest.locatorTable
0161:                                .getStartLocation(binding), WsdlMessages
0162:                                .PARSER_NOT_A_BINDING_FILE(binding
0163:                                        .getNamespaceURI(), binding
0164:                                        .getLocalName()));
0165:                        continue;
0166:                    }
0167:
0168:                    NodeList nl = binding.getElementsByTagNameNS(
0169:                            "http://java.sun.com/xml/ns/javaee",
0170:                            "handler-chains");
0171:                    for (int i = 0; i < nl.getLength(); i++) {
0172:                        options.addHandlerChainConfiguration((Element) nl
0173:                                .item(i));
0174:                    }
0175:
0176:                }
0177:                return buildWSDLDocument();
0178:            }
0179:
0180:            private String fixNull(String s) {
0181:                if (s == null)
0182:                    return "";
0183:                else
0184:                    return s;
0185:            }
0186:
0187:            public MetadataFinder getDOMForest() {
0188:                return forest;
0189:            }
0190:
0191:            private WSDLDocument buildWSDLDocument() {
0192:                /**
0193:                 * Currently we are working off first WSDL document
0194:                 * TODO: add support of creating WSDLDocument from collection of WSDL documents
0195:                 */
0196:
0197:                String location = forest.getRootWSDL();
0198:
0199:                //It means that WSDL is not found, an error might have been reported, lets try to recover
0200:                if (location == null)
0201:                    return null;
0202:
0203:                Document root = forest.get(location);
0204:
0205:                if (root == null)
0206:                    return null;
0207:
0208:                WSDLDocument document = new WSDLDocument(forest, errReceiver);
0209:                document.setSystemId(location);
0210:                TWSDLParserContextImpl context = new TWSDLParserContextImpl(
0211:                        forest, document, listeners, errReceiver);
0212:
0213:                Definitions definitions = parseDefinitions(context, root);
0214:                document.setDefinitions(definitions);
0215:                return document;
0216:            }
0217:
0218:            private Definitions parseDefinitions(
0219:                    TWSDLParserContextImpl context, Document root) {
0220:                context.pushWSDLLocation();
0221:                context.setWSDLLocation(context.getDocument().getSystemId());
0222:
0223:                new Internalizer(forest, options, errReceiver).transform();
0224:
0225:                //print the wsdl
0226:                //        try{
0227:                //            forest.dump(System.out);
0228:                //        }catch(IOException e){
0229:                //            e.printStackTrace();
0230:                //        }
0231:
0232:                Definitions definitions = parseDefinitionsNoImport(context,
0233:                        root);
0234:                if (definitions == null) {
0235:                    Locator locator = forest.locatorTable.getStartLocation(root
0236:                            .getDocumentElement());
0237:                    errReceiver.error(locator, WsdlMessages
0238:                            .PARSING_NOT_AWSDL(locator.getSystemId()));
0239:
0240:                }
0241:                processImports(context);
0242:                context.popWSDLLocation();
0243:                return definitions;
0244:            }
0245:
0246:            private void processMexDocs(TWSDLParserContextImpl context) {
0247:                for (String location : forest.listSystemIDs()) {
0248:                    if (!context.getDocument().isImportedDocument(location)) {
0249:                        Document doc = forest.get(location);
0250:                        if (doc == null)
0251:                            continue;
0252:                        Definitions importedDefinitions = parseDefinitionsNoImport(
0253:                                context, doc);
0254:                        if (importedDefinitions == null)
0255:                            continue;
0256:                        context.getDocument().addImportedEntity(
0257:                                importedDefinitions);
0258:                        context.getDocument().addImportedDocument(location);
0259:                    }
0260:                }
0261:            }
0262:
0263:            private void processImports(TWSDLParserContextImpl context) {
0264:                for (String location : forest.getExternalReferences()) {
0265:                    if (!context.getDocument().isImportedDocument(location)) {
0266:                        Document doc = forest.get(location);
0267:                        if (doc == null)
0268:                            continue;
0269:                        Definitions importedDefinitions = parseDefinitionsNoImport(
0270:                                context, doc);
0271:                        if (importedDefinitions == null)
0272:                            continue;
0273:                        context.getDocument().addImportedEntity(
0274:                                importedDefinitions);
0275:                        context.getDocument().addImportedDocument(location);
0276:                    }
0277:                }
0278:            }
0279:
0280:            private Definitions parseDefinitionsNoImport(
0281:                    TWSDLParserContextImpl context, Document doc) {
0282:                Element e = doc.getDocumentElement();
0283:                //at this poinjt we expect a wsdl or schema document to be fully qualified
0284:                if (e.getNamespaceURI() == null
0285:                        || (!e.getNamespaceURI().equals(WSDLConstants.NS_WSDL) || !e
0286:                                .getLocalName().equals("definitions"))) {
0287:                    return null;
0288:                }
0289:                context.push();
0290:                context.registerNamespaces(e);
0291:
0292:                Definitions definitions = new Definitions(
0293:                        context.getDocument(), forest.locatorTable
0294:                                .getStartLocation(e));
0295:                String name = XmlUtil
0296:                        .getAttributeOrNull(e, Constants.ATTR_NAME);
0297:                definitions.setName(name);
0298:
0299:                String targetNamespaceURI = XmlUtil.getAttributeOrNull(e,
0300:                        Constants.ATTR_TARGET_NAMESPACE);
0301:
0302:                definitions.setTargetNamespaceURI(targetNamespaceURI);
0303:
0304:                boolean gotDocumentation = false;
0305:                boolean gotTypes = false;
0306:
0307:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
0308:                    Element e2 = Util.nextElement(iter);
0309:                    if (e2 == null)
0310:                        break;
0311:
0312:                    if (XmlUtil.matchesTagNS(e2,
0313:                            WSDLConstants.QNAME_DOCUMENTATION)) {
0314:                        if (gotDocumentation) {
0315:                            errReceiver.error(forest.locatorTable
0316:                                    .getStartLocation(e2), WsdlMessages
0317:                                    .PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e
0318:                                            .getLocalName()));
0319:                            return null;
0320:                        }
0321:                        gotDocumentation = true;
0322:                        if (definitions.getDocumentation() == null)
0323:                            definitions
0324:                                    .setDocumentation(getDocumentationFor(e2));
0325:                    } else if (XmlUtil.matchesTagNS(e2,
0326:                            WSDLConstants.QNAME_TYPES)) {
0327:                        if (gotTypes && !options.isExtensionMode()) {
0328:                            errReceiver
0329:                                    .error(
0330:                                            forest.locatorTable
0331:                                                    .getStartLocation(e2),
0332:                                            WsdlMessages
0333:                                                    .PARSING_ONLY_ONE_TYPES_ALLOWED(Constants.TAG_DEFINITIONS));
0334:                            return null;
0335:                        }
0336:                        gotTypes = true;
0337:                        //add all the wsdl:type elements to latter make a list of all the schema elements
0338:                        // that will be needed to create jaxb model
0339:                        if (!options.isExtensionMode())
0340:                            validateSchemaImports(e2);
0341:                    } else if (XmlUtil.matchesTagNS(e2,
0342:                            WSDLConstants.QNAME_MESSAGE)) {
0343:                        Message message = parseMessage(context, definitions, e2);
0344:                        definitions.add(message);
0345:                    } else if (XmlUtil.matchesTagNS(e2,
0346:                            WSDLConstants.QNAME_PORT_TYPE)) {
0347:                        PortType portType = parsePortType(context, definitions,
0348:                                e2);
0349:                        definitions.add(portType);
0350:                    } else if (XmlUtil.matchesTagNS(e2,
0351:                            WSDLConstants.QNAME_BINDING)) {
0352:                        Binding binding = parseBinding(context, definitions, e2);
0353:                        definitions.add(binding);
0354:                    } else if (XmlUtil.matchesTagNS(e2,
0355:                            WSDLConstants.QNAME_SERVICE)) {
0356:                        Service service = parseService(context, definitions, e2);
0357:                        definitions.add(service);
0358:                    } else if (XmlUtil.matchesTagNS(e2,
0359:                            WSDLConstants.QNAME_IMPORT)) {
0360:                        definitions.add(parseImport(context, definitions, e2));
0361:                    } else if (XmlUtil.matchesTagNS(e2,
0362:                            SchemaConstants.QNAME_IMPORT)) {
0363:                        errReceiver.warning(forest.locatorTable
0364:                                .getStartLocation(e2), WsdlMessages
0365:                                .WARNING_WSI_R_2003());
0366:                    } else {
0367:                        // possible extensibility element -- must live outside the WSDL namespace
0368:                        checkNotWsdlElement(e2);
0369:                        if (!handleExtension(context, definitions, e2)) {
0370:                            checkNotWsdlRequired(e2);
0371:                        }
0372:                    }
0373:                }
0374:
0375:                context.pop();
0376:                context.fireDoneParsingEntity(WSDLConstants.QNAME_DEFINITIONS,
0377:                        definitions);
0378:                return definitions;
0379:            }
0380:
0381:            private Message parseMessage(TWSDLParserContextImpl context,
0382:                    Definitions definitions, Element e) {
0383:                context.push();
0384:                context.registerNamespaces(e);
0385:                Message message = new Message(definitions, forest.locatorTable
0386:                        .getStartLocation(e), errReceiver);
0387:                String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME);
0388:                message.setName(name);
0389:
0390:                boolean gotDocumentation = false;
0391:
0392:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
0393:                    Element e2 = Util.nextElement(iter);
0394:                    if (e2 == null)
0395:                        break;
0396:
0397:                    if (XmlUtil.matchesTagNS(e2,
0398:                            WSDLConstants.QNAME_DOCUMENTATION)) {
0399:                        if (gotDocumentation) {
0400:                            Util.fail("parsing.onlyOneDocumentationAllowed", e
0401:                                    .getLocalName());
0402:                        }
0403:                        gotDocumentation = true;
0404:                        message.setDocumentation(getDocumentationFor(e2));
0405:                    } else if (XmlUtil.matchesTagNS(e2,
0406:                            WSDLConstants.QNAME_PART)) {
0407:                        MessagePart part = parseMessagePart(context, e2);
0408:                        message.add(part);
0409:                    } else {
0410:                        Util.fail("parsing.invalidElement", e2.getTagName(), e2
0411:                                .getNamespaceURI());
0412:                    }
0413:                }
0414:
0415:                context.pop();
0416:                context.fireDoneParsingEntity(WSDLConstants.QNAME_MESSAGE,
0417:                        message);
0418:                return message;
0419:            }
0420:
0421:            private MessagePart parseMessagePart(
0422:                    TWSDLParserContextImpl context, Element e) {
0423:                context.push();
0424:                context.registerNamespaces(e);
0425:                MessagePart part = new MessagePart(forest.locatorTable
0426:                        .getStartLocation(e));
0427:                String partName = Util.getRequiredAttribute(e,
0428:                        Constants.ATTR_NAME);
0429:                part.setName(partName);
0430:
0431:                String elementAttr = XmlUtil.getAttributeOrNull(e,
0432:                        Constants.ATTR_ELEMENT);
0433:                String typeAttr = XmlUtil.getAttributeOrNull(e,
0434:                        Constants.ATTR_TYPE);
0435:
0436:                if (elementAttr != null) {
0437:                    if (typeAttr != null) {
0438:                        errReceiver
0439:                                .error(
0440:                                        context.getLocation(e),
0441:                                        WsdlMessages
0442:                                                .PARSING_ONLY_ONE_OF_ELEMENT_OR_TYPE_REQUIRED(partName));
0443:
0444:                    }
0445:
0446:                    part.setDescriptor(context.translateQualifiedName(context
0447:                            .getLocation(e), elementAttr));
0448:                    part.setDescriptorKind(SchemaKinds.XSD_ELEMENT);
0449:                } else if (typeAttr != null) {
0450:                    part.setDescriptor(context.translateQualifiedName(context
0451:                            .getLocation(e), typeAttr));
0452:                    part.setDescriptorKind(SchemaKinds.XSD_TYPE);
0453:                } else {
0454:                    // XXX-NOTE - this is wrong; for extensibility purposes,
0455:                    // any attribute can be specified on a <part> element, so
0456:                    // we need to put an extensibility hook here
0457:                    errReceiver
0458:                            .warning(
0459:                                    forest.locatorTable.getStartLocation(e),
0460:                                    WsdlMessages
0461:                                            .PARSING_ELEMENT_OR_TYPE_REQUIRED(partName));
0462:                }
0463:
0464:                context.pop();
0465:                context.fireDoneParsingEntity(WSDLConstants.QNAME_PART, part);
0466:                return part;
0467:            }
0468:
0469:            private PortType parsePortType(TWSDLParserContextImpl context,
0470:                    Definitions definitions, Element e) {
0471:                context.push();
0472:                context.registerNamespaces(e);
0473:                PortType portType = new PortType(definitions,
0474:                        forest.locatorTable.getStartLocation(e), errReceiver);
0475:                String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME);
0476:                portType.setName(name);
0477:
0478:                boolean gotDocumentation = false;
0479:
0480:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
0481:                    Element e2 = Util.nextElement(iter);
0482:                    if (e2 == null)
0483:                        break;
0484:
0485:                    if (XmlUtil.matchesTagNS(e2,
0486:                            WSDLConstants.QNAME_DOCUMENTATION)) {
0487:                        if (gotDocumentation) {
0488:                            errReceiver.error(forest.locatorTable
0489:                                    .getStartLocation(e), WsdlMessages
0490:                                    .PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e
0491:                                            .getLocalName()));
0492:                        }
0493:                        gotDocumentation = true;
0494:                        if (portType.getDocumentation() == null)
0495:                            portType.setDocumentation(getDocumentationFor(e2));
0496:                    } else if (XmlUtil.matchesTagNS(e2,
0497:                            WSDLConstants.QNAME_OPERATION)) {
0498:                        Operation op = parsePortTypeOperation(context, e2);
0499:                        op.setParent(portType);
0500:                        portType.add(op);
0501:                    } else {
0502:                        // possible extensibility element -- must live outside the WSDL namespace
0503:                        checkNotWsdlElement(e2);
0504:                        if (!handleExtension(context, portType, e2)) {
0505:                            checkNotWsdlRequired(e2);
0506:                        }
0507:                    }/*else {
0508:                                    Util.fail(
0509:                                        "parsing.invalidElement",
0510:                                        e2.getTagName(),
0511:                                        e2.getNamespaceURI());
0512:                                }*/
0513:                }
0514:
0515:                context.pop();
0516:                context.fireDoneParsingEntity(WSDLConstants.QNAME_PORT_TYPE,
0517:                        portType);
0518:                return portType;
0519:            }
0520:
0521:            private Operation parsePortTypeOperation(
0522:                    TWSDLParserContextImpl context, Element e) {
0523:                context.push();
0524:                context.registerNamespaces(e);
0525:
0526:                Operation operation = new Operation(forest.locatorTable
0527:                        .getStartLocation(e));
0528:                String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME);
0529:                operation.setName(name);
0530:                String parameterOrderAttr = XmlUtil.getAttributeOrNull(e,
0531:                        Constants.ATTR_PARAMETER_ORDER);
0532:                operation.setParameterOrder(parameterOrderAttr);
0533:
0534:                boolean gotDocumentation = false;
0535:
0536:                boolean gotInput = false;
0537:                boolean gotOutput = false;
0538:                boolean gotFault = false;
0539:                boolean inputBeforeOutput = false;
0540:
0541:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
0542:                    Element e2 = Util.nextElement(iter);
0543:                    if (e2 == null)
0544:                        break;
0545:
0546:                    if (XmlUtil.matchesTagNS(e2,
0547:                            WSDLConstants.QNAME_DOCUMENTATION)) {
0548:                        if (gotDocumentation) {
0549:                            errReceiver.error(forest.locatorTable
0550:                                    .getStartLocation(e2), WsdlMessages
0551:                                    .PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e2
0552:                                            .getLocalName()));
0553:                        }
0554:                        gotDocumentation = true;
0555:                        if (operation.getDocumentation() == null)
0556:                            operation.setDocumentation(getDocumentationFor(e2));
0557:                    } else if (XmlUtil.matchesTagNS(e2,
0558:                            WSDLConstants.QNAME_INPUT)) {
0559:                        if (gotInput) {
0560:                            errReceiver.error(forest.locatorTable
0561:                                    .getStartLocation(e), WsdlMessages
0562:                                    .PARSING_TOO_MANY_ELEMENTS(
0563:                                            Constants.TAG_INPUT,
0564:                                            Constants.TAG_OPERATION, name));
0565:                        }
0566:
0567:                        context.push();
0568:                        context.registerNamespaces(e2);
0569:                        Input input = new Input(forest.locatorTable
0570:                                .getStartLocation(e2), errReceiver);
0571:                        input.setParent(operation);
0572:                        String messageAttr = Util.getRequiredAttribute(e2,
0573:                                Constants.ATTR_MESSAGE);
0574:                        input.setMessage(context.translateQualifiedName(context
0575:                                .getLocation(e2), messageAttr));
0576:                        String nameAttr = XmlUtil.getAttributeOrNull(e2,
0577:                                Constants.ATTR_NAME);
0578:                        input.setName(nameAttr);
0579:                        operation.setInput(input);
0580:                        gotInput = true;
0581:                        if (gotOutput) {
0582:                            inputBeforeOutput = false;
0583:                        }
0584:
0585:                        // check for extensiblity attributes
0586:                        for (Iterator iter2 = XmlUtil.getAllAttributes(e2); iter2
0587:                                .hasNext();) {
0588:                            Attr e3 = (Attr) iter2.next();
0589:                            if (e3.getLocalName()
0590:                                    .equals(Constants.ATTR_MESSAGE)
0591:                                    || e3.getLocalName().equals(
0592:                                            Constants.ATTR_NAME))
0593:                                continue;
0594:
0595:                            // possible extensibility element -- must live outside the WSDL namespace
0596:                            checkNotWsdlAttribute(e3);
0597:                            if (!handleExtension(context, input, e3, e2)) {
0598:                                // ignore the extensiblity attribute
0599:                                // TODO throw a WARNING
0600:                            }
0601:                        }
0602:
0603:                        // verify that there is at most one child element and it is a documentation element
0604:                        boolean gotDocumentation2 = false;
0605:                        for (Iterator iter2 = XmlUtil.getAllChildren(e2); iter2
0606:                                .hasNext();) {
0607:                            Element e3 = Util.nextElement(iter2);
0608:                            if (e3 == null)
0609:                                break;
0610:
0611:                            if (XmlUtil.matchesTagNS(e3,
0612:                                    WSDLConstants.QNAME_DOCUMENTATION)) {
0613:                                if (gotDocumentation2) {
0614:                                    errReceiver
0615:                                            .error(
0616:                                                    forest.locatorTable
0617:                                                            .getStartLocation(e),
0618:                                                    WsdlMessages
0619:                                                            .PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e
0620:                                                                    .getLocalName()));
0621:                                }
0622:                                gotDocumentation2 = true;
0623:                                input.setDocumentation(getDocumentationFor(e3));
0624:                            } else {
0625:                                errReceiver.error(forest.locatorTable
0626:                                        .getStartLocation(e3), WsdlMessages
0627:                                        .PARSING_INVALID_ELEMENT(e3
0628:                                                .getTagName(), e3
0629:                                                .getNamespaceURI()));
0630:                            }
0631:                        }
0632:                        context.pop();
0633:                    } else if (XmlUtil.matchesTagNS(e2,
0634:                            WSDLConstants.QNAME_OUTPUT)) {
0635:                        if (gotOutput) {
0636:                            errReceiver.error(forest.locatorTable
0637:                                    .getStartLocation(e), WsdlMessages
0638:                                    .PARSING_TOO_MANY_ELEMENTS(
0639:                                            Constants.TAG_INPUT,
0640:                                            Constants.TAG_OPERATION, name));
0641:                        }
0642:
0643:                        context.push();
0644:                        context.registerNamespaces(e2);
0645:                        Output output = new Output(forest.locatorTable
0646:                                .getStartLocation(e2), errReceiver);
0647:                        output.setParent(operation);
0648:                        String messageAttr = Util.getRequiredAttribute(e2,
0649:                                Constants.ATTR_MESSAGE);
0650:                        output.setMessage(context.translateQualifiedName(
0651:                                context.getLocation(e2), messageAttr));
0652:                        String nameAttr = XmlUtil.getAttributeOrNull(e2,
0653:                                Constants.ATTR_NAME);
0654:                        output.setName(nameAttr);
0655:                        operation.setOutput(output);
0656:                        gotOutput = true;
0657:                        if (gotInput) {
0658:                            inputBeforeOutput = true;
0659:                        }
0660:
0661:                        // check for extensiblity attributes
0662:                        for (Iterator iter2 = XmlUtil.getAllAttributes(e2); iter2
0663:                                .hasNext();) {
0664:                            Attr e3 = (Attr) iter2.next();
0665:                            if (e3.getLocalName()
0666:                                    .equals(Constants.ATTR_MESSAGE)
0667:                                    || e3.getLocalName().equals(
0668:                                            Constants.ATTR_NAME))
0669:                                continue;
0670:
0671:                            // possible extensibility element -- must live outside the WSDL namespace
0672:                            checkNotWsdlAttribute(e3);
0673:                            if (!handleExtension(context, output, e3, e2)) {
0674:                                // ignore the extensiblity attribute
0675:                                // TODO throw a WARNING
0676:                            }
0677:                        }
0678:
0679:                        // verify that there is at most one child element and it is a documentation element
0680:                        boolean gotDocumentation2 = false;
0681:                        for (Iterator iter2 = XmlUtil.getAllChildren(e2); iter2
0682:                                .hasNext();) {
0683:                            Element e3 = Util.nextElement(iter2);
0684:                            if (e3 == null)
0685:                                break;
0686:
0687:                            if (XmlUtil.matchesTagNS(e3,
0688:                                    WSDLConstants.QNAME_DOCUMENTATION)) {
0689:                                if (gotDocumentation2) {
0690:                                    errReceiver
0691:                                            .error(
0692:                                                    forest.locatorTable
0693:                                                            .getStartLocation(e),
0694:                                                    WsdlMessages
0695:                                                            .PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e
0696:                                                                    .getLocalName()));
0697:                                }
0698:                                gotDocumentation2 = true;
0699:                                output
0700:                                        .setDocumentation(getDocumentationFor(e3));
0701:                            } else {
0702:                                errReceiver.error(forest.locatorTable
0703:                                        .getStartLocation(e3), WsdlMessages
0704:                                        .PARSING_INVALID_ELEMENT(e3
0705:                                                .getTagName(), e3
0706:                                                .getNamespaceURI()));
0707:                            }
0708:                        }
0709:                        context.pop();
0710:                    } else if (XmlUtil.matchesTagNS(e2,
0711:                            WSDLConstants.QNAME_FAULT)) {
0712:                        context.push();
0713:                        context.registerNamespaces(e2);
0714:                        Fault fault = new Fault(forest.locatorTable
0715:                                .getStartLocation(e2));
0716:                        fault.setParent(operation);
0717:                        String messageAttr = Util.getRequiredAttribute(e2,
0718:                                Constants.ATTR_MESSAGE);
0719:                        fault.setMessage(context.translateQualifiedName(context
0720:                                .getLocation(e2), messageAttr));
0721:                        String nameAttr = XmlUtil.getAttributeOrNull(e2,
0722:                                Constants.ATTR_NAME);
0723:                        fault.setName(nameAttr);
0724:                        operation.addFault(fault);
0725:                        gotFault = true;
0726:
0727:                        // check for extensiblity attributes
0728:                        for (Iterator iter2 = XmlUtil.getAllAttributes(e2); iter2
0729:                                .hasNext();) {
0730:                            Attr e3 = (Attr) iter2.next();
0731:                            if (e3.getLocalName()
0732:                                    .equals(Constants.ATTR_MESSAGE)
0733:                                    || e3.getLocalName().equals(
0734:                                            Constants.ATTR_NAME))
0735:                                continue;
0736:
0737:                            // possible extensibility element -- must live outside the WSDL namespace
0738:                            checkNotWsdlAttribute(e3);
0739:                            if (!handleExtension(context, fault, e3, e2)) {
0740:                                // ignore the extensiblity attribute
0741:                                // TODO throw a WARNING
0742:                            }
0743:                        }
0744:
0745:                        // verify that there is at most one child element and it is a documentation element
0746:                        boolean gotDocumentation2 = false;
0747:                        for (Iterator iter2 = XmlUtil.getAllChildren(e2); iter2
0748:                                .hasNext();) {
0749:                            Element e3 = Util.nextElement(iter2);
0750:                            if (e3 == null)
0751:                                break;
0752:
0753:                            if (XmlUtil.matchesTagNS(e3,
0754:                                    WSDLConstants.QNAME_DOCUMENTATION)) {
0755:                                if (gotDocumentation2) {
0756:                                    errReceiver
0757:                                            .error(
0758:                                                    forest.locatorTable
0759:                                                            .getStartLocation(e),
0760:                                                    WsdlMessages
0761:                                                            .PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e
0762:                                                                    .getLocalName()));
0763:                                }
0764:                                gotDocumentation2 = true;
0765:                                if (fault.getDocumentation() == null)
0766:                                    fault
0767:                                            .setDocumentation(getDocumentationFor(e3));
0768:                            } else {
0769:                                // possible extensibility element -- must live outside the WSDL namespace
0770:                                checkNotWsdlElement(e3);
0771:                                if (!handleExtension(context, fault, e3)) {
0772:                                    checkNotWsdlRequired(e3);
0773:                                }
0774:                            }/*else {
0775:                                                    Util.fail(
0776:                                                        "parsing.invalidElement",
0777:                                                        e3.getTagName(),
0778:                                                        e3.getNamespaceURI());
0779:                                                }*/
0780:                        }
0781:                        context.pop();
0782:                    } else {
0783:                        // possible extensibility element -- must live outside the WSDL namespace
0784:                        checkNotWsdlElement(e2);
0785:                        if (!handleExtension(context, operation, e2)) {
0786:                            checkNotWsdlRequired(e2);
0787:                        }
0788:                    }/*else {
0789:                                    Util.fail(
0790:                                        "parsing.invalidElement",
0791:                                        e2.getTagName(),
0792:                                        e2.getNamespaceURI());
0793:                                }*/
0794:                }
0795:
0796:                if (gotInput && !gotOutput && !gotFault) {
0797:                    operation.setStyle(OperationStyle.ONE_WAY);
0798:                } else if (gotInput && gotOutput && inputBeforeOutput) {
0799:                    operation.setStyle(OperationStyle.REQUEST_RESPONSE);
0800:                } else if (gotInput && gotOutput && !inputBeforeOutput) {
0801:                    operation.setStyle(OperationStyle.SOLICIT_RESPONSE);
0802:                } else if (gotOutput && !gotInput && !gotFault) {
0803:                    operation.setStyle(OperationStyle.NOTIFICATION);
0804:                } else {
0805:                    errReceiver.error(forest.locatorTable.getStartLocation(e),
0806:                            WsdlMessages.PARSING_INVALID_OPERATION_STYLE(name));
0807:                }
0808:
0809:                context.pop();
0810:                context.fireDoneParsingEntity(WSDLConstants.QNAME_OPERATION,
0811:                        operation);
0812:                return operation;
0813:            }
0814:
0815:            private Binding parseBinding(TWSDLParserContextImpl context,
0816:                    Definitions definitions, Element e) {
0817:                context.push();
0818:                context.registerNamespaces(e);
0819:                Binding binding = new Binding(definitions, forest.locatorTable
0820:                        .getStartLocation(e), errReceiver);
0821:                String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME);
0822:                binding.setName(name);
0823:                String typeAttr = Util.getRequiredAttribute(e,
0824:                        Constants.ATTR_TYPE);
0825:                binding.setPortType(context.translateQualifiedName(context
0826:                        .getLocation(e), typeAttr));
0827:
0828:                boolean gotDocumentation = false;
0829:
0830:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
0831:                    Element e2 = Util.nextElement(iter);
0832:                    if (e2 == null)
0833:                        break;
0834:
0835:                    if (XmlUtil.matchesTagNS(e2,
0836:                            WSDLConstants.QNAME_DOCUMENTATION)) {
0837:                        if (gotDocumentation) {
0838:                            errReceiver.error(forest.locatorTable
0839:                                    .getStartLocation(e), WsdlMessages
0840:                                    .PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e
0841:                                            .getLocalName()));
0842:                        }
0843:                        gotDocumentation = true;
0844:                        binding.setDocumentation(getDocumentationFor(e2));
0845:                    } else if (XmlUtil.matchesTagNS(e2,
0846:                            WSDLConstants.QNAME_OPERATION)) {
0847:                        BindingOperation op = parseBindingOperation(context, e2);
0848:                        binding.add(op);
0849:                    } else {
0850:                        // possible extensibility element -- must live outside the WSDL namespace
0851:                        checkNotWsdlElement(e2);
0852:                        if (!handleExtension(context, binding, e2)) {
0853:                            checkNotWsdlRequired(e2);
0854:                        }
0855:                    }
0856:                }
0857:
0858:                context.pop();
0859:                context.fireDoneParsingEntity(WSDLConstants.QNAME_BINDING,
0860:                        binding);
0861:                return binding;
0862:            }
0863:
0864:            private BindingOperation parseBindingOperation(
0865:                    TWSDLParserContextImpl context, Element e) {
0866:                context.push();
0867:                context.registerNamespaces(e);
0868:                BindingOperation operation = new BindingOperation(
0869:                        forest.locatorTable.getStartLocation(e));
0870:                String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME);
0871:                operation.setName(name);
0872:
0873:                boolean gotDocumentation = false;
0874:
0875:                boolean gotInput = false;
0876:                boolean gotOutput = false;
0877:                boolean gotFault = false;
0878:                boolean inputBeforeOutput = false;
0879:
0880:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
0881:                    Element e2 = Util.nextElement(iter);
0882:                    if (e2 == null)
0883:                        break;
0884:                    if (XmlUtil.matchesTagNS(e2,
0885:                            WSDLConstants.QNAME_DOCUMENTATION)) {
0886:                        if (gotDocumentation) {
0887:                            errReceiver.error(forest.locatorTable
0888:                                    .getStartLocation(e), WsdlMessages
0889:                                    .PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e
0890:                                            .getLocalName()));
0891:                        }
0892:                        gotDocumentation = true;
0893:                        operation.setDocumentation(getDocumentationFor(e2));
0894:                    } else if (XmlUtil.matchesTagNS(e2,
0895:                            WSDLConstants.QNAME_INPUT)) {
0896:                        if (gotInput) {
0897:                            errReceiver.error(forest.locatorTable
0898:                                    .getStartLocation(e), WsdlMessages
0899:                                    .PARSING_TOO_MANY_ELEMENTS(
0900:                                            Constants.TAG_INPUT,
0901:                                            Constants.TAG_OPERATION, name));
0902:                        }
0903:
0904:                        /* Here we check for the use scenario */
0905:                        Iterator itere2 = XmlUtil.getAllChildren(e2);
0906:                        context.push();
0907:                        context.registerNamespaces(e2);
0908:                        BindingInput input = new BindingInput(
0909:                                forest.locatorTable.getStartLocation(e2));
0910:                        String nameAttr = XmlUtil.getAttributeOrNull(e2,
0911:                                Constants.ATTR_NAME);
0912:                        input.setName(nameAttr);
0913:                        operation.setInput(input);
0914:                        gotInput = true;
0915:                        if (gotOutput) {
0916:                            inputBeforeOutput = false;
0917:                        }
0918:
0919:                        // verify that there is at most one child element and it is a documentation element
0920:                        boolean gotDocumentation2 = false;
0921:                        for (Iterator iter2 = XmlUtil.getAllChildren(e2); iter2
0922:                                .hasNext();) {
0923:                            Element e3 = Util.nextElement(iter2);
0924:                            if (e3 == null)
0925:                                break;
0926:
0927:                            if (XmlUtil.matchesTagNS(e3,
0928:                                    WSDLConstants.QNAME_DOCUMENTATION)) {
0929:                                if (gotDocumentation2) {
0930:                                    errReceiver
0931:                                            .error(
0932:                                                    forest.locatorTable
0933:                                                            .getStartLocation(e),
0934:                                                    WsdlMessages
0935:                                                            .PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e
0936:                                                                    .getLocalName()));
0937:                                }
0938:                                gotDocumentation2 = true;
0939:                                input.setDocumentation(getDocumentationFor(e3));
0940:                            } else {
0941:                                // possible extensibility element -- must live outside the WSDL namespace
0942:                                checkNotWsdlElement(e3);
0943:                                if (!handleExtension(context, input, e3)) {
0944:                                    checkNotWsdlRequired(e3);
0945:                                }
0946:                            }
0947:                        }
0948:                        context.pop();
0949:                    } else if (XmlUtil.matchesTagNS(e2,
0950:                            WSDLConstants.QNAME_OUTPUT)) {
0951:                        if (gotOutput) {
0952:                            errReceiver.error(forest.locatorTable
0953:                                    .getStartLocation(e), WsdlMessages
0954:                                    .PARSING_TOO_MANY_ELEMENTS(
0955:                                            Constants.TAG_INPUT,
0956:                                            Constants.TAG_OPERATION, name));
0957:                        }
0958:
0959:                        context.push();
0960:                        context.registerNamespaces(e2);
0961:                        BindingOutput output = new BindingOutput(
0962:                                forest.locatorTable.getStartLocation(e2));
0963:                        String nameAttr = XmlUtil.getAttributeOrNull(e2,
0964:                                Constants.ATTR_NAME);
0965:                        output.setName(nameAttr);
0966:                        operation.setOutput(output);
0967:                        gotOutput = true;
0968:                        if (gotInput) {
0969:                            inputBeforeOutput = true;
0970:                        }
0971:
0972:                        // verify that there is at most one child element and it is a documentation element
0973:                        boolean gotDocumentation2 = false;
0974:                        for (Iterator iter2 = XmlUtil.getAllChildren(e2); iter2
0975:                                .hasNext();) {
0976:
0977:                            Element e3 = Util.nextElement(iter2);
0978:                            if (e3 == null)
0979:                                break;
0980:
0981:                            if (XmlUtil.matchesTagNS(e3,
0982:                                    WSDLConstants.QNAME_DOCUMENTATION)) {
0983:                                if (gotDocumentation2) {
0984:                                    errReceiver
0985:                                            .error(
0986:                                                    forest.locatorTable
0987:                                                            .getStartLocation(e),
0988:                                                    WsdlMessages
0989:                                                            .PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e
0990:                                                                    .getLocalName()));
0991:                                }
0992:                                gotDocumentation2 = true;
0993:                                output
0994:                                        .setDocumentation(getDocumentationFor(e3));
0995:                            } else {
0996:                                // possible extensibility element -- must live outside the WSDL namespace
0997:                                checkNotWsdlElement(e3);
0998:                                if (!handleExtension(context, output, e3)) {
0999:                                    checkNotWsdlRequired(e3);
1000:                                }
1001:                            }
1002:                        }
1003:                        context.pop();
1004:                    } else if (XmlUtil.matchesTagNS(e2,
1005:                            WSDLConstants.QNAME_FAULT)) {
1006:                        context.push();
1007:                        context.registerNamespaces(e2);
1008:                        BindingFault fault = new BindingFault(
1009:                                forest.locatorTable.getStartLocation(e2));
1010:                        String nameAttr = Util.getRequiredAttribute(e2,
1011:                                Constants.ATTR_NAME);
1012:                        fault.setName(nameAttr);
1013:                        operation.addFault(fault);
1014:                        gotFault = true;
1015:
1016:                        // verify that there is at most one child element and it is a documentation element
1017:                        boolean gotDocumentation2 = false;
1018:                        for (Iterator iter2 = XmlUtil.getAllChildren(e2); iter2
1019:                                .hasNext();) {
1020:                            Element e3 = Util.nextElement(iter2);
1021:                            if (e3 == null)
1022:                                break;
1023:
1024:                            if (XmlUtil.matchesTagNS(e3,
1025:                                    WSDLConstants.QNAME_DOCUMENTATION)) {
1026:                                if (gotDocumentation2) {
1027:                                    errReceiver
1028:                                            .error(
1029:                                                    forest.locatorTable
1030:                                                            .getStartLocation(e),
1031:                                                    WsdlMessages
1032:                                                            .PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e
1033:                                                                    .getLocalName()));
1034:                                }
1035:                                gotDocumentation2 = true;
1036:                                if (fault.getDocumentation() == null)
1037:                                    fault
1038:                                            .setDocumentation(getDocumentationFor(e3));
1039:                            } else {
1040:                                // possible extensibility element -- must live outside the WSDL namespace
1041:                                checkNotWsdlElement(e3);
1042:                                if (!handleExtension(context, fault, e3)) {
1043:                                    checkNotWsdlRequired(e3);
1044:                                }
1045:                            }
1046:                        }
1047:                        context.pop();
1048:                    } else {
1049:                        // possible extensibility element -- must live outside the WSDL namespace
1050:                        checkNotWsdlElement(e2);
1051:                        if (!handleExtension(context, operation, e2)) {
1052:                            checkNotWsdlRequired(e2);
1053:                        }
1054:                    }
1055:                }
1056:
1057:                if (gotInput && !gotOutput && !gotFault) {
1058:                    operation.setStyle(OperationStyle.ONE_WAY);
1059:                } else if (gotInput && gotOutput && inputBeforeOutput) {
1060:                    operation.setStyle(OperationStyle.REQUEST_RESPONSE);
1061:                } else if (gotInput && gotOutput && !inputBeforeOutput) {
1062:                    operation.setStyle(OperationStyle.SOLICIT_RESPONSE);
1063:                } else if (gotOutput && !gotInput && !gotFault) {
1064:                    operation.setStyle(OperationStyle.NOTIFICATION);
1065:                } else {
1066:                    errReceiver.error(forest.locatorTable.getStartLocation(e),
1067:                            WsdlMessages.PARSING_INVALID_OPERATION_STYLE(name));
1068:                }
1069:
1070:                context.pop();
1071:                context.fireDoneParsingEntity(WSDLConstants.QNAME_OPERATION,
1072:                        operation);
1073:                return operation;
1074:            }
1075:
1076:            private Import parseImport(TWSDLParserContextImpl context,
1077:                    Definitions definitions, Element e) {
1078:                context.push();
1079:                context.registerNamespaces(e);
1080:                Import anImport = new Import(forest.locatorTable
1081:                        .getStartLocation(e));
1082:                String namespace = Util.getRequiredAttribute(e,
1083:                        Constants.ATTR_NAMESPACE);
1084:                anImport.setNamespace(namespace);
1085:                String location = Util.getRequiredAttribute(e,
1086:                        Constants.ATTR_LOCATION);
1087:                anImport.setLocation(location);
1088:
1089:                // according to the schema in the WSDL 1.1 spec, an import can have a documentation element
1090:                boolean gotDocumentation = false;
1091:
1092:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
1093:                    Element e2 = Util.nextElement(iter);
1094:                    if (e2 == null)
1095:                        break;
1096:
1097:                    if (XmlUtil.matchesTagNS(e2,
1098:                            WSDLConstants.QNAME_DOCUMENTATION)) {
1099:                        if (gotDocumentation) {
1100:                            errReceiver.error(forest.locatorTable
1101:                                    .getStartLocation(e), WsdlMessages
1102:                                    .PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e
1103:                                            .getLocalName()));
1104:                        }
1105:                        gotDocumentation = true;
1106:                        anImport.setDocumentation(getDocumentationFor(e2));
1107:                    } else {
1108:                        errReceiver.error(forest.locatorTable
1109:                                .getStartLocation(e2), WsdlMessages
1110:                                .PARSING_INVALID_ELEMENT(e2.getTagName(), e2
1111:                                        .getNamespaceURI()));
1112:                    }
1113:                }
1114:                context.pop();
1115:                context.fireDoneParsingEntity(WSDLConstants.QNAME_IMPORT,
1116:                        anImport);
1117:                return anImport;
1118:            }
1119:
1120:            private Service parseService(TWSDLParserContextImpl context,
1121:                    Definitions definitions, Element e) {
1122:                context.push();
1123:                context.registerNamespaces(e);
1124:                Service service = new Service(definitions, forest.locatorTable
1125:                        .getStartLocation(e), errReceiver);
1126:                String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME);
1127:                service.setName(name);
1128:
1129:                boolean gotDocumentation = false;
1130:
1131:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
1132:                    Element e2 = Util.nextElement(iter);
1133:                    if (e2 == null)
1134:                        break;
1135:
1136:                    if (XmlUtil.matchesTagNS(e2,
1137:                            WSDLConstants.QNAME_DOCUMENTATION)) {
1138:                        if (gotDocumentation) {
1139:                            errReceiver.error(forest.locatorTable
1140:                                    .getStartLocation(e), WsdlMessages
1141:                                    .PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e
1142:                                            .getLocalName()));
1143:                        }
1144:                        gotDocumentation = true;
1145:                        if (service.getDocumentation() == null)
1146:                            service.setDocumentation(getDocumentationFor(e2));
1147:                    } else if (XmlUtil.matchesTagNS(e2,
1148:                            WSDLConstants.QNAME_PORT)) {
1149:                        Port port = parsePort(context, definitions, e2);
1150:                        service.add(port);
1151:                    } else {
1152:                        // possible extensibility element -- must live outside the WSDL namespace
1153:                        checkNotWsdlElement(e2);
1154:                        if (!handleExtension(context, service, e2)) {
1155:                            checkNotWsdlRequired(e2);
1156:                        }
1157:                    }
1158:                }
1159:
1160:                context.pop();
1161:                context.fireDoneParsingEntity(WSDLConstants.QNAME_SERVICE,
1162:                        service);
1163:                return service;
1164:            }
1165:
1166:            private Port parsePort(TWSDLParserContextImpl context,
1167:                    Definitions definitions, Element e) {
1168:                context.push();
1169:                context.registerNamespaces(e);
1170:
1171:                Port port = new Port(definitions, forest.locatorTable
1172:                        .getStartLocation(e), errReceiver);
1173:                String name = Util.getRequiredAttribute(e, Constants.ATTR_NAME);
1174:                port.setName(name);
1175:
1176:                String bindingAttr = Util.getRequiredAttribute(e,
1177:                        Constants.ATTR_BINDING);
1178:                port.setBinding(context.translateQualifiedName(context
1179:                        .getLocation(e), bindingAttr));
1180:
1181:                boolean gotDocumentation = false;
1182:
1183:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
1184:                    Element e2 = Util.nextElement(iter);
1185:                    if (e2 == null)
1186:                        break;
1187:
1188:                    if (XmlUtil.matchesTagNS(e2,
1189:                            WSDLConstants.QNAME_DOCUMENTATION)) {
1190:                        if (gotDocumentation) {
1191:                            errReceiver.error(forest.locatorTable
1192:                                    .getStartLocation(e), WsdlMessages
1193:                                    .PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e
1194:                                            .getLocalName()));
1195:                        }
1196:                        gotDocumentation = true;
1197:                        if (port.getDocumentation() == null)
1198:                            port.setDocumentation(getDocumentationFor(e2));
1199:                    } else {
1200:                        // possible extensibility element -- must live outside the WSDL namespace
1201:                        checkNotWsdlElement(e2);
1202:                        if (!handleExtension(context, port, e2)) {
1203:                            checkNotWsdlRequired(e2);
1204:                        }
1205:                    }
1206:                }
1207:
1208:                context.pop();
1209:                context.fireDoneParsingEntity(WSDLConstants.QNAME_PORT, port);
1210:                return port;
1211:            }
1212:
1213:            private void validateSchemaImports(Element typesElement) {
1214:                for (Iterator iter = XmlUtil.getAllChildren(typesElement); iter
1215:                        .hasNext();) {
1216:                    Element e = Util.nextElement(iter);
1217:                    if (e == null)
1218:                        break;
1219:                    if (XmlUtil.matchesTagNS(e, SchemaConstants.QNAME_IMPORT)) {
1220:                        errReceiver.warning(forest.locatorTable
1221:                                .getStartLocation(e), WsdlMessages
1222:                                .WARNING_WSI_R_2003());
1223:                    } else {
1224:                        checkNotWsdlElement(e);
1225:                        //                if (XmlUtil.matchesTagNS(e, SchemaConstants.QNAME_SCHEMA)) {
1226:                        //                    forest.getInlinedSchemaElement().add(e);
1227:                        //                }
1228:
1229:                    }
1230:                }
1231:            }
1232:
1233:            private boolean handleExtension(TWSDLParserContextImpl context,
1234:                    TWSDLExtensible entity, Element e) {
1235:                TWSDLExtensionHandler h = (TWSDLExtensionHandler) extensionHandlers
1236:                        .get(e.getNamespaceURI());
1237:                if (h == null) {
1238:                    context.fireIgnoringExtension(e, (Entity) entity);
1239:                    return false;
1240:                } else {
1241:                    return h.doHandleExtension(context, entity, e);
1242:                }
1243:            }
1244:
1245:            private boolean handleExtension(TWSDLParserContextImpl context,
1246:                    TWSDLExtensible entity, Node n, Element e) {
1247:                TWSDLExtensionHandler h = (TWSDLExtensionHandler) extensionHandlers
1248:                        .get(n.getNamespaceURI());
1249:                if (h == null) {
1250:                    context.fireIgnoringExtension(e, (Entity) entity);
1251:                    return false;
1252:                } else {
1253:                    return h.doHandleExtension(context, entity, e);
1254:                }
1255:            }
1256:
1257:            private void checkNotWsdlElement(Element e) {
1258:                // possible extensibility element -- must live outside the WSDL namespace
1259:                if (e.getNamespaceURI() != null
1260:                        && e.getNamespaceURI().equals(Constants.NS_WSDL))
1261:                    errReceiver.error(forest.locatorTable.getStartLocation(e),
1262:                            WsdlMessages.PARSING_INVALID_WSDL_ELEMENT(e
1263:                                    .getTagName()));
1264:            }
1265:
1266:            private void checkNotWsdlAttribute(Attr a) {
1267:                // possible extensibility element -- must live outside the WSDL namespace
1268:                if (a.getNamespaceURI().equals(Constants.NS_WSDL))
1269:                    errReceiver.error(forest.locatorTable.getStartLocation(a
1270:                            .getOwnerElement()), WsdlMessages
1271:                            .PARSING_INVALID_WSDL_ELEMENT(a.getLocalName()));
1272:            }
1273:
1274:            private void checkNotWsdlRequired(Element e) {
1275:                // check the wsdl:required attribute, fail if set to "true"
1276:                String required = XmlUtil.getAttributeNSOrNull(e,
1277:                        Constants.ATTR_REQUIRED, Constants.NS_WSDL);
1278:                if (required != null && required.equals(Constants.TRUE)
1279:                        && !options.isExtensionMode()) {
1280:                    errReceiver
1281:                            .error(
1282:                                    forest.locatorTable.getStartLocation(e),
1283:                                    WsdlMessages
1284:                                            .PARSING_REQUIRED_EXTENSIBILITY_ELEMENT(
1285:                                                    e.getTagName(), e
1286:                                                            .getNamespaceURI()));
1287:                }
1288:            }
1289:
1290:            private Documentation getDocumentationFor(Element e) {
1291:                String s = XmlUtil.getTextForNode(e);
1292:                if (s == null) {
1293:                    return null;
1294:                } else {
1295:                    return new Documentation(s);
1296:                }
1297:            }
1298:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.