Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    *
    * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
    *
    * The contents of this file are subject to the terms of either the GNU
    * General Public License Version 2 only ("GPL") or the Common Development
    * and Distribution License("CDDL") (collectively, the "License").  You
    * may not use this file except in compliance with the License.  You can
   * obtain a copy of the License at
   * http://glassfish.java.net/public/CDDL+GPL_1_1.html
   * or packager/legal/LICENSE.txt.  See the License for the specific
   * language governing permissions and limitations under the License.
   *
   * When distributing the software, include this License Header Notice in each
   * file and include the License file at packager/legal/LICENSE.txt.
   *
   * GPL Classpath Exception:
   * Oracle designates this particular file as subject to the "Classpath"
   * exception as provided by Oracle in the GPL Version 2 section of the License
   * file that accompanied this code.
   *
   * Modifications:
   * If applicable, add the following below the License Header, with the fields
   * enclosed by brackets [] replaced by your own identifying information:
   * "Portions Copyright [year] [name of copyright owner]"
   *
   * Contributor(s):
   * If you wish your version of this file to be governed by only the CDDL or
   * only the GPL Version 2, indicate your decision by adding "[Contributor]
   * elects to include this software in this distribution under the [CDDL or GPL
   * Version 2] license."  If you don't indicate a single choice of license, a
   * recipient has the option to distribute your version of this file under
   * either the CDDL, the GPL Version 2 or to extend the choice of license to
   * its licensees as provided above.  However, if you add GPL Version 2 code
   * and therefore, elected the GPL Version 2 license, then the option applies
   * only if the new code is made subject to such option by the copyright
   * holder.
   */
  
  package com.sun.tools.ws.wsdl.parser;
  
  import org.w3c.dom.Attr;
  
  import java.util.HashMap;
  import java.util.Map;
  import org.w3c.dom.Node;

A parser for WSDL documents. This parser is used only at the tool time. Extensions should extend TWSDLExtensionHandler, so that it will be called during parsing wsdl to handle wsdl extenisbility elements. Generally these extensions will effect the artifacts generated during WSDL processing.

