1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.internal.ws.wsdl.parser;
  27 
  28 import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible;
  29 import com.sun.tools.internal.ws.api.wsdl.TWSDLExtension;
  30 import com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext;
  31 import com.sun.tools.internal.ws.util.xml.XmlUtil;
  32 import com.sun.tools.internal.ws.wsdl.document.*;
  33 import com.sun.tools.internal.ws.wsdl.document.jaxws.CustomName;
  34 import com.sun.tools.internal.ws.wsdl.document.jaxws.JAXWSBinding;
  35 import com.sun.tools.internal.ws.wsdl.document.jaxws.JAXWSBindingsConstants;
  36 import com.sun.tools.internal.ws.wsdl.document.jaxws.Parameter;
  37 import org.w3c.dom.Element;
  38 import org.w3c.dom.Node;
  39 import org.w3c.dom.NodeList;
  40 
  41 import javax.xml.namespace.NamespaceContext;
  42 import javax.xml.namespace.QName;
  43 import javax.xml.xpath.*;
  44 import java.util.Iterator;
  45 import java.util.Map;
  46 
  47 
  48 /**
  49  * @author Vivek Pandey
  50  *
  51  * jaxws:bindings exension handler.
  52  *
  53  */
  54 public class JAXWSBindingExtensionHandler extends AbstractExtensionHandler {
  55 
  56     // xml security enabled always, xpath used for parsing "part" attribute
  57     private static final XPathFactory xpf = XmlUtil.newXPathFactory(true);
  58     private final XPath xpath = xpf.newXPath();
  59 
  60     public JAXWSBindingExtensionHandler(Map<String, AbstractExtensionHandler> extensionHandlerMap) {
  61         super(extensionHandlerMap);
  62     }
  63 
  64     /* (non-Javadoc)
  65      * @see AbstractExtensionHandler#getNamespaceURI()
  66      */
  67     @Override
  68     public String getNamespaceURI() {
  69         return JAXWSBindingsConstants.NS_JAXWS_BINDINGS;
  70     }
  71 
  72     /**
  73      * @param context
  74      * @param parent
  75      * @param e
  76      */
  77     private boolean parseGlobalJAXWSBindings(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
  78         context.push();
  79         context.registerNamespaces(e);
  80 
  81         JAXWSBinding jaxwsBinding =  getJAXWSExtension(parent);
  82         if(jaxwsBinding == null) {
  83             jaxwsBinding = new JAXWSBinding(context.getLocation(e));
  84         }
  85         String attr = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.WSDL_LOCATION_ATTR);
  86         if (attr != null) {
  87             jaxwsBinding.setWsdlLocation(attr);
  88         }
  89 
  90         attr = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NODE_ATTR);
  91         if (attr != null) {
  92             jaxwsBinding.setNode(attr);
  93         }
  94 
  95         attr = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.VERSION_ATTR);
  96         if (attr != null) {
  97             jaxwsBinding.setVersion(attr);
  98         }
  99 
 100         for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
 101             Element e2 = Util.nextElement(iter);
 102             if (e2 == null) {
 103                 break;
 104             }
 105 
 106             if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.PACKAGE)) {
 107                 parsePackage(context, jaxwsBinding, e2);
 108                 if ((jaxwsBinding.getJaxwsPackage() != null) && (jaxwsBinding.getJaxwsPackage().getJavaDoc() != null)) {
 109                     ((Definitions) parent).setDocumentation(new Documentation(jaxwsBinding.getJaxwsPackage().getJavaDoc()));
 110                 }
 111             } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE)) {
 112                 parseWrapperStyle(context, jaxwsBinding, e2);
 113             } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ASYNC_MAPPING)) {
 114                 parseAsynMapping(context, jaxwsBinding, e2);
 115             } //            else if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){
 116             //                parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2);
 117             //            }
 118             else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_MIME_CONTENT)) {
 119                 parseMimeContent(context, jaxwsBinding, e2);
 120             } else {
 121                 Util.fail(
 122                         "parsing.invalidExtensionElement",
 123                         e2.getTagName(),
 124                         e2.getNamespaceURI());
 125                 return false;
 126             }
 127         }
 128         parent.addExtension(jaxwsBinding);
 129         context.pop();
 130 //        context.fireDoneParsingEntity(
 131 //                JAXWSBindingsConstants.JAXWS_BINDINGS,
 132 //                jaxwsBinding);
 133         return true;
 134     }
 135 
 136     private static JAXWSBinding getJAXWSExtension(TWSDLExtensible extensible) {
 137         for (TWSDLExtension extension:extensible.extensions()) {
 138             if (extension.getClass().equals(JAXWSBinding.class)) {
 139                 return (JAXWSBinding)extension;
 140             }
 141         }
 142 
 143         return null;
 144     }
 145 
 146     /**
 147      * @param context
 148      * @param parent
 149      * @param e
 150      */
 151     private void parseProvider(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding parent, Element e) {
 152         String val = e.getTextContent();
 153         if (val == null) {
 154             return;
 155         }
 156         if (val.equals("false") || val.equals("0")) {
 157             ((JAXWSBinding)parent).setProvider(Boolean.FALSE);
 158         } else if(val.equals("true") || val.equals("1")) {
 159             ((JAXWSBinding)parent).setProvider(Boolean.TRUE);
 160         }
 161 
 162     }
 163 
 164     /**
 165      * @param context
 166      * @param parent
 167      * @param e
 168      */
 169     private void parsePackage(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding parent, Element e) {
 170         //System.out.println("In handlePackageExtension: " + e.getNodeName());
 171         String packageName = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NAME_ATTR);
 172         JAXWSBinding binding = (JAXWSBinding)parent;
 173         binding.setJaxwsPackage(new CustomName(packageName, getJavaDoc(e)));
 174     }
 175 
 176     /**
 177      * @param context
 178      * @param parent
 179      * @param e
 180      */
 181     private void parseWrapperStyle(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding parent, Element e) {
 182         //System.out.println("In handleWrapperStyleExtension: " + e.getNodeName());
 183         String val = e.getTextContent();
 184         if (val == null) {
 185             return;
 186         }
 187         if (val.equals("false") || val.equals("0")) {
 188             ((JAXWSBinding) parent).setEnableWrapperStyle(Boolean.FALSE);
 189         } else if (val.equals("true") || val.equals("1")) {
 190             ((JAXWSBinding) parent).setEnableWrapperStyle(Boolean.TRUE);
 191         }
 192     }
 193 
 194     /**
 195      * @param context
 196      * @param parent
 197      * @param e
 198      */
 199 //    private void parseAdditionalSOAPHeaderMapping(TWSDLParserContextImpl context, TWSDLExtensible parent, Element e) {
 200 //        //System.out.println("In handleAdditionalSOAPHeaderExtension: " + e.getNodeName());
 201 //        String val = e.getTextContent();
 202 //        if(val == null)
 203 //            return;
 204 //        if(val.equals("false") || val.equals("0")){
 205 //            ((JAXWSBinding)parent).setEnableAdditionalHeaderMapping(Boolean.FALSE);
 206 //        }else if(val.equals("true") || val.equals("1")){
 207 //            ((JAXWSBinding)parent).setEnableAdditionalHeaderMapping(Boolean.TRUE);
 208 //        }
 209 //    }
 210 
 211     /**
 212      * @param context
 213      * @param parent
 214      * @param e
 215      */
 216     private void parseAsynMapping(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding parent, Element e) {
 217         //System.out.println("In handleAsynMappingExtension: " + e.getNodeName());
 218         String val = e.getTextContent();
 219         if (val == null) {
 220             return;
 221         }
 222         if (val.equals("false") || val.equals("0")) {
 223             ((JAXWSBinding) parent).setEnableAsyncMapping(Boolean.FALSE);
 224         } else if (val.equals("true") || val.equals("1")) {
 225             ((JAXWSBinding) parent).setEnableAsyncMapping(Boolean.TRUE);
 226         }
 227     }
 228 
 229     /**
 230      * @param context
 231      * @param parent
 232      * @param e
 233      */
 234     private void parseMimeContent(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding parent, Element e) {
 235         //System.out.println("In handleMimeContentExtension: " + e.getNodeName());
 236         String val = e.getTextContent();
 237         if (val == null) {
 238             return;
 239         }
 240         if (val.equals("false") || val.equals("0")) {
 241             ((JAXWSBinding) parent).setEnableMimeContentMapping(Boolean.FALSE);
 242         } else if (val.equals("true") || val.equals("1")) {
 243             ((JAXWSBinding) parent).setEnableMimeContentMapping(Boolean.TRUE);
 244         }
 245     }
 246 
 247     /**
 248      * @param context
 249      * @param jaxwsBinding
 250      * @param e
 251      */
 252     private void parseMethod(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding jaxwsBinding, Element e) {
 253         String methodName = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NAME_ATTR);
 254         String javaDoc = getJavaDoc(e);
 255         CustomName name = new CustomName(methodName, javaDoc);
 256         jaxwsBinding.setMethodName(name);
 257     }
 258 
 259     /**
 260      * @param context
 261      * @param jaxwsBinding
 262      * @param e
 263      */
 264     private void parseParameter(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding jaxwsBinding, Element e) {
 265         String part = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.PART_ATTR);
 266         Element msgPartElm = evaluateXPathNode(e.getOwnerDocument(), part, new NamespaceContextImpl(e));
 267         Node msgElm = msgPartElm.getParentNode();
 268         //MessagePart msgPart = new MessagePart();
 269 
 270         String partName = XmlUtil.getAttributeOrNull(msgPartElm, "name");
 271         String msgName = XmlUtil.getAttributeOrNull((Element)msgElm, "name");
 272         if ((partName == null) || (msgName == null)) {
 273             return;
 274         }
 275 
 276         String element = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.ELEMENT_ATTR);
 277         String name = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NAME_ATTR);
 278 
 279         QName elementName = null;
 280         if(element != null){
 281             String uri = e.lookupNamespaceURI(XmlUtil.getPrefix(element));
 282             elementName = (uri == null)?null:new QName(uri, XmlUtil.getLocalPart(element));
 283         }
 284 
 285         jaxwsBinding.addParameter(new Parameter(msgName, partName, elementName, name));
 286     }
 287 
 288     private Element evaluateXPathNode(Node target, String expression, NamespaceContext namespaceContext) {
 289         NodeList nlst;
 290         try {
 291             xpath.setNamespaceContext(namespaceContext);
 292             nlst = (NodeList)xpath.evaluate(expression, target, XPathConstants.NODESET);
 293         } catch (XPathExpressionException e) {
 294             Util.fail("internalizer.XPathEvaluationError", e.getMessage());
 295             return null; // abort processing this <jaxb:bindings>
 296         }
 297 
 298         if( nlst.getLength()==0 ) {
 299             Util.fail("internalizer.XPathEvaluatesToNoTarget", new Object[]{expression});
 300             return null; // abort
 301         }
 302 
 303         if( nlst.getLength()!=1 ) {
 304             Util.fail("internalizer.XPathEvaulatesToTooManyTargets", new Object[]{expression, nlst.getLength()});
 305             return null; // abort
 306         }
 307 
 308         Node rnode = nlst.item(0);
 309         if(!(rnode instanceof Element )) {
 310             Util.fail("internalizer.XPathEvaluatesToNonElement", new Object[]{expression});
 311             return null; // abort
 312         }
 313         return (Element)rnode;
 314     }
 315 
 316     /**
 317      * @param context
 318      * @param jaxwsBinding
 319      * @param e
 320      */
 321     private void parseClass(com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, JAXWSBinding jaxwsBinding, Element e) {
 322         String className = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NAME_ATTR);
 323         String javaDoc = getJavaDoc(e);
 324         jaxwsBinding.setClassName(new CustomName(className, javaDoc));
 325     }
 326 
 327 
 328     @Override
 329     public boolean handleDefinitionsExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 330         return parseGlobalJAXWSBindings(context, parent, e);
 331     }
 332 
 333     @Override
 334     public boolean handlePortTypeExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 335         if(XmlUtil.matchesTagNS(e, JAXWSBindingsConstants.JAXWS_BINDINGS)){
 336             context.push();
 337             context.registerNamespaces(e);
 338             JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e));
 339 
 340             for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
 341                 Element e2 = Util.nextElement(iter);
 342                 if (e2 == null) {
 343                     break;
 344                 }
 345 
 346                 if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE)) {
 347                     parseWrapperStyle(context, jaxwsBinding, e2);
 348                 } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ASYNC_MAPPING)) {
 349                     parseAsynMapping(context, jaxwsBinding, e2);
 350                 } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.CLASS)) {
 351                     parseClass(context, jaxwsBinding, e2);
 352                     if ((jaxwsBinding.getClassName() != null) && (jaxwsBinding.getClassName().getJavaDoc() != null) && (parent instanceof PortType)) {
 353                         ((PortType) parent).setDocumentation(new Documentation(jaxwsBinding.getClassName().getJavaDoc()));
 354                     }
 355                 } else {
 356                     Util.fail(
 357                             "parsing.invalidExtensionElement",
 358                             e2.getTagName(),
 359                             e2.getNamespaceURI());
 360                     return false;
 361                 }
 362             }
 363             parent.addExtension(jaxwsBinding);
 364             context.pop();
 365 //            context.fireDoneParsingEntity(
 366 //                    JAXWSBindingsConstants.JAXWS_BINDINGS,
 367 //                    jaxwsBinding);
 368             return true;
 369         }else {
 370             Util.fail(
 371                 "parsing.invalidExtensionElement",
 372                 e.getTagName(),
 373                 e.getNamespaceURI());
 374             return false;
 375         }
 376     }
 377 
 378     @Override
 379     public boolean handleOperationExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 380         if(XmlUtil.matchesTagNS(e, JAXWSBindingsConstants.JAXWS_BINDINGS)){
 381             if(parent instanceof Operation){
 382                 return handlePortTypeOperation(context, (Operation)parent, e);
 383             }else if(parent instanceof BindingOperation){
 384                 return handleBindingOperation(context, (BindingOperation)parent, e);
 385             }
 386         }else {
 387             Util.fail(
 388                 "parsing.invalidExtensionElement",
 389                 e.getTagName(),
 390                 e.getNamespaceURI());
 391             return false;
 392         }
 393         return false;
 394     }
 395 
 396     private boolean handleBindingOperation(TWSDLParserContext context, BindingOperation operation, Element e) {
 397         if(XmlUtil.matchesTagNS(e, JAXWSBindingsConstants.JAXWS_BINDINGS)){
 398             context.push();
 399             context.registerNamespaces(e);
 400             JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e));
 401 
 402             for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
 403                 Element e2 = Util.nextElement(iter);
 404                 if (e2 == null) {
 405                     break;
 406                 }
 407 
 408 //                if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){
 409 //                    parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2);
 410 //                }else
 411                 if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_MIME_CONTENT)){
 412                     parseMimeContent(context, jaxwsBinding, e2);
 413                 }else if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.PARAMETER)){
 414                     parseParameter(context, jaxwsBinding, e2);
 415                 }else{
 416                     Util.fail(
 417                         "parsing.invalidExtensionElement",
 418                         e2.getTagName(),
 419                         e2.getNamespaceURI());
 420                     return false;
 421                 }
 422             }
 423             operation.addExtension(jaxwsBinding);
 424             context.pop();
 425 //            context.fireDoneParsingEntity(
 426 //                    JAXWSBindingsConstants.JAXWS_BINDINGS,
 427 //                    jaxwsBinding);
 428             return true;
 429         }else {
 430             Util.fail(
 431                 "parsing.invalidExtensionElement",
 432                 e.getTagName(),
 433                 e.getNamespaceURI());
 434             return false;
 435         }
 436     }
 437 
 438     private boolean handlePortTypeOperation(TWSDLParserContext context, Operation parent, Element e) {
 439         context.push();
 440         context.registerNamespaces(e);
 441         JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e));
 442 
 443         for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
 444             Element e2 = Util.nextElement(iter);
 445             if (e2 == null) {
 446                 break;
 447             }
 448 
 449             if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE)){
 450                 parseWrapperStyle(context, jaxwsBinding, e2);
 451             }else if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ASYNC_MAPPING)){
 452                 parseAsynMapping(context, jaxwsBinding, e2);
 453             }else if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.METHOD)){
 454                 parseMethod(context, jaxwsBinding, e2);
 455                 if((jaxwsBinding.getMethodName() != null) && (jaxwsBinding.getMethodName().getJavaDoc() != null)){
 456                     parent.setDocumentation(new Documentation(jaxwsBinding.getMethodName().getJavaDoc()));
 457                 }
 458             }else if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.PARAMETER)){
 459                 parseParameter(context, jaxwsBinding, e2);
 460             }else{
 461                 Util.fail(
 462                     "parsing.invalidExtensionElement",
 463                     e2.getTagName(),
 464                     e2.getNamespaceURI());
 465                 return false;
 466             }
 467         }
 468         parent.addExtension(jaxwsBinding);
 469         context.pop();
 470 //        context.fireDoneParsingEntity(
 471 //                JAXWSBindingsConstants.JAXWS_BINDINGS,
 472 //                jaxwsBinding);
 473         return true;
 474     }
 475 
 476     @Override
 477     public boolean handleBindingExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 478         if(XmlUtil.matchesTagNS(e, JAXWSBindingsConstants.JAXWS_BINDINGS)){
 479             context.push();
 480             context.registerNamespaces(e);
 481             JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e));
 482 
 483             for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
 484                 Element e2 = Util.nextElement(iter);
 485                 if (e2 == null) {
 486                     break;
 487                 }
 488 
 489 //                if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){
 490 //                    parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2);
 491 //                }else
 492                 if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_MIME_CONTENT)){
 493                     parseMimeContent(context, jaxwsBinding, e2);
 494                 }else{
 495                     Util.fail(
 496                         "parsing.invalidExtensionElement",
 497                         e2.getTagName(),
 498                         e2.getNamespaceURI());
 499                     return false;
 500                 }
 501             }
 502             parent.addExtension(jaxwsBinding);
 503             context.pop();
 504 //            context.fireDoneParsingEntity(
 505 //                    JAXWSBindingsConstants.JAXWS_BINDINGS,
 506 //                    jaxwsBinding);
 507             return true;
 508         }else {
 509             Util.fail(
 510                 "parsing.invalidExtensionElement",
 511                 e.getTagName(),
 512                 e.getNamespaceURI());
 513             return false;
 514         }
 515     }
 516 
 517     /* (non-Javadoc)
 518      * @see ExtensionHandlerBase#handleFaultExtension(TWSDLParserContextImpl, TWSDLExtensible, org.w3c.dom.Element)
 519      */
 520     @Override
 521     public boolean handleFaultExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 522         if(XmlUtil.matchesTagNS(e, JAXWSBindingsConstants.JAXWS_BINDINGS)){
 523             context.push();
 524             context.registerNamespaces(e);
 525             JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e));
 526 
 527             for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
 528                 Element e2 = Util.nextElement(iter);
 529                 if (e2 == null) {
 530                     break;
 531                 }
 532                 if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.CLASS)){
 533                     parseClass(context, jaxwsBinding, e2);
 534                     if((jaxwsBinding.getClassName() != null) && (jaxwsBinding.getClassName().getJavaDoc() != null)){
 535                         ((Fault)parent).setDocumentation(new Documentation(jaxwsBinding.getClassName().getJavaDoc()));
 536                     }
 537                 }else{
 538                     Util.fail(
 539                         "parsing.invalidExtensionElement",
 540                         e2.getTagName(),
 541                         e2.getNamespaceURI());
 542                     return false;
 543                 }
 544             }
 545             parent.addExtension(jaxwsBinding);
 546             context.pop();
 547 //            context.fireDoneParsingEntity(
 548 //                    JAXWSBindingsConstants.JAXWS_BINDINGS,
 549 //                    jaxwsBinding);
 550             return true;
 551         }else {
 552             Util.fail(
 553                 "parsing.invalidExtensionElement",
 554                 e.getTagName(),
 555                 e.getNamespaceURI());
 556             return false;
 557         }
 558     }
 559 
 560     @Override
 561     public boolean handleServiceExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 562         if(XmlUtil.matchesTagNS(e, JAXWSBindingsConstants.JAXWS_BINDINGS)){
 563             context.push();
 564             context.registerNamespaces(e);
 565             JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e));
 566 
 567             for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
 568                 Element e2 = Util.nextElement(iter);
 569                 if (e2 == null) {
 570                     break;
 571                 }
 572                 if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.CLASS)){
 573                     parseClass(context, jaxwsBinding, e2);
 574                     if((jaxwsBinding.getClassName() != null) && (jaxwsBinding.getClassName().getJavaDoc() != null)){
 575                         ((Service)parent).setDocumentation(new Documentation(jaxwsBinding.getClassName().getJavaDoc()));
 576                     }
 577                 }else{
 578                     Util.fail(
 579                         "parsing.invalidExtensionElement",
 580                         e2.getTagName(),
 581                         e2.getNamespaceURI());
 582                     return false;
 583                 }
 584             }
 585             parent.addExtension(jaxwsBinding);
 586             context.pop();
 587 //            context.fireDoneParsingEntity(
 588 //                    JAXWSBindingsConstants.JAXWS_BINDINGS,
 589 //                    jaxwsBinding);
 590             return true;
 591         }else {
 592             Util.fail(
 593                 "parsing.invalidExtensionElement",
 594                 e.getTagName(),
 595                 e.getNamespaceURI());
 596             return false;
 597         }
 598     }
 599 
 600     @Override
 601     public boolean handlePortExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 602         if(XmlUtil.matchesTagNS(e, JAXWSBindingsConstants.JAXWS_BINDINGS)){
 603             context.push();
 604             context.registerNamespaces(e);
 605             JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e));
 606 
 607             for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
 608                 Element e2 = Util.nextElement(iter);
 609                 if (e2 == null) {
 610                     break;
 611                 }
 612 
 613                 if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.PROVIDER)){
 614                     parseProvider(context, jaxwsBinding, e2);
 615                 }else if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.METHOD)){
 616                     parseMethod(context, jaxwsBinding, e2);
 617                     if((jaxwsBinding.getMethodName() != null) && (jaxwsBinding.getMethodName().getJavaDoc() != null)){
 618                         ((Port)parent).setDocumentation(new Documentation(jaxwsBinding.getMethodName().getJavaDoc()));
 619                     }
 620                 }else{
 621                     Util.fail(
 622                         "parsing.invalidExtensionElement",
 623                         e2.getTagName(),
 624                         e2.getNamespaceURI());
 625                     return false;
 626                 }
 627             }
 628             parent.addExtension(jaxwsBinding);
 629             context.pop();
 630 //            context.fireDoneParsingEntity(
 631 //                    JAXWSBindingsConstants.JAXWS_BINDINGS,
 632 //                    jaxwsBinding);
 633             return true;
 634         }else {
 635             Util.fail(
 636                 "parsing.invalidExtensionElement",
 637                 e.getTagName(),
 638                 e.getNamespaceURI());
 639             return false;
 640         }
 641     }
 642 
 643     private String getJavaDoc(Element e){
 644         for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
 645             Element e2 = Util.nextElement(iter);
 646             if (e2 == null) {
 647                 break;
 648             }
 649             if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.JAVADOC)){
 650                 return XmlUtil.getTextForNode(e2);
 651             }
 652         }
 653         return null;
 654     }
 655 }