Author(s):
WS Development Team
See also:
com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser which will be used for WSDL parsing at runtime.
 
 public class WSDLParser {
     private final ErrorReceiverFilter errReceiver;
     private WsimportOptions options;
 
     //wsdl extension handlers
     private final Map extensionHandlers;
     private MetadataFinder forest;
     private ArrayList<ParserListenerlisteners;
 
     public WSDLParser(WsimportOptions optionsErrorReceiverFilter errReceiverMetadataFinder forest) {
         this. = new HashMap();
         this. = options;
         this. = errReceiver;
         if (forest == null) {
             forest = new MetadataFinder(new WSDLInternalizationLogic(), optionserrReceiver);
             forest.parseWSDL();
             if (forest.isMexMetadata) {
                 errReceiver.reset();
         }
         }
         this. = forest;
         // register handlers for default extensions
 
         // MemberSubmission Addressing not supported by WsImport anymore see JAX_WS-1040 for details
         //register(new MemberSubmissionAddressingExtensionHandler(extensionHandlers, errReceiver, options.isExtensionMode()));
 
         register(new W3CAddressingExtensionHandler(errReceiver));
         register(new Policy12ExtensionHandler());
         register(new Policy15ExtensionHandler());
         for (TWSDLExtensionHandler te : ServiceFinder.find(TWSDLExtensionHandler.class)) {
             register(te);
         }
 
     }
 
     //TODO RK remove this after tests are fixed.
     WSDLParser(WsimportOptions optionsErrorReceiverFilter errReceiver) {
         this(options,errReceiver,null);
     }
     private void register(TWSDLExtensionHandler h) {
         .put(h.getNamespaceURI(), h);
     }
 
     public void addParserListener(ParserListener l) {
         if ( == null) {
              = new ArrayList<ParserListener>();
         }
         .add(l);
     }
 
     public WSDLDocument parse() throws SAXExceptionIOException {
         // parse external binding files
         for (InputSource value : .getWSDLBindings()) {
             .pollAbort();
             Document root = .parse(valuefalse);
             if(root==null)       continue;   // error must have been reported
             Element binding = root.getDocumentElement();
             if (!Internalizer.fixNull(binding.getNamespaceURI()).equals(.)
                     || !binding.getLocalName().equals("bindings")){
                     .error(..getStartLocation(binding), WsdlMessages.PARSER_NOT_A_BINDING_FILE(
                         binding.getNamespaceURI(),
                         binding.getLocalName()));
                 continue;
             }
 
             NodeList nl = binding.getElementsByTagNameNS(
                 "http://java.sun.com/xml/ns/javaee""handler-chains");
             for(int i = 0; i < nl.getLength(); i++){
                 .addHandlerChainConfiguration((Elementnl.item(i));
             }
 
         }
         return buildWSDLDocument();
     }
 
     public MetadataFinder getDOMForest() {
         return ;
     }
 
     private WSDLDocument buildWSDLDocument(){
        
Currently we are working off first WSDL document TODO: add support of creating WSDLDocument from fromjava.collection of WSDL documents
 
 
         String location = .getRootWSDL();
 
         //It means that WSDL is not found, an error might have been reported, lets try to recover
         if(location == null)
             return null;
 
         Document root = .get(location);
 
         if(root == null)
             return null;
 
         WSDLDocument document = new WSDLDocument();
         document.setSystemId(location);
         TWSDLParserContextImpl context = new TWSDLParserContextImpl(document);
 
         Definitions definitions = parseDefinitions(contextroot);
         document.setDefinitions(definitions);
         return document;
     }
 
     private Definitions parseDefinitions(TWSDLParserContextImpl contextDocument root) {
         context.pushWSDLLocation();
         context.setWSDLLocation(context.getDocument().getSystemId());
 
         new Internalizer().transform();
 
         Definitions definitions = parseDefinitionsNoImport(contextroot);
         if(definitions == null){
             Locator locator = ..getStartLocation(root.getDocumentElement());
             .error(locator, WsdlMessages.PARSING_NOT_AWSDL(locator.getSystemId()));
 
         }
         processImports(context);
         context.popWSDLLocation();
         return definitions;
     }
 
     private void processImports(TWSDLParserContextImpl context) {
         for(String location : .getExternalReferences()){
             if (!context.getDocument().isImportedDocument(location)){
                 Document doc = .get(location);
                 if(doc == null)
                     continue;
                 Definitions importedDefinitions = parseDefinitionsNoImport(contextdoc);
                 if(importedDefinitions == null)
                     continue;
                 context.getDocument().addImportedEntity(importedDefinitions);
                 context.getDocument().addImportedDocument(location);
             }
         }
     }
 
         TWSDLParserContextImpl context,
         Document doc) {
         Element e = doc.getDocumentElement();
         //at this poinjt we expect a wsdl or schema document to be fully qualified
         if(e.getNamespaceURI() == null || (!e.getNamespaceURI().equals(.) || !e.getLocalName().equals("definitions"))){
             return null;
         }
         context.push();
         context.registerNamespaces(e);
 
         Definitions definitions = new Definitions(context.getDocument(), ..getStartLocation(e));
         String name = XmlUtil.getAttributeOrNull(e.);
         definitions.setName(name);
 
         String targetNamespaceURI =
             XmlUtil.getAttributeOrNull(e.);
 
         definitions.setTargetNamespaceURI(targetNamespaceURI);
 
         boolean gotDocumentation = false;
         boolean gotTypes = false;
 
         for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
             Element e2 = Util.nextElement(iter);
             if (e2 == null)
                 break;
 
             if (XmlUtil.matchesTagNS(e2.)) {
                 if (gotDocumentation) {
                     .error(..getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
                     return null;
                 }
                 gotDocumentation = true;
                 if(definitions.getDocumentation() == null)
                     definitions.setDocumentation(getDocumentationFor(e2));
             } else if (XmlUtil.matchesTagNS(e2.)) {
                 if (gotTypes && !.isExtensionMode()) {
                     return null;
                 }
                 gotTypes = true;
                 //add all the wsdl:type elements to latter make a list of all the schema elements
                 // that will be needed to create jaxb model
                 if(!.isExtensionMode())
                     validateSchemaImports(e2);
             } else if (XmlUtil.matchesTagNS(e2.)) {
                 Message message = parseMessage(contextdefinitionse2);
                 definitions.add(message);
             } else if (
                 XmlUtil.matchesTagNS(e2.)) {
                 PortType portType = parsePortType(contextdefinitionse2);
                 definitions.add(portType);
             } else if (XmlUtil.matchesTagNS(e2.)) {
                 Binding binding = parseBinding(contextdefinitionse2);
                 definitions.add(binding);
             } else if (XmlUtil.matchesTagNS(e2.)) {
                 Service service = parseService(contextdefinitionse2);
                 definitions.add(service);
             } else if (XmlUtil.matchesTagNS(e2.)) {
                 definitions.add(parseImport(contextdefinitionse2));
             } else if (XmlUtil.matchesTagNS(e2.)) {
                 .warning(..getStartLocation(e2), WsdlMessages.WARNING_WSI_R_2003());
             } else {
                 // possible extensibility element -- must live outside the WSDL namespace
                 checkNotWsdlElement(e2);
                 if (!handleExtension(contextdefinitionse2)) {
                     checkNotWsdlRequired(e2);
                 }
             }
         }
 
         context.pop();
         context.fireDoneParsingEntity(
             .,
             definitions);
         return definitions;
     }
 
     private Message parseMessage(
         TWSDLParserContextImpl context,
         Definitions definitions,
         Element e) {
         context.push();
         context.registerNamespaces(e);
         Message message = new Message(definitions..getStartLocation(e), );
         String name = Util.getRequiredAttribute(e.);
         message.setName(name);
 
         boolean gotDocumentation = false;
 
         for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
             Element e2 = Util.nextElement(iter);
             if (e2 == null)
                 break;
 
             if (XmlUtil.matchesTagNS(e2.)) {
                 if (gotDocumentation) {
                     Util.fail(
                         "parsing.onlyOneDocumentationAllowed",
                         e.getLocalName());
                 }
                 gotDocumentation = true;
                 message.setDocumentation(getDocumentationFor(e2));
             } else if (XmlUtil.matchesTagNS(e2.)) {
                 MessagePart part = parseMessagePart(contexte2);
                 message.add(part);
             } else {
                 //Ignore any extensibility elements, WS-I BP 1.1 Profiled WSDL 1.1 schema allows extension elements here.
                 /*Util.fail(
                     "parsing.invalidElement",
                     e2.getTagName(),
                     e2.getNamespaceURI());
                     */
             }
         }
 
         context.pop();
         context.fireDoneParsingEntity(.message);
         return message;
     }
 
     private MessagePart parseMessagePart(TWSDLParserContextImpl contextElement e) {
         context.push();
         context.registerNamespaces(e);
         MessagePart part = new MessagePart(..getStartLocation(e));
         String partName = Util.getRequiredAttribute(e.);
         part.setName(partName);
 
         String elementAttr =
             XmlUtil.getAttributeOrNull(e.);
         String typeAttr = XmlUtil.getAttributeOrNull(e.);
 
         if (elementAttr != null) {
             if (typeAttr != null) {
                 .error(context.getLocation(e), WsdlMessages.PARSING_ONLY_ONE_OF_ELEMENT_OR_TYPE_REQUIRED(partName));
 
             }
 
             part.setDescriptor(context.translateQualifiedName(context.getLocation(e), elementAttr));
             part.setDescriptorKind(.);
         } else if (typeAttr != null) {
             part.setDescriptor(context.translateQualifiedName(context.getLocation(e), typeAttr));
             part.setDescriptorKind(.);
         } else {
             // XXX-NOTE - this is wrong; for extensibility purposes,
             // any attribute can be specified on a <part> element, so
             // we need to put an extensibility hook here
             .warning(..getStartLocation(e), WsdlMessages.PARSING_ELEMENT_OR_TYPE_REQUIRED(partName));
         }
 
         context.pop();
         context.fireDoneParsingEntity(.part);
         return part;
     }
 
     private PortType parsePortType(
         TWSDLParserContextImpl context,
         Definitions definitions,
         Element e) {
         context.push();
         context.registerNamespaces(e);
         PortType portType = new PortType(definitions..getStartLocation(e), );
         String name = Util.getRequiredAttribute(e.);
         portType.setName(name);
 
         boolean gotDocumentation = false;
 
         for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
             Element e2 = Util.nextElement(iter);
             if (e2 == null)
                 break;
 
             if (XmlUtil.matchesTagNS(e2.)) {
                 if (gotDocumentation) {
                     .error(..getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
                 }
                 gotDocumentation = true;
                 if(portType.getDocumentation() == null)
                     portType.setDocumentation(getDocumentationFor(e2));
             } else if (
                 XmlUtil.matchesTagNS(e2.)) {
                 Operation op = parsePortTypeOperation(contexte2);
                 op.setParent(portType);
                 portType.add(op);
             } else {
                 // possible extensibility element -- must live outside the WSDL namespace
                 checkNotWsdlElement(e2);
                 if (!handleExtension(contextportTypee2)) {
                     checkNotWsdlRequired(e2);
                 }
             }/*else {
                 Util.fail(
                     "parsing.invalidElement",
                     e2.getTagName(),
                     e2.getNamespaceURI());
             }*/
         }
 
         context.pop();
         context.fireDoneParsingEntity(.portType);
         return portType;
     }
 
         TWSDLParserContextImpl context,
         Element e) {
         context.push();
         context.registerNamespaces(e);
 
         Operation operation = new Operation(..getStartLocation(e));
         String name = Util.getRequiredAttribute(e.);
         operation.setName(name);
         String parameterOrderAttr =
             XmlUtil.getAttributeOrNull(e.);
         operation.setParameterOrder(parameterOrderAttr);
 
         boolean gotDocumentation = false;
 
         boolean gotInput = false;
         boolean gotOutput = false;
         boolean gotFault = false;
         boolean inputBeforeOutput = false;
 
         for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
             Element e2 = Util.nextElement(iter);
             if (e2 == null)
                 break;
 
             if (XmlUtil.matchesTagNS(e2.)) {
                 if (gotDocumentation) {
                     .error(..getStartLocation(e2), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e2.getLocalName()));
                 }
                 gotDocumentation = true;
                 if(operation.getDocumentation() == null)
                     operation.setDocumentation(getDocumentationFor(e2));
             } else if (XmlUtil.matchesTagNS(e2.)) {
                 if (gotInput) {
                     .error(..getStartLocation(e), WsdlMessages.PARSING_TOO_MANY_ELEMENTS(.,
                             .,
                             name));
                 }
 
                 context.push();
                 context.registerNamespaces(e2);
                 Input input = new Input(..getStartLocation(e2), );
                 input.setParent(operation);
                 String messageAttr =
                     Util.getRequiredAttribute(e2.);
                 input.setMessage(context.translateQualifiedName(context.getLocation(e2), messageAttr));
                 String nameAttr =
                     XmlUtil.getAttributeOrNull(e2.);
                 input.setName(nameAttr);
                 operation.setInput(input);
                 gotInput = true;
                 if (gotOutput) {
                     inputBeforeOutput = false;
                 }
 
                 // check for extensiblity attributes
                 for (Iterator iter2 = XmlUtil.getAllAttributes(e2);
                      iter2.hasNext();
                 ) {
                     Attr e3 = (Attr)iter2.next();
                     if (e3.getLocalName().equals(.) ||
                         e3.getLocalName().equals(.))
                         continue;
 
                     // possible extensibility element -- must live outside the WSDL namespace
                     checkNotWsdlAttribute(e3);
                     handleExtension(contextinpute3e2);
                 }
 
                 // verify that there is at most one child element and it is a documentation element
                 boolean gotDocumentation2 = false;
                 for (Iterator iter2 = XmlUtil.getAllChildren(e2);
                      iter2.hasNext();
                     ) {
                     Element e3 = Util.nextElement(iter2);
                     if (e3 == null)
                         break;
 
                     if (XmlUtil
                         .matchesTagNS(e3.)) {
                         if (gotDocumentation2) {
                             .error(..getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
                         }
                         gotDocumentation2 = true;
                         input.setDocumentation(getDocumentationFor(e3));
                     } else {
                         .error(..getStartLocation(e3), WsdlMessages.PARSING_INVALID_ELEMENT(e3.getTagName(),
                             e3.getNamespaceURI()));
                     }
                 }
                 context.pop();
             } else if (XmlUtil.matchesTagNS(e2.)) {
                 if (gotOutput) {
                     .error(..getStartLocation(e), WsdlMessages.PARSING_TOO_MANY_ELEMENTS(.,
                             .,
                             name));
                 }
 
                 context.push();
                 context.registerNamespaces(e2);
                 Output output = new Output(..getStartLocation(e2), );
                 output.setParent(operation);
                 String messageAttr =
                     Util.getRequiredAttribute(e2.);
                 output.setMessage(context.translateQualifiedName(context.getLocation(e2), messageAttr));
                 String nameAttr =
                     XmlUtil.getAttributeOrNull(e2.);
                 output.setName(nameAttr);
                 operation.setOutput(output);
                 gotOutput = true;
                 if (gotInput) {
                     inputBeforeOutput = true;
                 }
 
                 // check for extensiblity attributes
                 for (Iterator iter2 = XmlUtil.getAllAttributes(e2);
                      iter2.hasNext();
                 ) {
                     Attr e3 = (Attr)iter2.next();
                     if (e3.getLocalName().equals(.) ||
                         e3.getLocalName().equals(.))
                         continue;
 
                     // possible extensibility element -- must live outside the WSDL namespace
                     checkNotWsdlAttribute(e3);
                     handleExtension(contextoutpute3e2);
                 }
 
                 // verify that there is at most one child element and it is a documentation element
                 boolean gotDocumentation2 = false;
                 for (Iterator iter2 = XmlUtil.getAllChildren(e2);
                      iter2.hasNext();
                     ) {
                     Element e3 = Util.nextElement(iter2);
                     if (e3 == null)
                         break;
 
                     if (XmlUtil
                         .matchesTagNS(e3.)) {
                         if (gotDocumentation2) {
                             .error(..getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
                         }
                         gotDocumentation2 = true;
                         output.setDocumentation(getDocumentationFor(e3));
                     } else {
                         .error(..getStartLocation(e3), WsdlMessages.PARSING_INVALID_ELEMENT(e3.getTagName(),
                             e3.getNamespaceURI()));
                     }
                 }
                 context.pop();
             } else if (XmlUtil.matchesTagNS(e2.)) {
                 context.push();
                 context.registerNamespaces(e2);
                 Fault fault = new Fault(..getStartLocation(e2));
                 fault.setParent(operation);
                 String messageAttr =
                     Util.getRequiredAttribute(e2.);
                 fault.setMessage(context.translateQualifiedName(context.getLocation(e2), messageAttr));
                 String nameAttr =
                     XmlUtil.getAttributeOrNull(e2.);
                 fault.setName(nameAttr);
                 operation.addFault(fault);
                 gotFault = true;
 
                 // check for extensiblity attributes
                 for (Iterator iter2 = XmlUtil.getAllAttributes(e2);
                      iter2.hasNext();
                 ) {
                     Attr e3 = (Attr)iter2.next();
                     if (e3.getLocalName().equals(.) ||
                         e3.getLocalName().equals(.))
                         continue;
 
                     // possible extensibility element -- must live outside the WSDL namespace
                     checkNotWsdlAttribute(e3);
                     handleExtension(contextfaulte3e2);
                 }
 
                 // verify that there is at most one child element and it is a documentation element
                 boolean gotDocumentation2 = false;
                 for (Iterator iter2 = XmlUtil.getAllChildren(e2);
                      iter2.hasNext();
                     ) {
                     Element e3 = Util.nextElement(iter2);
                     if (e3 == null)
                         break;
 
                     if (XmlUtil
                         .matchesTagNS(e3.)) {
                         if (gotDocumentation2) {
                             .error(..getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
                         }
                         gotDocumentation2 = true;
                         if(fault.getDocumentation() == null)
                             fault.setDocumentation(getDocumentationFor(e3));
                     } else {
                         // possible extensibility element -- must live outside the WSDL namespace
                         checkNotWsdlElement(e3);
                         if (!handleExtension(contextfaulte3)) {
                             checkNotWsdlRequired(e3);
                         }
                     }/*else {
                         Util.fail(
                             "parsing.invalidElement",
                             e3.getTagName(),
                             e3.getNamespaceURI());
                     }*/
                 }
                 context.pop();
             } else {
                 // possible extensibility element -- must live outside the WSDL namespace
                 checkNotWsdlElement(e2);
                 if (!handleExtension(contextoperatione2)) {
                     checkNotWsdlRequired(e2);
                 }
             }/*else {
                 Util.fail(
                     "parsing.invalidElement",
                     e2.getTagName(),
                     e2.getNamespaceURI());
             }*/
         }
 
         if (gotInput && !gotOutput && !gotFault) {
             operation.setStyle(.);
         } else if (gotInput && gotOutput && inputBeforeOutput) {
             operation.setStyle(.);
         } else if (gotInput && gotOutput && !inputBeforeOutput) {
             operation.setStyle(.);
         } else if (gotOutput && !gotInput && !gotFault) {
             operation.setStyle(.);
         } else {
             .error(..getStartLocation(e), WsdlMessages.PARSING_INVALID_OPERATION_STYLE(name));
         }
 
         context.pop();
         context.fireDoneParsingEntity(.operation);
         return operation;
     }
 
     private Binding parseBinding(
         TWSDLParserContextImpl context,
         Definitions definitions,
         Element e) {
         context.push();
         context.registerNamespaces(e);
         Binding binding = new Binding(definitions..getStartLocation(e), );
         String name = Util.getRequiredAttribute(e.);
         binding.setName(name);
         String typeAttr = Util.getRequiredAttribute(e.);
         binding.setPortType(context.translateQualifiedName(context.getLocation(e), typeAttr));
 
         boolean gotDocumentation = false;
 
         for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
             Element e2 = Util.nextElement(iter);
             if (e2 == null)
                 break;
 
             if (XmlUtil.matchesTagNS(e2.)) {
                 if (gotDocumentation) {
                     .error(..getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
                 }
                 gotDocumentation = true;
                 binding.setDocumentation(getDocumentationFor(e2));
             } else if (
                 XmlUtil.matchesTagNS(e2.)) {
                 BindingOperation op = parseBindingOperation(contexte2);
                 binding.add(op);
             } else {
                 // possible extensibility element -- must live outside the WSDL namespace
                 checkNotWsdlElement(e2);
                 if (!handleExtension(contextbindinge2)) {
                     checkNotWsdlRequired(e2);
                 }
             }
         }
 
         context.pop();
         context.fireDoneParsingEntity(.binding);
         return binding;
     }
 
         TWSDLParserContextImpl context,
         Element e) {
         context.push();
         context.registerNamespaces(e);
         BindingOperation operation = new BindingOperation(..getStartLocation(e));
         String name = Util.getRequiredAttribute(e.);
         operation.setName(name);
 
         boolean gotDocumentation = false;
 
         boolean gotInput = false;
         boolean gotOutput = false;
         boolean gotFault = false;
         boolean inputBeforeOutput = false;
 
         for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
             Element e2 = Util.nextElement(iter);
             if (e2 == null)
                 break;
             if (XmlUtil.matchesTagNS(e2.)) {
                 if (gotDocumentation) {
                     .error(..getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
                 }
                 gotDocumentation = true;
                 operation.setDocumentation(getDocumentationFor(e2));
             } else if (XmlUtil.matchesTagNS(e2.)) {
                 if (gotInput) {
                     .error(..getStartLocation(e), WsdlMessages.PARSING_TOO_MANY_ELEMENTS(.,
                             .,
                             name));
                 }
 
                 /* Here we check for the use scenario */
                 context.push();
                 context.registerNamespaces(e2);
                 BindingInput input = new BindingInput(..getStartLocation(e2));
                 String nameAttr =
                     XmlUtil.getAttributeOrNull(e2.);
                 input.setName(nameAttr);
                 operation.setInput(input);
                 gotInput = true;
                 if (gotOutput) {
                     inputBeforeOutput = false;
                 }
 
                 // verify that there is at most one child element and it is a documentation element
                 boolean gotDocumentation2 = false;
                 for (Iterator iter2 = XmlUtil.getAllChildren(e2);
                      iter2.hasNext();
                     ) {
                     Element e3 = Util.nextElement(iter2);
                     if (e3 == null)
                         break;
 
                     if (XmlUtil
                         .matchesTagNS(e3.)) {
                         if (gotDocumentation2) {
                             .error(..getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
                         }
                         gotDocumentation2 = true;
                         input.setDocumentation(getDocumentationFor(e3));
                     } else {
                         // possible extensibility element -- must live outside the WSDL namespace
                         checkNotWsdlElement(e3);
                         if (!handleExtension(contextinpute3)) {
                             checkNotWsdlRequired(e3);
                         }
                     }
                 }
                 context.pop();
             } else if (XmlUtil.matchesTagNS(e2.)) {
                 if (gotOutput) {
                     .error(..getStartLocation(e), WsdlMessages.PARSING_TOO_MANY_ELEMENTS(.,
                             .,
                             name));
                 }
 
                 context.push();
                 context.registerNamespaces(e2);
                 BindingOutput output = new BindingOutput(..getStartLocation(e2));
                 String nameAttr =
                     XmlUtil.getAttributeOrNull(e2.);
                 output.setName(nameAttr);
                 operation.setOutput(output);
                 gotOutput = true;
                 if (gotInput) {
                     inputBeforeOutput = true;
                 }
 
                 // verify that there is at most one child element and it is a documentation element
                 boolean gotDocumentation2 = false;
                 for (Iterator iter2 = XmlUtil.getAllChildren(e2);
                      iter2.hasNext();
                     ) {
 
                     Element e3 = Util.nextElement(iter2);
                     if (e3 == null)
                         break;
 
                     if (XmlUtil
                         .matchesTagNS(e3.)) {
                         if (gotDocumentation2) {
                             .error(..getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
                         }
                         gotDocumentation2 = true;
                         output.setDocumentation(getDocumentationFor(e3));
                     } else {
                         // possible extensibility element -- must live outside the WSDL namespace
                         checkNotWsdlElement(e3);
                         if (!handleExtension(contextoutpute3)) {
                             checkNotWsdlRequired(e3);
                         }
                     }
                 }
                 context.pop();
             } else if (XmlUtil.matchesTagNS(e2.)) {
                 context.push();
                 context.registerNamespaces(e2);
                 BindingFault fault = new BindingFault(..getStartLocation(e2));
                 String nameAttr =
                     Util.getRequiredAttribute(e2.);
                 fault.setName(nameAttr);
                 operation.addFault(fault);
                 gotFault = true;
 
                 // verify that there is at most one child element and it is a documentation element
                 boolean gotDocumentation2 = false;
                 for (Iterator iter2 = XmlUtil.getAllChildren(e2);
                      iter2.hasNext();
                     ) {
                     Element e3 = Util.nextElement(iter2);
                     if (e3 == null)
                         break;
 
                     if (XmlUtil
                         .matchesTagNS(e3.)) {
                         if (gotDocumentation2) {
                             .error(..getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));
                         }
                         gotDocumentation2 = true;
                         if(fault.getDocumentation() == null)
                             fault.setDocumentation(getDocumentationFor(e3));
                     } else {
                         // possible extensibility element -- must live outside the WSDL namespace
                         checkNotWsdlElement(e3);
                         if (!handleExtension(contextfaulte3)) {
                             checkNotWsdlRequired(e3);
                         }
                     }
                 }
                 context.pop();
             } else {
                 // possible extensibility element -- must live outside the WSDL namespace
                 checkNotWsdlElement(e2);
                 if (!handleExtension(contextoperatione2)) {
                     checkNotWsdlRequired(e2);
                 }
             }
         }
 
         if (gotInput && !gotOutput && !gotFault) {
             operation.setStyle(.);
         } else if (gotInput && gotOutput && inputBeforeOutput) {
             operation.setStyle(.);
         } else if (gotInput && gotOutput && !inputBeforeOutput) {
             operation.setStyle(.);
         } else if (gotOutput && !gotInput && !gotFault) {
             operation.setStyle(.);
         } else {
             .error(..getStartLocation(e), WsdlMessages.PARSING_INVALID_OPERATION_STYLE(name));
         }
 
         context.pop();
         context.fireDoneParsingEntity(.operation);
         return operation;
     }
 
     private Import parseImport(
         TWSDLParserContextImpl context,
         Definitions definitions,
         Element e) {
         context.push();
         context.registerNamespaces(e);
         Import anImport = new Import(..getStartLocation(e));
         String namespace =
             Util.getRequiredAttribute(e.);
         anImport.setNamespace(namespace);
         String location = Util.getRequiredAttribute(e.);
         anImport.setLocation(location);
 
         // according to the schema in the WSDL 1.1 spec, an import can have a documentation element
         boolean gotDocumentation = false;
 
         for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
             Element e2 = Util.nextElement(iter);
             if (e2 == null)
                 break;
 
             if (XmlUtil.matchesTagNS(e2.)) {
                 if (gotDocumentation) {
                     .error(..getStartLocation(e), WsdlMessages.PARSING_ONLY_ONE_DOCUMENTATION_ALLOWED(e.getLocalName()));