src/share/jaxws_classes/com/sun/tools/internal/ws/processor/modeler/wsdl/WSDLModeler.java

changeset 0
373ffda63c9a
child 637
9c07ef4934dd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/processor/modeler/wsdl/WSDLModeler.java	Wed Apr 27 01:27:09 2016 +0800
     1.3 @@ -0,0 +1,2821 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package com.sun.tools.internal.ws.processor.modeler.wsdl;
    1.30 +
    1.31 +import com.sun.codemodel.internal.JType;
    1.32 +import com.sun.istack.internal.NotNull;
    1.33 +import com.sun.istack.internal.SAXParseException2;
    1.34 +import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible;
    1.35 +import com.sun.tools.internal.ws.processor.generator.Names;
    1.36 +import com.sun.tools.internal.ws.processor.model.*;
    1.37 +import com.sun.tools.internal.ws.processor.model.Fault;
    1.38 +import com.sun.tools.internal.ws.processor.model.Operation;
    1.39 +import com.sun.tools.internal.ws.processor.model.Port;
    1.40 +import com.sun.tools.internal.ws.processor.model.Service;
    1.41 +import com.sun.tools.internal.ws.processor.model.java.*;
    1.42 +import com.sun.tools.internal.ws.processor.model.jaxb.*;
    1.43 +import com.sun.tools.internal.ws.processor.modeler.JavaSimpleTypeCreator;
    1.44 +import com.sun.tools.internal.ws.processor.util.ClassNameCollector;
    1.45 +import com.sun.tools.internal.ws.resources.ModelerMessages;
    1.46 +import com.sun.tools.internal.ws.wscompile.ErrorReceiver;
    1.47 +import com.sun.tools.internal.ws.wscompile.WsimportOptions;
    1.48 +import com.sun.tools.internal.ws.wsdl.document.*;
    1.49 +import com.sun.tools.internal.ws.wsdl.document.Message;
    1.50 +import com.sun.tools.internal.ws.wsdl.document.jaxws.CustomName;
    1.51 +import com.sun.tools.internal.ws.wsdl.document.jaxws.JAXWSBinding;
    1.52 +import com.sun.tools.internal.ws.wsdl.document.mime.MIMEContent;
    1.53 +import com.sun.tools.internal.ws.wsdl.document.schema.SchemaKinds;
    1.54 +import com.sun.tools.internal.ws.wsdl.document.soap.*;
    1.55 +import com.sun.tools.internal.ws.wsdl.framework.*;
    1.56 +import com.sun.tools.internal.ws.wsdl.parser.MetadataFinder;
    1.57 +import com.sun.tools.internal.ws.wsdl.parser.WSDLParser;
    1.58 +import com.sun.tools.internal.xjc.api.S2JJAXBModel;
    1.59 +import com.sun.tools.internal.xjc.api.TypeAndAnnotation;
    1.60 +import com.sun.tools.internal.xjc.api.XJC;
    1.61 +import com.sun.xml.internal.ws.spi.db.BindingHelper;
    1.62 +import com.sun.xml.internal.ws.util.xml.XmlUtil;
    1.63 +import org.xml.sax.InputSource;
    1.64 +import org.xml.sax.Locator;
    1.65 +import org.xml.sax.SAXException;
    1.66 +import org.xml.sax.SAXParseException;
    1.67 +import org.xml.sax.helpers.LocatorImpl;
    1.68 +
    1.69 +import javax.jws.WebParam.Mode;
    1.70 +import javax.xml.namespace.QName;
    1.71 +import java.util.*;
    1.72 +import java.io.IOException;
    1.73 +
    1.74 +
    1.75 +/**
    1.76 + * The WSDLModeler processes a WSDL to create a Model.
    1.77 + *
    1.78 + * @author WS Development Team
    1.79 + */
    1.80 +public class WSDLModeler extends WSDLModelerBase {
    1.81 +
    1.82 +    //map of wsdl:operation QName to <soapenv:Body> child, as per BP it must be unique in a port
    1.83 +    private final Map<QName, Operation> uniqueBodyBlocks = new HashMap<QName, Operation>();
    1.84 +    private final QName VOID_BODYBLOCK = new QName("");
    1.85 +    private final ClassNameCollector classNameCollector;
    1.86 +    private final String explicitDefaultPackage;
    1.87 +
    1.88 +    public WSDLModeler(WsimportOptions options, ErrorReceiver receiver, MetadataFinder forest) {
    1.89 +        super(options, receiver,forest);
    1.90 +        this.classNameCollector = new ClassNameCollector();
    1.91 +        this.explicitDefaultPackage = options.defaultPackage;
    1.92 +    }
    1.93 +
    1.94 +
    1.95 +    protected enum StyleAndUse {
    1.96 +        RPC_LITERAL, DOC_LITERAL
    1.97 +    }
    1.98 +
    1.99 +    private JAXBModelBuilder jaxbModelBuilder;
   1.100 +
   1.101 +    @Override
   1.102 +    public Model buildModel() {
   1.103 +        try {
   1.104 +            parser = new WSDLParser(options, errReceiver, forest);
   1.105 +            parser.addParserListener(new ParserListener() {
   1.106 +                @Override
   1.107 +                public void ignoringExtension(Entity entity, QName name, QName parent) {
   1.108 +                    if (parent.equals(WSDLConstants.QNAME_TYPES)) {
   1.109 +                        // check for a schema element with the wrong namespace URI
   1.110 +                        if (name.getLocalPart().equals("schema")
   1.111 +                                && !name.getNamespaceURI().equals("")) {
   1.112 +                            warning(entity, ModelerMessages.WSDLMODELER_WARNING_IGNORING_UNRECOGNIZED_SCHEMA_EXTENSION(name.getNamespaceURI()));
   1.113 +                        }
   1.114 +                    }
   1.115 +
   1.116 +                }
   1.117 +
   1.118 +                @Override
   1.119 +                public void doneParsingEntity(QName element, Entity entity) {
   1.120 +                }
   1.121 +            });
   1.122 +
   1.123 +            document = parser.parse();
   1.124 +            if (document == null || document.getDefinitions() == null) {
   1.125 +                return null;
   1.126 +            }
   1.127 +
   1.128 +            document.validateLocally();
   1.129 +            Model model = internalBuildModel(document);
   1.130 +            if (model == null || errReceiver.hadError()) {
   1.131 +                return null;
   1.132 +            }
   1.133 +            //ClassNameCollector classNameCollector = new ClassNameCollector();
   1.134 +            classNameCollector.process(model);
   1.135 +            if (classNameCollector.getConflictingClassNames().isEmpty()) {
   1.136 +                if (errReceiver.hadError()) {
   1.137 +                    return null;
   1.138 +                }
   1.139 +                return model;
   1.140 +            }
   1.141 +            // do another pass, this time with conflict resolution enabled
   1.142 +            model = internalBuildModel(document);
   1.143 +
   1.144 +            classNameCollector.process(model);
   1.145 +            if (classNameCollector.getConflictingClassNames().isEmpty()) {
   1.146 +                // we're done
   1.147 +                if (errReceiver.hadError()) {
   1.148 +                    return null;
   1.149 +                }
   1.150 +                return model;
   1.151 +            }
   1.152 +            // give up
   1.153 +            StringBuilder conflictList = new StringBuilder();
   1.154 +            boolean first = true;
   1.155 +            for (Iterator iter =
   1.156 +                    classNameCollector.getConflictingClassNames().iterator();
   1.157 +                 iter.hasNext();
   1.158 +                    ) {
   1.159 +                if (!first) {
   1.160 +                    conflictList.append(", ");
   1.161 +                } else {
   1.162 +                    first = false;
   1.163 +                }
   1.164 +                conflictList.append((String) iter.next());
   1.165 +            }
   1.166 +            error(document.getDefinitions(), ModelerMessages.WSDLMODELER_UNSOLVABLE_NAMING_CONFLICTS(conflictList.toString()));
   1.167 +        } catch (ModelException e) {
   1.168 +            reportError(document.getDefinitions(), e.getMessage(), e);
   1.169 +        } catch (ParseException e) {
   1.170 +            errReceiver.error(e);
   1.171 +        } catch (ValidationException e) {
   1.172 +            errReceiver.error(e.getMessage(), e);
   1.173 +        } catch (SAXException e) {
   1.174 +            errReceiver.error(e);
   1.175 +        } catch (IOException e) {
   1.176 +            errReceiver.error(e);
   1.177 +        }
   1.178 +        //should never reach here
   1.179 +        return null;
   1.180 +    }
   1.181 +
   1.182 +    private Model internalBuildModel(WSDLDocument document) {
   1.183 +        numPasses++;
   1.184 +
   1.185 +        //build the jaxbModel to be used latter
   1.186 +        buildJAXBModel(document);
   1.187 +
   1.188 +        QName modelName =
   1.189 +                new QName(
   1.190 +                        document.getDefinitions().getTargetNamespaceURI(),
   1.191 +                        document.getDefinitions().getName() == null
   1.192 +                                ? "model"
   1.193 +                                : document.getDefinitions().getName());
   1.194 +        Model model = new Model(modelName, document.getDefinitions());
   1.195 +        model.setJAXBModel(getJAXBModelBuilder().getJAXBModel());
   1.196 +
   1.197 +        // This fails with the changed classname (WSDLModeler to WSDLModeler11 etc.)
   1.198 +        // with this source comaptibility change the WSDL Modeler class name is changed. Right now hardcoding the
   1.199 +        // modeler class name to the same one being checked in WSDLGenerator.
   1.200 +
   1.201 +        model.setProperty(
   1.202 +                ModelProperties.PROPERTY_MODELER_NAME,
   1.203 +                ModelProperties.WSDL_MODELER_NAME);
   1.204 +
   1.205 +        _javaExceptions = new HashMap<String, JavaException>();
   1.206 +        _bindingNameToPortMap = new HashMap<QName, Port>();
   1.207 +
   1.208 +        // grab target namespace
   1.209 +        model.setTargetNamespaceURI(document.getDefinitions().getTargetNamespaceURI());
   1.210 +
   1.211 +        setDocumentationIfPresent(model,
   1.212 +                document.getDefinitions().getDocumentation());
   1.213 +
   1.214 +        boolean hasServices = document.getDefinitions().services().hasNext();
   1.215 +        if (hasServices) {
   1.216 +            for (Iterator iter = document.getDefinitions().services();
   1.217 +                 iter.hasNext();
   1.218 +                    ) {
   1.219 +                processService((com.sun.tools.internal.ws.wsdl.document.Service) iter.next(),
   1.220 +                        model, document);
   1.221 +            }
   1.222 +        } else {
   1.223 +            // emit a warning if there are no service definitions
   1.224 +            warning(model.getEntity(), ModelerMessages.WSDLMODELER_WARNING_NO_SERVICE_DEFINITIONS_FOUND());
   1.225 +        }
   1.226 +
   1.227 +        return model;
   1.228 +    }
   1.229 +
   1.230 +    /* (non-Javadoc)
   1.231 +     * @see WSDLModelerBase#processService(Service, Model, WSDLDocument)
   1.232 +     */
   1.233 +    protected void processService(com.sun.tools.internal.ws.wsdl.document.Service wsdlService, Model model, WSDLDocument document) {
   1.234 +        QName serviceQName = getQNameOf(wsdlService);
   1.235 +        String serviceInterface = getServiceInterfaceName(serviceQName, wsdlService);
   1.236 +        if (isConflictingServiceClassName(serviceInterface)) {
   1.237 +            serviceInterface += "_Service";
   1.238 +        }
   1.239 +        Service service =
   1.240 +                new Service(
   1.241 +                        serviceQName,
   1.242 +                        new JavaInterface(serviceInterface, serviceInterface + "Impl"), wsdlService);
   1.243 +
   1.244 +        setDocumentationIfPresent(service, wsdlService.getDocumentation());
   1.245 +        boolean hasPorts = false;
   1.246 +        for (Iterator iter = wsdlService.ports(); iter.hasNext();) {
   1.247 +            boolean processed =
   1.248 +                    processPort(
   1.249 +                            (com.sun.tools.internal.ws.wsdl.document.Port) iter.next(),
   1.250 +                            service,
   1.251 +                            document);
   1.252 +            hasPorts = hasPorts || processed;
   1.253 +        }
   1.254 +        if (!hasPorts) {
   1.255 +            // emit a warning if there are no ports
   1.256 +            warning(wsdlService, ModelerMessages.WSDLMODELER_WARNING_NO_PORTS_IN_SERVICE(wsdlService.getName()));
   1.257 +        } else {
   1.258 +            model.addService(service);
   1.259 +        }
   1.260 +    }
   1.261 +
   1.262 +    /* (non-Javadoc)
   1.263 +     * @see WSDLModelerBase#processPort(WSDLPort, Service, WSDLDocument)
   1.264 +     */
   1.265 +    protected boolean processPort(com.sun.tools.internal.ws.wsdl.document.Port wsdlPort,
   1.266 +                                  Service service, WSDLDocument document) {
   1.267 +        try {
   1.268 +
   1.269 +            //clear the  unique block map
   1.270 +            uniqueBodyBlocks.clear();
   1.271 +
   1.272 +            QName portQName = getQNameOf(wsdlPort);
   1.273 +            Port port = new Port(portQName, wsdlPort);
   1.274 +
   1.275 +            setDocumentationIfPresent(port, wsdlPort.getDocumentation());
   1.276 +
   1.277 +            SOAPAddress soapAddress =
   1.278 +                    (SOAPAddress) getExtensionOfType(wsdlPort, SOAPAddress.class);
   1.279 +            if (soapAddress == null) {
   1.280 +                if(options.isExtensionMode()){
   1.281 +                    warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_NO_SOAP_ADDRESS(wsdlPort.getName()));
   1.282 +                }else{
   1.283 +                    // not a SOAP port, ignore it
   1.284 +                    warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_IGNORING_NON_SOAP_PORT_NO_ADDRESS(wsdlPort.getName()));
   1.285 +                    return false;
   1.286 +                }
   1.287 +            }
   1.288 +            if (soapAddress != null) {
   1.289 +                port.setAddress(soapAddress.getLocation());
   1.290 +            }
   1.291 +            Binding binding = wsdlPort.resolveBinding(document);
   1.292 +            QName bindingName = getQNameOf(binding);
   1.293 +            PortType portType = binding.resolvePortType(document);
   1.294 +
   1.295 +            port.setProperty(
   1.296 +                    ModelProperties.PROPERTY_WSDL_PORT_NAME,
   1.297 +                    getQNameOf(wsdlPort));
   1.298 +            port.setProperty(
   1.299 +                    ModelProperties.PROPERTY_WSDL_PORT_TYPE_NAME,
   1.300 +                    getQNameOf(portType));
   1.301 +            port.setProperty(
   1.302 +                    ModelProperties.PROPERTY_WSDL_BINDING_NAME,
   1.303 +                    bindingName);
   1.304 +
   1.305 +            boolean isProvider = isProvider(wsdlPort);
   1.306 +            if (_bindingNameToPortMap.containsKey(bindingName) && !isProvider) {
   1.307 +                // this binding has been processed before
   1.308 +                Port existingPort =
   1.309 +                        _bindingNameToPortMap.get(bindingName);
   1.310 +                port.setOperations(existingPort.getOperations());
   1.311 +                port.setJavaInterface(existingPort.getJavaInterface());
   1.312 +                port.setStyle(existingPort.getStyle());
   1.313 +                port.setWrapped(existingPort.isWrapped());
   1.314 +            } else {
   1.315 +                // find out the SOAP binding extension, if any
   1.316 +                SOAPBinding soapBinding =
   1.317 +                        (SOAPBinding) getExtensionOfType(binding, SOAPBinding.class);
   1.318 +
   1.319 +                if (soapBinding == null) {
   1.320 +                    soapBinding =
   1.321 +                            (SOAPBinding) getExtensionOfType(binding, SOAP12Binding.class);
   1.322 +                    if (soapBinding == null) {
   1.323 +                        if(!options.isExtensionMode()){
   1.324 +                            // cannot deal with non-SOAP ports
   1.325 +                            warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_IGNORING_NON_SOAP_PORT(wsdlPort.getName()));
   1.326 +                            return false;
   1.327 +                        }else{
   1.328 +                            warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_NON_SOAP_PORT(wsdlPort.getName()));
   1.329 +                        }
   1.330 +                    }else{
   1.331 +                        // we can only do soap1.2 if extensions are on
   1.332 +                        if (options.isExtensionMode()) {
   1.333 +                            warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_PORT_SOAP_BINDING_12(wsdlPort.getName()));
   1.334 +                        } else {
   1.335 +                            warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_IGNORING_SOAP_BINDING_12(wsdlPort.getName()));
   1.336 +                            return false;
   1.337 +                        }
   1.338 +                    }
   1.339 +                }
   1.340 +
   1.341 +                if (soapBinding != null  && (soapBinding.getTransport() == null
   1.342 +                        || (!soapBinding.getTransport().equals(
   1.343 +                        SOAPConstants.URI_SOAP_TRANSPORT_HTTP) && !soapBinding.getTransport().equals(
   1.344 +                        SOAP12Constants.URI_SOAP_TRANSPORT_HTTP)))) {
   1.345 +                    if (!options.isExtensionMode()) {
   1.346 +                        // cannot deal with non-HTTP ports
   1.347 +                        warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_IGNORING_SOAP_BINDING_NON_HTTP_TRANSPORT(wsdlPort.getName()));
   1.348 +                        return false;
   1.349 +                    }
   1.350 +
   1.351 +                }
   1.352 +
   1.353 +                /**
   1.354 +                 * validate wsdl:binding uniqueness in style, e.g. rpclit or doclit
   1.355 +                 * ref: WSI BP 1.1 R 2705
   1.356 +                 */
   1.357 +                if (soapBinding != null && !validateWSDLBindingStyle(binding)) {
   1.358 +                    if (options.isExtensionMode()) {
   1.359 +                        warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_PORT_SOAP_BINDING_MIXED_STYLE(wsdlPort.getName()));
   1.360 +                    } else {
   1.361 +                        error(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_IGNORING_SOAP_BINDING_MIXED_STYLE(wsdlPort.getName()));
   1.362 +                    }
   1.363 +                }
   1.364 +
   1.365 +                if(soapBinding != null){
   1.366 +                    port.setStyle(soapBinding.getStyle());
   1.367 +                }
   1.368 +
   1.369 +                boolean hasOverloadedOperations = false;
   1.370 +                Set<String> operationNames = new HashSet<String>();
   1.371 +                for (Iterator iter = portType.operations(); iter.hasNext();) {
   1.372 +                    com.sun.tools.internal.ws.wsdl.document.Operation operation =
   1.373 +                            (com.sun.tools.internal.ws.wsdl.document.Operation) iter.next();
   1.374 +
   1.375 +                    if (operationNames.contains(operation.getName())) {
   1.376 +                        hasOverloadedOperations = true;
   1.377 +                        break;
   1.378 +                    }
   1.379 +                    operationNames.add(operation.getName());
   1.380 +
   1.381 +                    for (Iterator itr = binding.operations();
   1.382 +                         iter.hasNext();
   1.383 +                            ) {
   1.384 +                        BindingOperation bindingOperation =
   1.385 +                                (BindingOperation) itr.next();
   1.386 +                        if (operation
   1.387 +                                .getName()
   1.388 +                                .equals(bindingOperation.getName())) {
   1.389 +                            break;
   1.390 +                        } else if (!itr.hasNext()) {
   1.391 +                            error(bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_NOT_FOUND(operation.getName(), bindingOperation.getName()));
   1.392 +                        }
   1.393 +                    }
   1.394 +                }
   1.395 +
   1.396 +                Map headers = new HashMap();
   1.397 +                boolean hasOperations = false;
   1.398 +                for (Iterator iter = binding.operations(); iter.hasNext();) {
   1.399 +                    BindingOperation bindingOperation =
   1.400 +                            (BindingOperation) iter.next();
   1.401 +
   1.402 +                    com.sun.tools.internal.ws.wsdl.document.Operation portTypeOperation =
   1.403 +                            null;
   1.404 +                    Set operations =
   1.405 +                            portType.getOperationsNamed(bindingOperation.getName());
   1.406 +                    if (operations.isEmpty()) {
   1.407 +                        // the WSDL document is invalid
   1.408 +                        error(bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_NOT_IN_PORT_TYPE(bindingOperation.getName(), binding.getName()));
   1.409 +                    } else if (operations.size() == 1) {
   1.410 +                        portTypeOperation =
   1.411 +                                (com.sun.tools.internal.ws.wsdl.document.Operation) operations
   1.412 +                                        .iterator()
   1.413 +                                        .next();
   1.414 +                    } else {
   1.415 +                        boolean found = false;
   1.416 +                        String expectedInputName =
   1.417 +                                bindingOperation.getInput().getName();
   1.418 +                        String expectedOutputName =
   1.419 +                                bindingOperation.getOutput().getName();
   1.420 +
   1.421 +                        for (Iterator iter2 = operations.iterator(); iter2.hasNext();) {
   1.422 +                            com.sun.tools.internal.ws.wsdl.document.Operation candidateOperation =
   1.423 +                                    (com.sun.tools.internal.ws.wsdl.document.Operation) iter2
   1.424 +                                            .next();
   1.425 +
   1.426 +                            if (expectedInputName == null) {
   1.427 +                                // the WSDL document is invalid
   1.428 +                                error(bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_MISSING_INPUT_NAME(bindingOperation.getName()));
   1.429 +                            }
   1.430 +                            if (expectedOutputName == null) {
   1.431 +                                // the WSDL document is invalid
   1.432 +                                error(bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_MISSING_OUTPUT_NAME(bindingOperation.getName()));
   1.433 +                            }
   1.434 +                            if (expectedInputName
   1.435 +                                    .equals(candidateOperation.getInput().getName())
   1.436 +                                    && expectedOutputName.equals(
   1.437 +                                    candidateOperation
   1.438 +                                            .getOutput()
   1.439 +                                            .getName())) {
   1.440 +                                if (found) {
   1.441 +                                    // the WSDL document is invalid
   1.442 +                                    error(bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_MULTIPLE_MATCHING_OPERATIONS(bindingOperation.getName(), bindingOperation.getName()));
   1.443 +                                }
   1.444 +                                // got it!
   1.445 +                                found = true;
   1.446 +                                portTypeOperation = candidateOperation;
   1.447 +                            }
   1.448 +                        }
   1.449 +                        if (!found) {
   1.450 +                            // the WSDL document is invalid
   1.451 +                            error(bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_NOT_FOUND(bindingOperation.getName(), binding.getName()));
   1.452 +                        }
   1.453 +                    }
   1.454 +                    if (!isProvider) {
   1.455 +                        this.info =
   1.456 +                                new ProcessSOAPOperationInfo(
   1.457 +                                        port,
   1.458 +                                        wsdlPort,
   1.459 +                                        portTypeOperation,
   1.460 +                                        bindingOperation,
   1.461 +                                        soapBinding,
   1.462 +                                        document,
   1.463 +                                        hasOverloadedOperations,
   1.464 +                                        headers);
   1.465 +
   1.466 +
   1.467 +                        Operation operation;
   1.468 +                        if (soapBinding != null) {
   1.469 +                            operation = processSOAPOperation();
   1.470 +                        } else {
   1.471 +                            operation = processNonSOAPOperation();
   1.472 +                        }
   1.473 +                        if (operation != null) {
   1.474 +                            port.addOperation(operation);
   1.475 +                            hasOperations = true;
   1.476 +                        }
   1.477 +                    }
   1.478 +                }
   1.479 +                if (!isProvider && !hasOperations) {
   1.480 +                    // emit a warning if there are no operations, except when its a provider port
   1.481 +                    warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_NO_OPERATIONS_IN_PORT(wsdlPort.getName()));
   1.482 +                    return false;
   1.483 +                }
   1.484 +                createJavaInterfaceForPort(port, isProvider);
   1.485 +                PortType pt = binding.resolvePortType(document);
   1.486 +                String jd = (pt.getDocumentation() != null) ? pt.getDocumentation().getContent() : null;
   1.487 +                port.getJavaInterface().setJavaDoc(jd);
   1.488 +                _bindingNameToPortMap.put(bindingName, port);
   1.489 +            }
   1.490 +
   1.491 +            service.addPort(port);
   1.492 +            applyPortMethodCustomization(port, wsdlPort);
   1.493 +            applyWrapperStyleCustomization(port, binding.resolvePortType(document));
   1.494 +
   1.495 +            return true;
   1.496 +
   1.497 +        } catch (NoSuchEntityException e) {
   1.498 +            warning(document.getDefinitions(), e.getMessage());
   1.499 +            // should not happen
   1.500 +            return false;
   1.501 +        }
   1.502 +    }
   1.503 +
   1.504 +    /**
   1.505 +     * Returns an operation purely from abstract operation
   1.506 +     */
   1.507 +    private Operation processNonSOAPOperation() {
   1.508 +        Operation operation =
   1.509 +                new Operation(new QName(null, info.bindingOperation.getName()), info.bindingOperation);
   1.510 +
   1.511 +        setDocumentationIfPresent(
   1.512 +                operation,
   1.513 +                info.portTypeOperation.getDocumentation());
   1.514 +
   1.515 +        if (info.portTypeOperation.getStyle()
   1.516 +                != OperationStyle.REQUEST_RESPONSE
   1.517 +                && info.portTypeOperation.getStyle() != OperationStyle.ONE_WAY) {
   1.518 +            if (options.isExtensionMode()) {
   1.519 +                warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_NOT_SUPPORTED_STYLE(info.portTypeOperation.getName()));
   1.520 +                return null;
   1.521 +            } else {
   1.522 +                error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_OPERATION_NOT_SUPPORTED_STYLE(info.portTypeOperation.getName(),
   1.523 +                        info.port.resolveBinding(document).resolvePortType(document).getName()));
   1.524 +            }
   1.525 +        }
   1.526 +
   1.527 +        boolean isRequestResponse = info.portTypeOperation.getStyle() == OperationStyle.REQUEST_RESPONSE;
   1.528 +        Message inputMessage = getInputMessage();
   1.529 +        Request request = new Request(inputMessage, errReceiver);
   1.530 +        request.setErrorReceiver(errReceiver);
   1.531 +        info.operation = operation;
   1.532 +        info.operation.setWSDLPortTypeOperation(info.portTypeOperation);
   1.533 +
   1.534 +        Response response;
   1.535 +
   1.536 +        Message outputMessage = null;
   1.537 +        if (isRequestResponse) {
   1.538 +            outputMessage = getOutputMessage();
   1.539 +            response = new Response(outputMessage, errReceiver);
   1.540 +        }else{
   1.541 +            response = new Response(null, errReceiver);
   1.542 +        }
   1.543 +
   1.544 +        //set the style based on heuristic that message has either all parts defined
   1.545 +        // using type(RPC) or element(DOCUMENT)
   1.546 +        setNonSoapStyle(inputMessage, outputMessage);
   1.547 +
   1.548 +        // Process parameterOrder and get the parameterList
   1.549 +        List<MessagePart> parameterList = getParameterOrder();
   1.550 +
   1.551 +        boolean unwrappable = isUnwrappable();
   1.552 +        info.operation.setWrapped(unwrappable);
   1.553 +        List<Parameter> params = getDoclitParameters(request, response, parameterList);
   1.554 +        if (!validateParameterName(params)) {
   1.555 +            return null;
   1.556 +        }
   1.557 +
   1.558 +        // create a definitive list of parameters to match what we'd like to get
   1.559 +        // in the java interface (which is generated much later), parameterOrder
   1.560 +        List<Parameter> definitiveParameterList = new ArrayList<Parameter>();
   1.561 +        for (Parameter param : params) {
   1.562 +            if (param.isReturn()) {
   1.563 +                info.operation.setProperty(WSDL_RESULT_PARAMETER, param);
   1.564 +                response.addParameter(param);
   1.565 +                continue;
   1.566 +            }
   1.567 +            if (param.isIN()) {
   1.568 +                request.addParameter(param);
   1.569 +            } else if (param.isOUT()) {
   1.570 +                response.addParameter(param);
   1.571 +            } else if (param.isINOUT()) {
   1.572 +                request.addParameter(param);
   1.573 +                response.addParameter(param);
   1.574 +            }
   1.575 +            definitiveParameterList.add(param);
   1.576 +        }
   1.577 +
   1.578 +        info.operation.setRequest(request);
   1.579 +
   1.580 +        if (isRequestResponse) {
   1.581 +            info.operation.setResponse(response);
   1.582 +        }
   1.583 +
   1.584 +        // faults with duplicate names
   1.585 +        Set duplicateNames = getDuplicateFaultNames();
   1.586 +
   1.587 +        // handle soap:fault
   1.588 +        handleLiteralSOAPFault(response, duplicateNames);
   1.589 +        info.operation.setProperty(
   1.590 +                WSDL_PARAMETER_ORDER,
   1.591 +                definitiveParameterList);
   1.592 +
   1.593 +        Binding binding = info.port.resolveBinding(document);
   1.594 +        PortType portType = binding.resolvePortType(document);
   1.595 +        if (isAsync(portType, info.portTypeOperation)) {
   1.596 +            warning(portType, "Can not generate Async methods for non-soap binding!");
   1.597 +        }
   1.598 +        return info.operation;
   1.599 +    }
   1.600 +
   1.601 +    /**
   1.602 +     * This method is added to fix one of the use case for j2ee se folks, so that we determine
   1.603 +     * for non_soap wsdl what could be the style - rpc or document based on parts in the message.
   1.604 +     *
   1.605 +     * We assume that the message parts could have either all of them with type attribute (RPC)
   1.606 +     * or element (DOCUMENT)
   1.607 +     *
   1.608 +     * Shall this check if parts are mixed and throw error message?
   1.609 +     */
   1.610 +    private void setNonSoapStyle(Message inputMessage, Message outputMessage) {
   1.611 +        SOAPStyle style = SOAPStyle.DOCUMENT;
   1.612 +        for(MessagePart part:inputMessage.getParts()){
   1.613 +            if (part.getDescriptorKind() == SchemaKinds.XSD_TYPE) {
   1.614 +                style = SOAPStyle.RPC;
   1.615 +            } else {
   1.616 +                style = SOAPStyle.DOCUMENT;
   1.617 +            }
   1.618 +        }
   1.619 +
   1.620 +        //check the outputMessage parts
   1.621 +        if(outputMessage != null){
   1.622 +            for(MessagePart part:outputMessage.getParts()){
   1.623 +                if (part.getDescriptorKind() == SchemaKinds.XSD_TYPE) {
   1.624 +                    style = SOAPStyle.RPC;
   1.625 +                } else {
   1.626 +                    style = SOAPStyle.DOCUMENT;
   1.627 +                }
   1.628 +            }
   1.629 +        }
   1.630 +        info.modelPort.setStyle(style);
   1.631 +    }
   1.632 +
   1.633 +    /* (non-Javadoc)
   1.634 +     * @see WSDLModelerBase#processSOAPOperation()
   1.635 +     */
   1.636 +    protected Operation processSOAPOperation() {
   1.637 +        Operation operation =
   1.638 +                new Operation(new QName(null, info.bindingOperation.getName()), info.bindingOperation);
   1.639 +
   1.640 +        setDocumentationIfPresent(
   1.641 +                operation,
   1.642 +                info.portTypeOperation.getDocumentation());
   1.643 +
   1.644 +        if (info.portTypeOperation.getStyle()
   1.645 +                != OperationStyle.REQUEST_RESPONSE
   1.646 +                && info.portTypeOperation.getStyle() != OperationStyle.ONE_WAY) {
   1.647 +            if (options.isExtensionMode()) {
   1.648 +                warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_NOT_SUPPORTED_STYLE(info.portTypeOperation.getName()));
   1.649 +                return null;
   1.650 +            } else {
   1.651 +                error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_OPERATION_NOT_SUPPORTED_STYLE(info.portTypeOperation.getName(),
   1.652 +                        info.port.resolveBinding(document).resolvePortType(document).getName()));
   1.653 +            }
   1.654 +        }
   1.655 +
   1.656 +        SOAPStyle soapStyle = info.soapBinding.getStyle();
   1.657 +
   1.658 +        // find out the SOAP operation extension, if any
   1.659 +        SOAPOperation soapOperation =
   1.660 +                (SOAPOperation) getExtensionOfType(info.bindingOperation,
   1.661 +                        SOAPOperation.class);
   1.662 +
   1.663 +        if (soapOperation != null) {
   1.664 +            if (soapOperation.getStyle() != null) {
   1.665 +                soapStyle = soapOperation.getStyle();
   1.666 +            }
   1.667 +            if (soapOperation.getSOAPAction() != null) {
   1.668 +                operation.setSOAPAction(soapOperation.getSOAPAction());
   1.669 +            }
   1.670 +        }
   1.671 +
   1.672 +        operation.setStyle(soapStyle);
   1.673 +
   1.674 +        String uniqueOperationName =
   1.675 +                getUniqueName(info.portTypeOperation, info.hasOverloadedOperations);
   1.676 +        if (info.hasOverloadedOperations) {
   1.677 +            operation.setUniqueName(uniqueOperationName);
   1.678 +        }
   1.679 +
   1.680 +        info.operation = operation;
   1.681 +
   1.682 +        //attachment
   1.683 +        SOAPBody soapRequestBody = getSOAPRequestBody();
   1.684 +        if (soapRequestBody == null) {
   1.685 +            // the WSDL document is invalid
   1.686 +            error(info.bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_INPUT_MISSING_SOAP_BODY(info.bindingOperation.getName()));
   1.687 +        }
   1.688 +
   1.689 +        if (soapStyle == SOAPStyle.RPC) {
   1.690 +            if (soapRequestBody.isEncoded()) {
   1.691 +                if(options.isExtensionMode()){
   1.692 +                    warning(soapRequestBody, ModelerMessages.WSDLMODELER_20_RPCENC_NOT_SUPPORTED());
   1.693 +                    processNonSOAPOperation();
   1.694 +                }else{
   1.695 +                    error(soapRequestBody, ModelerMessages.WSDLMODELER_20_RPCENC_NOT_SUPPORTED());
   1.696 +                }
   1.697 +            }
   1.698 +            return processLiteralSOAPOperation(StyleAndUse.RPC_LITERAL);
   1.699 +        }
   1.700 +        // document style
   1.701 +        return processLiteralSOAPOperation(StyleAndUse.DOC_LITERAL);
   1.702 +    }
   1.703 +
   1.704 +    protected Operation processLiteralSOAPOperation(StyleAndUse styleAndUse) {
   1.705 +        //returns false if the operation name is not acceptable
   1.706 +        if (!applyOperationNameCustomization()) {
   1.707 +            return null;
   1.708 +        }
   1.709 +
   1.710 +        boolean isRequestResponse = info.portTypeOperation.getStyle() == OperationStyle.REQUEST_RESPONSE;
   1.711 +        Message inputMessage = getInputMessage();
   1.712 +        Request request = new Request(inputMessage, errReceiver);
   1.713 +        request.setErrorReceiver(errReceiver);
   1.714 +        info.operation.setUse(SOAPUse.LITERAL);
   1.715 +        info.operation.setWSDLPortTypeOperation(info.portTypeOperation);
   1.716 +        SOAPBody soapRequestBody = getSOAPRequestBody();
   1.717 +        if ((StyleAndUse.DOC_LITERAL == styleAndUse) && (soapRequestBody.getNamespace() != null)) {
   1.718 +            warning(soapRequestBody, ModelerMessages.WSDLMODELER_WARNING_R_2716("soapbind:body", info.bindingOperation.getName()));
   1.719 +        }
   1.720 +
   1.721 +
   1.722 +        Response response;
   1.723 +
   1.724 +        SOAPBody soapResponseBody = null;
   1.725 +        Message outputMessage = null;
   1.726 +        if (isRequestResponse) {
   1.727 +            soapResponseBody = getSOAPResponseBody();
   1.728 +            if (isOperationDocumentLiteral(styleAndUse) && (soapResponseBody.getNamespace() != null)) {
   1.729 +                warning(soapResponseBody, ModelerMessages.WSDLMODELER_WARNING_R_2716("soapbind:body", info.bindingOperation.getName()));
   1.730 +            }
   1.731 +            outputMessage = getOutputMessage();
   1.732 +            response = new Response(outputMessage, errReceiver);
   1.733 +        }else{
   1.734 +            response = new Response(null, errReceiver);
   1.735 +        }
   1.736 +
   1.737 +        //ignore operation if there are more than one root part
   1.738 +        if (!validateMimeParts(getMimeParts(info.bindingOperation.getInput())) ||
   1.739 +                !validateMimeParts(getMimeParts(info.bindingOperation.getOutput()))) {
   1.740 +            return null;
   1.741 +        }
   1.742 +
   1.743 +        if (!validateBodyParts(info.bindingOperation)) {
   1.744 +            // BP 1.1
   1.745 +            // R2204   A document-literal binding in a DESCRIPTION MUST refer, in each of its soapbind:body element(s),
   1.746 +            // only to wsdl:part element(s) that have been defined using the element attribute.
   1.747 +
   1.748 +            // R2203   An rpc-literal binding in a DESCRIPTION MUST refer, in its soapbind:body element(s),
   1.749 +            // only to wsdNl:part element(s) that have been defined using the type attribute.
   1.750 +            if (isOperationDocumentLiteral(styleAndUse)) {
   1.751 +                if (options.isExtensionMode()) {
   1.752 +                    warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_CANNOT_HANDLE_TYPE_MESSAGE_PART(info.portTypeOperation.getName()));
   1.753 +                } else {
   1.754 +                    error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_DOCLITOPERATION(info.portTypeOperation.getName()));
   1.755 +                }
   1.756 +            } else if (isOperationRpcLiteral(styleAndUse)) {
   1.757 +                if (options.isExtensionMode()) {
   1.758 +                    warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_CANNOT_HANDLE_ELEMENT_MESSAGE_PART(info.portTypeOperation.getName()));
   1.759 +                } else {
   1.760 +                    error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_RPCLITOPERATION(info.portTypeOperation.getName()));
   1.761 +                }
   1.762 +            }
   1.763 +            return null;
   1.764 +        }
   1.765 +
   1.766 +        // Process parameterOrder and get the parameterList
   1.767 +        List<MessagePart> parameterList = getParameterOrder();
   1.768 +
   1.769 +        //binding is invalid in the wsdl, ignore the operation.
   1.770 +        if (!setMessagePartsBinding(styleAndUse)) {
   1.771 +            return null;
   1.772 +        }
   1.773 +
   1.774 +        List<Parameter> params = null;
   1.775 +        boolean unwrappable = isUnwrappable();
   1.776 +        info.operation.setWrapped(unwrappable);
   1.777 +        if (isOperationDocumentLiteral(styleAndUse)) {
   1.778 +            params = getDoclitParameters(request, response, parameterList);
   1.779 +        } else if (isOperationRpcLiteral(styleAndUse)) {
   1.780 +            String operationName = info.bindingOperation.getName();
   1.781 +            Block reqBlock = null;
   1.782 +            if (inputMessage != null) {
   1.783 +                QName name = new QName(getRequestNamespaceURI(soapRequestBody), operationName);
   1.784 +                RpcLitStructure rpcStruct = new RpcLitStructure(name, getJAXBModelBuilder().getJAXBModel());
   1.785 +                rpcStruct.setJavaType(new JavaSimpleType("com.sun.xml.internal.ws.encoding.jaxb.RpcLitPayload", null));
   1.786 +                reqBlock = new Block(name, rpcStruct, inputMessage);
   1.787 +                request.addBodyBlock(reqBlock);
   1.788 +            }
   1.789 +
   1.790 +            Block resBlock = null;
   1.791 +            if (isRequestResponse && outputMessage != null) {
   1.792 +                QName name = new QName(getResponseNamespaceURI(soapResponseBody), operationName + "Response");
   1.793 +                RpcLitStructure rpcStruct = new RpcLitStructure(name, getJAXBModelBuilder().getJAXBModel());
   1.794 +                rpcStruct.setJavaType(new JavaSimpleType("com.sun.xml.internal.ws.encoding.jaxb.RpcLitPayload", null));
   1.795 +                resBlock = new Block(name, rpcStruct, outputMessage);
   1.796 +                response.addBodyBlock(resBlock);
   1.797 +            }
   1.798 +            params = getRpcLitParameters(request, response, reqBlock, resBlock, parameterList);
   1.799 +        }
   1.800 +
   1.801 +
   1.802 +        if (!validateParameterName(params)) {
   1.803 +            return null;
   1.804 +        }
   1.805 +
   1.806 +        // create a definitive list of parameters to match what we'd like to get
   1.807 +        // in the java interface (which is generated much later), parameterOrder
   1.808 +        List<Parameter> definitiveParameterList = new ArrayList<Parameter>();
   1.809 +        for (Parameter param : params) {
   1.810 +            if (param.isReturn()) {
   1.811 +                info.operation.setProperty(WSDL_RESULT_PARAMETER, param);
   1.812 +                response.addParameter(param);
   1.813 +                continue;
   1.814 +            }
   1.815 +            if (param.isIN()) {
   1.816 +                request.addParameter(param);
   1.817 +            } else if (param.isOUT()) {
   1.818 +                response.addParameter(param);
   1.819 +            } else if (param.isINOUT()) {
   1.820 +                request.addParameter(param);
   1.821 +                response.addParameter(param);
   1.822 +            }
   1.823 +            definitiveParameterList.add(param);
   1.824 +        }
   1.825 +
   1.826 +        info.operation.setRequest(request);
   1.827 +
   1.828 +        if (isRequestResponse) {
   1.829 +            info.operation.setResponse(response);
   1.830 +        }
   1.831 +
   1.832 +        Iterator<Block> bb = request.getBodyBlocks();
   1.833 +        QName body;
   1.834 +        Operation thatOp;
   1.835 +        if (bb.hasNext()) {
   1.836 +            body = bb.next().getName();
   1.837 +            thatOp = uniqueBodyBlocks.get(body);
   1.838 +        } else {
   1.839 +            //there is no body block
   1.840 +            body = VOID_BODYBLOCK;
   1.841 +            thatOp = uniqueBodyBlocks.get(VOID_BODYBLOCK);
   1.842 +        }
   1.843 +
   1.844 +        if(thatOp != null){
   1.845 +            if(options.isExtensionMode()){
   1.846 +                warning(info.port, ModelerMessages.WSDLMODELER_NON_UNIQUE_BODY_WARNING(info.port.getName(), info.operation.getName(), thatOp.getName(), body));
   1.847 +            }else{
   1.848 +                error(info.port, ModelerMessages.WSDLMODELER_NON_UNIQUE_BODY_ERROR(info.port.getName(), info.operation.getName(), thatOp.getName(), body));
   1.849 +            }
   1.850 +        }else{
   1.851 +            uniqueBodyBlocks.put(body, info.operation);
   1.852 +        }
   1.853 +
   1.854 +        //Add additional headers
   1.855 +        if (options.additionalHeaders) {
   1.856 +            List<Parameter> additionalHeaders = new ArrayList<Parameter>();
   1.857 +            if (inputMessage != null) {
   1.858 +                for (MessagePart part : getAdditionHeaderParts(info.bindingOperation, inputMessage, true)) {
   1.859 +                    QName name = part.getDescriptor();
   1.860 +                    JAXBType jaxbType = getJAXBType(part);
   1.861 +                    Block block = new Block(name, jaxbType, part);
   1.862 +                    Parameter param = ModelerUtils.createParameter(part.getName(), jaxbType, block);
   1.863 +                    additionalHeaders.add(param);
   1.864 +                    request.addHeaderBlock(block);
   1.865 +                    request.addParameter(param);
   1.866 +                    definitiveParameterList.add(param);
   1.867 +                }
   1.868 +            }
   1.869 +
   1.870 +            if (isRequestResponse && outputMessage != null) {
   1.871 +                List<Parameter> outParams = new ArrayList<Parameter>();
   1.872 +                for (MessagePart part : getAdditionHeaderParts(info.bindingOperation,outputMessage, false)) {
   1.873 +                    QName name = part.getDescriptor();
   1.874 +                    JAXBType jaxbType = getJAXBType(part);
   1.875 +                    Block block = new Block(name, jaxbType, part);
   1.876 +                    Parameter param = ModelerUtils.createParameter(part.getName(), jaxbType, block);
   1.877 +                    param.setMode(Mode.OUT);
   1.878 +                    outParams.add(param);
   1.879 +                    response.addHeaderBlock(block);
   1.880 +                    response.addParameter(param);
   1.881 +                }
   1.882 +                for (Parameter outParam : outParams) {
   1.883 +                    for (Parameter inParam : additionalHeaders) {
   1.884 +                        if (inParam.getName().equals(outParam.getName()) &&
   1.885 +                                inParam.getBlock().getName().equals(outParam.getBlock().getName())) {
   1.886 +                            //it is INOUT
   1.887 +                            inParam.setMode(Mode.INOUT);
   1.888 +                            outParam.setMode(Mode.INOUT);
   1.889 +                            break;
   1.890 +                        }
   1.891 +                    }
   1.892 +                    if (outParam.isOUT()) {
   1.893 +                        definitiveParameterList.add(outParam);
   1.894 +                    }
   1.895 +                }
   1.896 +            }
   1.897 +        }
   1.898 +
   1.899 +        // faults with duplicate names
   1.900 +        Set duplicateNames = getDuplicateFaultNames();
   1.901 +
   1.902 +        // handle soap:fault
   1.903 +        handleLiteralSOAPFault(response, duplicateNames);
   1.904 +        info.operation.setProperty(
   1.905 +                WSDL_PARAMETER_ORDER,
   1.906 +                definitiveParameterList);
   1.907 +
   1.908 +        //set Async property
   1.909 +        Binding binding = info.port.resolveBinding(document);
   1.910 +        PortType portType = binding.resolvePortType(document);
   1.911 +        if (isAsync(portType, info.portTypeOperation)) {
   1.912 +            addAsyncOperations(info.operation, styleAndUse);
   1.913 +        }
   1.914 +
   1.915 +        return info.operation;
   1.916 +    }
   1.917 +
   1.918 +
   1.919 +    private boolean validateParameterName(List<Parameter> params) {
   1.920 +        if (options.isExtensionMode()) {
   1.921 +            return true;
   1.922 +        }
   1.923 +
   1.924 +        Message msg = getInputMessage();
   1.925 +        for (Parameter param : params) {
   1.926 +            if (param.isOUT()) {
   1.927 +                continue;
   1.928 +            }
   1.929 +            if (param.getCustomName() != null) {
   1.930 +                if (Names.isJavaReservedWord(param.getCustomName())) {
   1.931 +                    error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_CUSTOM_NAME(info.operation.getName(), param.getCustomName()));
   1.932 +                    return false;
   1.933 +                }
   1.934 +                return true;
   1.935 +            }
   1.936 +            //process doclit wrapper style
   1.937 +            if (param.isEmbedded() && !(param.getBlock().getType() instanceof RpcLitStructure)) {
   1.938 +                if (Names.isJavaReservedWord(param.getName())) {
   1.939 +                    error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_WRAPPER_STYLE(info.operation.getName(), param.getName(), param.getBlock().getName()));
   1.940 +                    return false;
   1.941 +                }
   1.942 +            } else {
   1.943 +                //non-wrapper style and rpclit
   1.944 +                if (Names.isJavaReservedWord(param.getName())) {
   1.945 +                    error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_NON_WRAPPER_STYLE(info.operation.getName(), msg.getName(), param.getName()));
   1.946 +                    return false;
   1.947 +                }
   1.948 +            }
   1.949 +        }
   1.950 +
   1.951 +        boolean isRequestResponse = info.portTypeOperation.getStyle() == OperationStyle.REQUEST_RESPONSE;
   1.952 +        if (isRequestResponse) {
   1.953 +            msg = getOutputMessage();
   1.954 +            for (Parameter param : params) {
   1.955 +                if (param.isIN()) {
   1.956 +                    continue;
   1.957 +                }
   1.958 +                if (param.getCustomName() != null) {
   1.959 +                    if (Names.isJavaReservedWord(param.getCustomName())) {
   1.960 +                        error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_CUSTOM_NAME(info.operation.getName(), param.getCustomName()));
   1.961 +                        return false;
   1.962 +                    }
   1.963 +                    return true;
   1.964 +                }
   1.965 +                //process doclit wrapper style
   1.966 +                if (param.isEmbedded() && !(param.getBlock().getType() instanceof RpcLitStructure)) {
   1.967 +                    if (param.isReturn()) {
   1.968 +                        continue;
   1.969 +                    }
   1.970 +                    if (!param.getName().equals("return") && Names.isJavaReservedWord(param.getName())) {
   1.971 +                        error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_WRAPPER_STYLE(info.operation.getName(), param.getName(), param.getBlock().getName()));
   1.972 +                        return false;
   1.973 +                    }
   1.974 +                } else {
   1.975 +                    if (param.isReturn()) {
   1.976 +                        continue;
   1.977 +                    }
   1.978 +
   1.979 +                    //non-wrapper style and rpclit
   1.980 +                    if (Names.isJavaReservedWord(param.getName())) {
   1.981 +                        error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_NON_WRAPPER_STYLE(info.operation.getName(), msg.getName(), param.getName()));
   1.982 +                        return false;
   1.983 +                    }
   1.984 +                }
   1.985 +            }
   1.986 +        }
   1.987 +
   1.988 +        return true;
   1.989 +    }
   1.990 +
   1.991 +    private boolean enableMimeContent() {
   1.992 +        //first we look at binding operation
   1.993 +        JAXWSBinding jaxwsCustomization = (JAXWSBinding) getExtensionOfType(info.bindingOperation, JAXWSBinding.class);
   1.994 +        Boolean mimeContentMapping = (jaxwsCustomization != null) ? jaxwsCustomization.isEnableMimeContentMapping() : null;
   1.995 +        if (mimeContentMapping != null) {
   1.996 +            return mimeContentMapping;
   1.997 +        }
   1.998 +
   1.999 +        //then in wsdl:binding
  1.1000 +        Binding binding = info.port.resolveBinding(info.document);
  1.1001 +        jaxwsCustomization = (JAXWSBinding) getExtensionOfType(binding, JAXWSBinding.class);
  1.1002 +        mimeContentMapping = (jaxwsCustomization != null) ? jaxwsCustomization.isEnableMimeContentMapping() : null;
  1.1003 +        if (mimeContentMapping != null) {
  1.1004 +            return mimeContentMapping;
  1.1005 +        }
  1.1006 +
  1.1007 +        //at last look in wsdl:definitions
  1.1008 +        jaxwsCustomization = (JAXWSBinding) getExtensionOfType(info.document.getDefinitions(), JAXWSBinding.class);
  1.1009 +        mimeContentMapping = (jaxwsCustomization != null) ? jaxwsCustomization.isEnableMimeContentMapping() : null;
  1.1010 +        if (mimeContentMapping != null) {
  1.1011 +            return mimeContentMapping;
  1.1012 +        }
  1.1013 +        return false;
  1.1014 +    }
  1.1015 +
  1.1016 +    private boolean applyOperationNameCustomization() {
  1.1017 +        JAXWSBinding jaxwsCustomization = (JAXWSBinding) getExtensionOfType(info.portTypeOperation, JAXWSBinding.class);
  1.1018 +        String operationName = (jaxwsCustomization != null) ? ((jaxwsCustomization.getMethodName() != null) ? jaxwsCustomization.getMethodName().getName() : null) : null;
  1.1019 +        if (operationName != null) {
  1.1020 +            if (Names.isJavaReservedWord(operationName)) {
  1.1021 +                if (options.isExtensionMode()) {
  1.1022 +                    warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_CUSTOMIZED_OPERATION_NAME(info.operation.getName(), operationName));
  1.1023 +                } else {
  1.1024 +                    error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_CUSTOMIZED_OPERATION_NAME(info.operation.getName(), operationName));
  1.1025 +                }
  1.1026 +                return false;
  1.1027 +            }
  1.1028 +
  1.1029 +            info.operation.setCustomizedName(operationName);
  1.1030 +        }
  1.1031 +
  1.1032 +        if (Names.isJavaReservedWord(info.operation.getJavaMethodName())) {
  1.1033 +            if (options.isExtensionMode()) {
  1.1034 +                warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_OPERATION_NAME(info.operation.getName()));
  1.1035 +            } else {
  1.1036 +                error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_OPERATION_NAME(info.operation.getName()));
  1.1037 +            }
  1.1038 +            return false;
  1.1039 +        }
  1.1040 +        return true;
  1.1041 +    }
  1.1042 +
  1.1043 +    protected String getAsyncOperationName(Operation operation) {
  1.1044 +        String name = operation.getCustomizedName();
  1.1045 +        if (name == null) {
  1.1046 +            name = operation.getUniqueName();
  1.1047 +        }
  1.1048 +        return name;
  1.1049 +    }
  1.1050 +
  1.1051 +    /**
  1.1052 +     * @param styleAndUse
  1.1053 +     */
  1.1054 +    private void addAsyncOperations(Operation syncOperation, StyleAndUse styleAndUse) {
  1.1055 +        Operation operation = createAsyncOperation(syncOperation, styleAndUse, AsyncOperationType.POLLING);
  1.1056 +        if (operation != null) {
  1.1057 +            info.modelPort.addOperation(operation);
  1.1058 +        }
  1.1059 +
  1.1060 +        operation = createAsyncOperation(syncOperation, styleAndUse, AsyncOperationType.CALLBACK);
  1.1061 +        if (operation != null) {
  1.1062 +            info.modelPort.addOperation(operation);
  1.1063 +        }
  1.1064 +    }
  1.1065 +
  1.1066 +    private Operation createAsyncOperation(Operation syncOperation, StyleAndUse styleAndUse, AsyncOperationType asyncType) {
  1.1067 +        boolean isRequestResponse = info.portTypeOperation.getStyle() == OperationStyle.REQUEST_RESPONSE;
  1.1068 +        if (!isRequestResponse) {
  1.1069 +            return null;
  1.1070 +        }
  1.1071 +
  1.1072 +        //create async operations
  1.1073 +        AsyncOperation operation = new AsyncOperation(info.operation, info.bindingOperation);
  1.1074 +
  1.1075 +        //creation the async operation name: operationName+Async or customized name
  1.1076 +        //operation.setName(new QName(operation.getName().getNamespaceURI(), getAsyncOperationName(info.portTypeOperation, operation)));
  1.1077 +        if (asyncType.equals(AsyncOperationType.CALLBACK)) {
  1.1078 +            operation.setUniqueName(info.operation.getUniqueName() + "_async_callback");
  1.1079 +        } else if (asyncType.equals(AsyncOperationType.POLLING)) {
  1.1080 +            operation.setUniqueName(info.operation.getUniqueName() + "_async_polling");
  1.1081 +        }
  1.1082 +
  1.1083 +        setDocumentationIfPresent(
  1.1084 +                operation,
  1.1085 +                info.portTypeOperation.getDocumentation());
  1.1086 +
  1.1087 +        operation.setAsyncType(asyncType);
  1.1088 +        operation.setSOAPAction(info.operation.getSOAPAction());
  1.1089 +        boolean unwrappable = info.operation.isWrapped();
  1.1090 +        operation.setWrapped(unwrappable);
  1.1091 +        SOAPBody soapRequestBody = getSOAPRequestBody();
  1.1092 +
  1.1093 +        Message inputMessage = getInputMessage();
  1.1094 +        Request request = new Request(inputMessage, errReceiver);
  1.1095 +
  1.1096 +        SOAPBody soapResponseBody = getSOAPResponseBody();
  1.1097 +        Message outputMessage = getOutputMessage();
  1.1098 +        Response response = new Response(outputMessage, errReceiver);
  1.1099 +
  1.1100 +        // Process parameterOrder and get the parameterList
  1.1101 +        java.util.List<String> parameterList = getAsynParameterOrder();
  1.1102 +
  1.1103 +        List<Parameter> inParameters = null;
  1.1104 +        if (isOperationDocumentLiteral(styleAndUse)) {
  1.1105 +            inParameters = getRequestParameters(request, parameterList);
  1.1106 +            // outParameters = getResponseParameters(response);
  1.1107 +            // re-create parameterList with unwrapped parameters
  1.1108 +            if (unwrappable) {
  1.1109 +                List<String> unwrappedParameterList = new ArrayList<String>();
  1.1110 +                if (inputMessage != null) {
  1.1111 +                    Iterator<MessagePart> parts = inputMessage.parts();
  1.1112 +                    if (parts.hasNext()) {
  1.1113 +                        MessagePart part = parts.next();
  1.1114 +                        JAXBType jaxbType = getJAXBType(part);
  1.1115 +                        List<JAXBProperty> memberList = jaxbType.getWrapperChildren();
  1.1116 +                        Iterator<JAXBProperty> props = memberList.iterator();
  1.1117 +                        while (props.hasNext()) {
  1.1118 +                            JAXBProperty prop = props.next();
  1.1119 +                            unwrappedParameterList.add(prop.getElementName().getLocalPart());
  1.1120 +                        }
  1.1121 +                    }
  1.1122 +                }
  1.1123 +
  1.1124 +                parameterList.clear();
  1.1125 +                parameterList.addAll(unwrappedParameterList);
  1.1126 +            }
  1.1127 +        } else if (isOperationRpcLiteral(styleAndUse)) {
  1.1128 +            String operationName = info.bindingOperation.getName();
  1.1129 +            Block reqBlock = null;
  1.1130 +            if (inputMessage != null) {
  1.1131 +                QName name = new QName(getRequestNamespaceURI(soapRequestBody), operationName);
  1.1132 +                RpcLitStructure rpcStruct = new RpcLitStructure(name, getJAXBModelBuilder().getJAXBModel());
  1.1133 +                rpcStruct.setJavaType(new JavaSimpleType("com.sun.xml.internal.ws.encoding.jaxb.RpcLitPayload", null));
  1.1134 +                reqBlock = new Block(name, rpcStruct, inputMessage);
  1.1135 +                request.addBodyBlock(reqBlock);
  1.1136 +            }
  1.1137 +            inParameters = createRpcLitRequestParameters(request, parameterList, reqBlock);
  1.1138 +        }
  1.1139 +
  1.1140 +        // add response blocks, we dont need to create respnse parameters, just blocks will be fine, lets
  1.1141 +        // copy them from sync optraions
  1.1142 +        //copy the response blocks from the sync operation
  1.1143 +        Iterator<Block> blocks = info.operation.getResponse().getBodyBlocks();
  1.1144 +
  1.1145 +        while (blocks.hasNext()) {
  1.1146 +            response.addBodyBlock(blocks.next());
  1.1147 +        }
  1.1148 +
  1.1149 +        blocks = info.operation.getResponse().getHeaderBlocks();
  1.1150 +        while (blocks.hasNext()) {
  1.1151 +            response.addHeaderBlock(blocks.next());
  1.1152 +        }
  1.1153 +
  1.1154 +        blocks = info.operation.getResponse().getAttachmentBlocks();
  1.1155 +        while (blocks.hasNext()) {
  1.1156 +            response.addAttachmentBlock(blocks.next());
  1.1157 +        }
  1.1158 +
  1.1159 +        List<MessagePart> outputParts = outputMessage.getParts();
  1.1160 +
  1.1161 +        // handle headers
  1.1162 +        int numOfOutMsgParts = outputParts.size();
  1.1163 +
  1.1164 +        if (numOfOutMsgParts == 1) {
  1.1165 +            MessagePart part = outputParts.get(0);
  1.1166 +            if (isOperationDocumentLiteral(styleAndUse)) {
  1.1167 +                JAXBType type = getJAXBType(part);
  1.1168 +                operation.setResponseBean(type);
  1.1169 +            } else if (isOperationRpcLiteral(styleAndUse)) {
  1.1170 +                String operationName = info.bindingOperation.getName();
  1.1171 +                Block resBlock = info.operation.getResponse().getBodyBlocksMap().get(new QName(getResponseNamespaceURI(soapResponseBody),
  1.1172 +                        operationName + "Response"));
  1.1173 +
  1.1174 +                RpcLitStructure resBean = (RpcLitStructure) resBlock.getType();
  1.1175 +                List<RpcLitMember> members = resBean.getRpcLitMembers();
  1.1176 +                operation.setResponseBean(members.get(0));
  1.1177 +            }
  1.1178 +        } else {
  1.1179 +            //create response bean
  1.1180 +            String nspace = "";
  1.1181 +            QName responseBeanName = new QName(nspace, getAsyncOperationName(info.operation) + "Response");
  1.1182 +            JAXBType responseBeanType = getJAXBModelBuilder().getJAXBType(responseBeanName);
  1.1183 +            if (responseBeanType == null) {
  1.1184 +                error(info.operation.getEntity(), ModelerMessages.WSDLMODELER_RESPONSEBEAN_NOTFOUND(info.operation.getName()));
  1.1185 +            }
  1.1186 +            operation.setResponseBean(responseBeanType);
  1.1187 +        }
  1.1188 +
  1.1189 +        QName respBeanName = new QName(soapResponseBody.getNamespace(), getAsyncOperationName(info.operation) + "Response");
  1.1190 +        Block block = new Block(respBeanName, operation.getResponseBeanType(), outputMessage);
  1.1191 +        JavaType respJavaType = operation.getResponseBeanJavaType();
  1.1192 +        JAXBType respType = new JAXBType(respBeanName, respJavaType);
  1.1193 +        Parameter respParam = ModelerUtils.createParameter(info.operation.getName() + "Response", respType, block);
  1.1194 +        respParam.setParameterIndex(-1);
  1.1195 +        response.addParameter(respParam);
  1.1196 +        operation.setProperty(WSDL_RESULT_PARAMETER, respParam.getName());
  1.1197 +
  1.1198 +
  1.1199 +        int parameterOrderPosition = 0;
  1.1200 +        for (String name : parameterList) {
  1.1201 +            Parameter inParameter = ModelerUtils.getParameter(name, inParameters);
  1.1202 +            if (inParameter == null) {
  1.1203 +                if (options.isExtensionMode()) {
  1.1204 +                    warning(info.operation.getEntity(), ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_PART_NOT_FOUND(info.operation.getName().getLocalPart(), name));
  1.1205 +                } else {
  1.1206 +                    error(info.operation.getEntity(), ModelerMessages.WSDLMODELER_ERROR_PART_NOT_FOUND(info.operation.getName().getLocalPart(), name));
  1.1207 +                }
  1.1208 +                return null;
  1.1209 +            }
  1.1210 +            request.addParameter(inParameter);
  1.1211 +            inParameter.setParameterIndex(parameterOrderPosition);
  1.1212 +            parameterOrderPosition++;
  1.1213 +        }
  1.1214 +
  1.1215 +        operation.setResponse(response);
  1.1216 +
  1.1217 +        //  add callback handlerb Parameter to request
  1.1218 +        if (operation.getAsyncType().equals(AsyncOperationType.CALLBACK)) {
  1.1219 +            JavaType cbJavaType = operation.getCallBackType();
  1.1220 +            JAXBType callbackType = new JAXBType(respBeanName, cbJavaType);
  1.1221 +            Parameter cbParam = ModelerUtils.createParameter("asyncHandler", callbackType, block);
  1.1222 +            request.addParameter(cbParam);
  1.1223 +        }
  1.1224 +
  1.1225 +        operation.setRequest(request);
  1.1226 +
  1.1227 +        return operation;
  1.1228 +    }
  1.1229 +
  1.1230 +    protected boolean isAsync(com.sun.tools.internal.ws.wsdl.document.PortType portType, com.sun.tools.internal.ws.wsdl.document.Operation wsdlOperation) {
  1.1231 +        //First look into wsdl:operation
  1.1232 +        JAXWSBinding jaxwsCustomization = (JAXWSBinding) getExtensionOfType(wsdlOperation, JAXWSBinding.class);
  1.1233 +        Boolean isAsync = (jaxwsCustomization != null) ? jaxwsCustomization.isEnableAsyncMapping() : null;
  1.1234 +
  1.1235 +        if (isAsync != null) {
  1.1236 +            return isAsync;
  1.1237 +        }
  1.1238 +
  1.1239 +        // then into wsdl:portType
  1.1240 +        jaxwsCustomization = (JAXWSBinding) getExtensionOfType(portType, JAXWSBinding.class);
  1.1241 +        isAsync = (jaxwsCustomization != null) ? jaxwsCustomization.isEnableAsyncMapping() : null;
  1.1242 +        if (isAsync != null) {
  1.1243 +            return isAsync;
  1.1244 +        }
  1.1245 +
  1.1246 +        //then wsdl:definitions
  1.1247 +        jaxwsCustomization = (JAXWSBinding) getExtensionOfType(document.getDefinitions(), JAXWSBinding.class);
  1.1248 +        isAsync = (jaxwsCustomization != null) ? jaxwsCustomization.isEnableAsyncMapping() : null;
  1.1249 +        if (isAsync != null) {
  1.1250 +            return isAsync;
  1.1251 +        }
  1.1252 +        return false;
  1.1253 +    }
  1.1254 +
  1.1255 +    protected void handleLiteralSOAPHeaders(Request request, Response response, Iterator headerParts, Set duplicateNames, @NotNull List<String> definitiveParameterList, boolean processRequest) {
  1.1256 +        QName headerName;
  1.1257 +        Block headerBlock;
  1.1258 +        JAXBType jaxbType;
  1.1259 +        int parameterOrderPosition = definitiveParameterList.size();
  1.1260 +        while (headerParts.hasNext()) {
  1.1261 +            MessagePart part = (MessagePart) headerParts.next();
  1.1262 +            headerName = part.getDescriptor();
  1.1263 +            jaxbType = getJAXBType(part);
  1.1264 +            headerBlock = new Block(headerName, jaxbType, part);
  1.1265 +            TWSDLExtensible ext;
  1.1266 +            if (processRequest) {
  1.1267 +                ext = info.bindingOperation.getInput();
  1.1268 +            } else {
  1.1269 +                ext = info.bindingOperation.getOutput();
  1.1270 +            }
  1.1271 +            Message headerMessage = getHeaderMessage(part, ext);
  1.1272 +
  1.1273 +            if (processRequest) {
  1.1274 +                request.addHeaderBlock(headerBlock);
  1.1275 +            } else {
  1.1276 +                response.addHeaderBlock(headerBlock);
  1.1277 +            }
  1.1278 +
  1.1279 +            Parameter parameter = ModelerUtils.createParameter(part.getName(), jaxbType, headerBlock);
  1.1280 +            parameter.setParameterIndex(parameterOrderPosition);
  1.1281 +            setCustomizedParameterName(info.bindingOperation, headerMessage, part, parameter, false);
  1.1282 +            if (processRequest) {
  1.1283 +                request.addParameter(parameter);
  1.1284 +                definitiveParameterList.add(parameter.getName());
  1.1285 +            } else {
  1.1286 +                for (String inParamName : definitiveParameterList) {
  1.1287 +                    if (inParamName.equals(parameter.getName())) {
  1.1288 +                        Parameter inParam = request.getParameterByName(inParamName);
  1.1289 +                        parameter.setLinkedParameter(inParam);
  1.1290 +                        inParam.setLinkedParameter(parameter);
  1.1291 +                        //its in/out parameter, input and output parameter have the same order position.
  1.1292 +                        parameter.setParameterIndex(inParam.getParameterIndex());
  1.1293 +                    }
  1.1294 +                }
  1.1295 +                if (!definitiveParameterList.contains(parameter.getName())) {
  1.1296 +                    definitiveParameterList.add(parameter.getName());
  1.1297 +                }
  1.1298 +                response.addParameter(parameter);
  1.1299 +            }
  1.1300 +            parameterOrderPosition++;
  1.1301 +        }
  1.1302 +
  1.1303 +    }
  1.1304 +
  1.1305 +    protected void handleLiteralSOAPFault(Response response, Set duplicateNames) {
  1.1306 +        for (BindingFault bindingFault : info.bindingOperation.faults()) {
  1.1307 +            com.sun.tools.internal.ws.wsdl.document.Fault portTypeFault = null;
  1.1308 +            for (com.sun.tools.internal.ws.wsdl.document.Fault aFault : info.portTypeOperation.faults()) {
  1.1309 +                if (aFault.getName().equals(bindingFault.getName())) {
  1.1310 +                    if (portTypeFault != null) {
  1.1311 +                        // the WSDL document is invalid, a wsld:fault in a wsdl:operation of a portType can be bound only once
  1.1312 +                        error(portTypeFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_NOT_UNIQUE(bindingFault.getName(), info.bindingOperation.getName()));
  1.1313 +                    }
  1.1314 +                    portTypeFault = aFault;
  1.1315 +                }
  1.1316 +            }
  1.1317 +
  1.1318 +            // The WSDL document is invalid, the wsdl:fault in abstract operation is does not have any binding
  1.1319 +            if (portTypeFault == null) {
  1.1320 +                error(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_NOT_FOUND(bindingFault.getName(), info.bindingOperation.getName()));
  1.1321 +
  1.1322 +            }
  1.1323 +        }
  1.1324 +        for ( com.sun.tools.internal.ws.wsdl.document.Fault portTypeFault : info.portTypeOperation.faults()) {
  1.1325 +
  1.1326 +            BindingFault bindingFault = null ;
  1.1327 +            for(BindingFault bFault: info.bindingOperation.faults()) {
  1.1328 +                if (bFault.getName().equals(portTypeFault.getName())) {
  1.1329 +                    bindingFault = bFault;
  1.1330 +                }
  1.1331 +            }
  1.1332 +
  1.1333 +            if(bindingFault == null) {
  1.1334 +                warning(portTypeFault,ModelerMessages.WSDLMODELER_INVALID_PORT_TYPE_FAULT_NOT_FOUND(portTypeFault.getName(),info.portTypeOperation.getName()));
  1.1335 +            }
  1.1336 +            // wsdl:fault message name is used to create the java exception name later on
  1.1337 +            String faultName = getFaultClassName(portTypeFault);
  1.1338 +            Fault fault = new Fault(faultName, portTypeFault);
  1.1339 +            fault.setWsdlFaultName(portTypeFault.getName());
  1.1340 +            setDocumentationIfPresent(fault, portTypeFault.getDocumentation());
  1.1341 +            if (bindingFault != null) {
  1.1342 +                //get the soapbind:fault from wsdl:fault in the binding
  1.1343 +                SOAPFault soapFault = (SOAPFault) getExtensionOfType(bindingFault, SOAPFault.class);
  1.1344 +
  1.1345 +                // The WSDL document is invalid, can't have wsdl:fault without soapbind:fault
  1.1346 +                if (soapFault == null) {
  1.1347 +                    if (options.isExtensionMode()) {
  1.1348 +                        warning(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_OUTPUT_MISSING_SOAP_FAULT(bindingFault.getName(), info.bindingOperation.getName()));
  1.1349 +                        soapFault = new SOAPFault(new LocatorImpl());
  1.1350 +                    } else {
  1.1351 +                        error(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_OUTPUT_MISSING_SOAP_FAULT(bindingFault.getName(), info.bindingOperation.getName()));
  1.1352 +                    }
  1.1353 +                }
  1.1354 +
  1.1355 +                //the soapbind:fault must have use="literal" or no use attribute, in that case its assumed "literal"
  1.1356 +                if (!soapFault.isLiteral()) {
  1.1357 +                    if (options.isExtensionMode()) {
  1.1358 +                        warning(soapFault, ModelerMessages.WSDLMODELER_WARNING_IGNORING_FAULT_NOT_LITERAL(bindingFault.getName(), info.bindingOperation.getName()));
  1.1359 +                    } else {
  1.1360 +                        error(soapFault, ModelerMessages.WSDLMODELER_INVALID_OPERATION_FAULT_NOT_LITERAL(bindingFault.getName(), info.bindingOperation.getName()));
  1.1361 +                    }
  1.1362 +                    continue;
  1.1363 +                }
  1.1364 +
  1.1365 +                // the soapFault name must be present
  1.1366 +                if (soapFault.getName() == null) {
  1.1367 +                    warning(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_NO_SOAP_FAULT_NAME(bindingFault.getName(), info.bindingOperation.getName()));
  1.1368 +                } else if (!soapFault.getName().equals(bindingFault.getName())) {
  1.1369 +                    warning(soapFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_WRONG_SOAP_FAULT_NAME(soapFault.getName(), bindingFault.getName(), info.bindingOperation.getName()));
  1.1370 +                } else if (soapFault.getNamespace() != null) {
  1.1371 +                    warning(soapFault, ModelerMessages.WSDLMODELER_WARNING_R_2716_R_2726("soapbind:fault", soapFault.getName()));
  1.1372 +                }
  1.1373 +
  1.1374 +            }
  1.1375 +
  1.1376 +            com.sun.tools.internal.ws.wsdl.document.Message faultMessage = portTypeFault.resolveMessage(info.document);
  1.1377 +            Iterator iter2 = faultMessage.parts();
  1.1378 +            if (!iter2.hasNext()) {
  1.1379 +                // the WSDL document is invalid
  1.1380 +                error(faultMessage, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_EMPTY_MESSAGE(portTypeFault.getName(), faultMessage.getName()));
  1.1381 +            }
  1.1382 +            MessagePart faultPart = (MessagePart) iter2.next();
  1.1383 +            QName faultQName = faultPart.getDescriptor();
  1.1384 +
  1.1385 +            // Don't include fault messages with non-unique soap:fault names
  1.1386 +            if (duplicateNames.contains(faultQName)) {
  1.1387 +                warning(faultPart, ModelerMessages.WSDLMODELER_DUPLICATE_FAULT_SOAP_NAME(portTypeFault.getName(), info.portTypeOperation.getName(), faultPart.getName()));
  1.1388 +                continue;
  1.1389 +            }
  1.1390 +
  1.1391 +            if (iter2.hasNext()) {
  1.1392 +                // the WSDL document is invalid
  1.1393 +                error(faultMessage, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_MESSAGE_HAS_MORE_THAN_ONE_PART(portTypeFault.getName(), faultMessage.getName()));
  1.1394 +            }
  1.1395 +
  1.1396 +            if (faultPart.getDescriptorKind() != SchemaKinds.XSD_ELEMENT) {
  1.1397 +                if (options.isExtensionMode()) {
  1.1398 +                    warning(faultPart, ModelerMessages.WSDLMODELER_INVALID_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(faultMessage.getName(), faultPart.getName()));
  1.1399 +                } else {
  1.1400 +                    error(faultPart, ModelerMessages.WSDLMODELER_INVALID_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(faultMessage.getName(), faultPart.getName()));
  1.1401 +                }
  1.1402 +            }
  1.1403 +
  1.1404 +            JAXBType jaxbType = getJAXBType(faultPart);
  1.1405 +
  1.1406 +            fault.setElementName(faultPart.getDescriptor());
  1.1407 +            fault.setJavaMemberName(Names.getExceptionClassMemberName());
  1.1408 +
  1.1409 +            Block faultBlock = new Block(faultQName, jaxbType, faultPart);
  1.1410 +            fault.setBlock(faultBlock);
  1.1411 +            //createParentFault(fault);
  1.1412 +            //createSubfaults(fault);
  1.1413 +            if (!response.getFaultBlocksMap().containsKey(faultBlock.getName())) {
  1.1414 +                response.addFaultBlock(faultBlock);
  1.1415 +            }
  1.1416 +            info.operation.addFault(fault);
  1.1417 +        }
  1.1418 +    }
  1.1419 +
  1.1420 +    private String getFaultClassName(com.sun.tools.internal.ws.wsdl.document.Fault portTypeFault) {
  1.1421 +        JAXWSBinding jaxwsBinding = (JAXWSBinding) getExtensionOfType(portTypeFault, JAXWSBinding.class);
  1.1422 +        if (jaxwsBinding != null) {
  1.1423 +            CustomName className = jaxwsBinding.getClassName();
  1.1424 +            if (className != null) {
  1.1425 +                return makePackageQualified(className.getName());
  1.1426 +            }
  1.1427 +        }
  1.1428 +        return makePackageQualified(BindingHelper.mangleNameToClassName(portTypeFault.getMessage().getLocalPart()));
  1.1429 +    }
  1.1430 +
  1.1431 +    protected boolean setMessagePartsBinding(StyleAndUse styleAndUse) {
  1.1432 +        SOAPBody inBody = getSOAPRequestBody();
  1.1433 +        Message inMessage = getInputMessage();
  1.1434 +        if (!setMessagePartsBinding(inBody, inMessage, styleAndUse, true)) {
  1.1435 +            return false;
  1.1436 +        }
  1.1437 +
  1.1438 +        if (isRequestResponse()) {
  1.1439 +            SOAPBody outBody = getSOAPResponseBody();
  1.1440 +            Message outMessage = getOutputMessage();
  1.1441 +            if (!setMessagePartsBinding(outBody, outMessage, styleAndUse, false)) {
  1.1442 +                return false;
  1.1443 +            }
  1.1444 +        }
  1.1445 +        return true;
  1.1446 +    }
  1.1447 +
  1.1448 +    //returns false if the wsdl is invalid and operation should be ignored
  1.1449 +    protected boolean setMessagePartsBinding(SOAPBody body, Message message, StyleAndUse styleAndUse, boolean isInput) {
  1.1450 +
  1.1451 +        //get Mime parts
  1.1452 +        List<MessagePart> mimeParts;
  1.1453 +        List<MessagePart> headerParts;
  1.1454 +        List<MessagePart> bodyParts = getBodyParts(body, message);
  1.1455 +
  1.1456 +        if (isInput) {
  1.1457 +            headerParts = getHeaderPartsFromMessage(message, isInput);
  1.1458 +            mimeParts = getMimeContentParts(message, info.bindingOperation.getInput());
  1.1459 +        } else {
  1.1460 +            headerParts = getHeaderPartsFromMessage(message, isInput);
  1.1461 +            mimeParts = getMimeContentParts(message, info.bindingOperation.getOutput());
  1.1462 +        }
  1.1463 +
  1.1464 +        //As of now WSDL MIME binding is not supported, so throw the exception when such binding is encounterd
  1.1465 +//        if(mimeParts.size() > 0){
  1.1466 +//            fail("wsdlmodeler.unsupportedBinding.mime", new Object[]{});
  1.1467 +//        }
  1.1468 +
  1.1469 +        //if soap:body parts attribute not there, then all unbounded message parts will
  1.1470 +        // belong to the soap body
  1.1471 +        if (bodyParts == null) {
  1.1472 +            bodyParts = new ArrayList<MessagePart>();
  1.1473 +            for (Iterator<MessagePart> iter = message.parts(); iter.hasNext();) {
  1.1474 +                MessagePart mPart = iter.next();
  1.1475 +                //Its a safe assumption that the parts in the message not belonging to header or mime will
  1.1476 +                // belong to the body?
  1.1477 +                if (mimeParts.contains(mPart) || headerParts.contains(mPart) || boundToFault(mPart.getName())) {
  1.1478 +                    //throw error that a part cant be bound multiple times, not ignoring operation, if there
  1.1479 +                    //is conflict it will fail latter
  1.1480 +                    if (options.isExtensionMode()) {
  1.1481 +                        warning(mPart, ModelerMessages.WSDLMODELER_WARNING_BINDING_OPERATION_MULTIPLE_PART_BINDING(info.bindingOperation.getName(), mPart.getName()));
  1.1482 +                    } else {
  1.1483 +                        error(mPart, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_MULTIPLE_PART_BINDING(info.bindingOperation.getName(), mPart.getName()));
  1.1484 +                    }
  1.1485 +                }
  1.1486 +                bodyParts.add(mPart);
  1.1487 +            }
  1.1488 +        }
  1.1489 +
  1.1490 +        //now build the final parts list with header, mime parts and body parts
  1.1491 +        for (Iterator iter = message.parts(); iter.hasNext();) {
  1.1492 +            MessagePart mPart = (MessagePart) iter.next();
  1.1493 +            if (mimeParts.contains(mPart)) {
  1.1494 +                mPart.setBindingExtensibilityElementKind(MessagePart.WSDL_MIME_BINDING);
  1.1495 +            } else if (headerParts.contains(mPart)) {
  1.1496 +                mPart.setBindingExtensibilityElementKind(MessagePart.SOAP_HEADER_BINDING);
  1.1497 +            } else if (bodyParts.contains(mPart)) {
  1.1498 +                mPart.setBindingExtensibilityElementKind(MessagePart.SOAP_BODY_BINDING);
  1.1499 +            } else {
  1.1500 +                mPart.setBindingExtensibilityElementKind(MessagePart.PART_NOT_BOUNDED);
  1.1501 +            }
  1.1502 +        }
  1.1503 +
  1.1504 +        if (isOperationDocumentLiteral(styleAndUse) && bodyParts.size() > 1) {
  1.1505 +            if (options.isExtensionMode()) {
  1.1506 +                warning(message, ModelerMessages.WSDLMODELER_WARNING_OPERATION_MORE_THAN_ONE_PART_IN_MESSAGE(info.portTypeOperation.getName()));
  1.1507 +            } else {
  1.1508 +                error(message, ModelerMessages.WSDLMODELER_INVALID_OPERATION_MORE_THAN_ONE_PART_IN_MESSAGE(info.portTypeOperation.getName()));
  1.1509 +            }
  1.1510 +            return false;
  1.1511 +        }
  1.1512 +        return true;
  1.1513 +    }
  1.1514 +
  1.1515 +    private boolean boundToFault(String partName) {
  1.1516 +        for (BindingFault bindingFault : info.bindingOperation.faults()) {
  1.1517 +            if (partName.equals(bindingFault.getName())) {
  1.1518 +                return true;
  1.1519 +            }
  1.1520 +        }
  1.1521 +        return false;
  1.1522 +    }
  1.1523 +
  1.1524 +    //get MessagePart(s) referenced by parts attribute of soap:body element
  1.1525 +    private List<MessagePart> getBodyParts(SOAPBody body, Message message) {
  1.1526 +        String bodyParts = body.getParts();
  1.1527 +        if (bodyParts != null) {
  1.1528 +            List<MessagePart> partsList = new ArrayList<MessagePart>();
  1.1529 +            StringTokenizer in = new StringTokenizer(bodyParts.trim(), " ");
  1.1530 +            while (in.hasMoreTokens()) {
  1.1531 +                String part = in.nextToken();
  1.1532 +                MessagePart mPart = message.getPart(part);
  1.1533 +                if (null == mPart) {
  1.1534 +                    error(message, ModelerMessages.WSDLMODELER_ERROR_PARTS_NOT_FOUND(part, message.getName()));
  1.1535 +                }
  1.1536 +                mPart.setBindingExtensibilityElementKind(MessagePart.SOAP_BODY_BINDING);
  1.1537 +                partsList.add(mPart);
  1.1538 +            }
  1.1539 +            return partsList;
  1.1540 +        }
  1.1541 +        return null;
  1.1542 +    }
  1.1543 +
  1.1544 +    List<MessagePart> getAdditionHeaderParts(BindingOperation bindingOperation,Message message, boolean isInput){
  1.1545 +        List<MessagePart> headerParts = new ArrayList<MessagePart>();
  1.1546 +        List<MessagePart> parts = message.getParts();
  1.1547 +        List<MessagePart> headers = getHeaderParts(bindingOperation, isInput);
  1.1548 +
  1.1549 +        for(MessagePart part: headers){
  1.1550 +            if (parts.contains(part)) {
  1.1551 +                continue;
  1.1552 +            }
  1.1553 +            headerParts.add(part);
  1.1554 +        }
  1.1555 +        return headerParts;
  1.1556 +    }
  1.1557 +
  1.1558 +    private List<MessagePart> getHeaderPartsFromMessage(Message message, boolean isInput) {
  1.1559 +        List<MessagePart> headerParts = new ArrayList<MessagePart>();
  1.1560 +        Iterator<MessagePart> parts = message.parts();
  1.1561 +        List<MessagePart> headers = getHeaderParts(info.bindingOperation, isInput);
  1.1562 +        while (parts.hasNext()) {
  1.1563 +            MessagePart part = parts.next();
  1.1564 +            if (headers.contains(part)) {
  1.1565 +                headerParts.add(part);
  1.1566 +            }
  1.1567 +        }
  1.1568 +        return headerParts;
  1.1569 +    }
  1.1570 +
  1.1571 +    private Message getHeaderMessage(MessagePart part, TWSDLExtensible ext) {
  1.1572 +        Iterator<SOAPHeader> headers = getHeaderExtensions(ext).iterator();
  1.1573 +        while (headers.hasNext()) {
  1.1574 +            SOAPHeader header = headers.next();
  1.1575 +            if (!header.isLiteral()) {
  1.1576 +                continue;
  1.1577 +            }
  1.1578 +            com.sun.tools.internal.ws.wsdl.document.Message headerMessage = findMessage(header.getMessage(), document);
  1.1579 +            if (headerMessage == null) {
  1.1580 +                continue;
  1.1581 +            }
  1.1582 +
  1.1583 +            MessagePart headerPart = headerMessage.getPart(header.getPart());
  1.1584 +            if (headerPart == part) {
  1.1585 +                return headerMessage;
  1.1586 +            }
  1.1587 +        }
  1.1588 +        return null;
  1.1589 +    }
  1.1590 +
  1.1591 +    private List<MessagePart> getHeaderParts(BindingOperation bindingOperation, boolean isInput) {
  1.1592 +        TWSDLExtensible ext;
  1.1593 +        if (isInput) {
  1.1594 +            ext = bindingOperation.getInput();
  1.1595 +        } else {
  1.1596 +            ext = bindingOperation.getOutput();
  1.1597 +        }
  1.1598 +
  1.1599 +        List<MessagePart> parts = new ArrayList<MessagePart>();
  1.1600 +        Iterator<SOAPHeader> headers = getHeaderExtensions(ext).iterator();
  1.1601 +        while (headers.hasNext()) {
  1.1602 +            SOAPHeader header = headers.next();
  1.1603 +            if (!header.isLiteral()) {
  1.1604 +                error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_NOT_LITERAL(header.getPart(), bindingOperation.getName()));
  1.1605 +            }
  1.1606 +
  1.1607 +            if (header.getNamespace() != null) {
  1.1608 +                warning(header, ModelerMessages.WSDLMODELER_WARNING_R_2716_R_2726("soapbind:header", bindingOperation.getName()));
  1.1609 +            }
  1.1610 +            com.sun.tools.internal.ws.wsdl.document.Message headerMessage = findMessage(header.getMessage(),document);
  1.1611 +            if (headerMessage == null) {
  1.1612 +                error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_CANT_RESOLVE_MESSAGE(header.getMessage(), bindingOperation.getName()));
  1.1613 +            }
  1.1614 +
  1.1615 +            MessagePart part = headerMessage.getPart(header.getPart());
  1.1616 +            if (part == null) {
  1.1617 +                error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_NOT_FOUND(header.getPart(), bindingOperation.getName()));
  1.1618 +            }
  1.1619 +            if (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT) {
  1.1620 +                if (options.isExtensionMode()) {
  1.1621 +                    warning(part, ModelerMessages.WSDLMODELER_INVALID_HEADER_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(part.getName(), bindingOperation.getName()));
  1.1622 +                } else {
  1.1623 +                    error(part, ModelerMessages.WSDLMODELER_INVALID_HEADER_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(part.getName(), bindingOperation.getName()));
  1.1624 +                }
  1.1625 +            }
  1.1626 +            part.setBindingExtensibilityElementKind(MessagePart.SOAP_HEADER_BINDING);
  1.1627 +            parts.add(part);
  1.1628 +        }
  1.1629 +        return parts;
  1.1630 +    }
  1.1631 +
  1.1632 +    private boolean isOperationDocumentLiteral(StyleAndUse styleAndUse) {
  1.1633 +        return StyleAndUse.DOC_LITERAL == styleAndUse;
  1.1634 +    }
  1.1635 +
  1.1636 +    private boolean isOperationRpcLiteral(StyleAndUse styleAndUse) {
  1.1637 +        return StyleAndUse.RPC_LITERAL == styleAndUse;
  1.1638 +    }
  1.1639 +
  1.1640 +    /**
  1.1641 +     * @param part
  1.1642 +     * @return Returns a JAXBType object
  1.1643 +     */
  1.1644 +    private JAXBType getJAXBType(MessagePart part) {
  1.1645 +        JAXBType type;
  1.1646 +        QName name = part.getDescriptor();
  1.1647 +        if (part.getDescriptorKind().equals(SchemaKinds.XSD_ELEMENT)) {
  1.1648 +            type = getJAXBModelBuilder().getJAXBType(name);
  1.1649 +            if(type == null){
  1.1650 +                error(part, ModelerMessages.WSDLMODELER_JAXB_JAVATYPE_NOTFOUND(name, part.getName()));
  1.1651 +            }
  1.1652 +        } else {
  1.1653 +            S2JJAXBModel jaxbModel = getJAXBModelBuilder().getJAXBModel().getS2JJAXBModel();
  1.1654 +            TypeAndAnnotation typeAnno = jaxbModel.getJavaType(name);
  1.1655 +            if (typeAnno == null) {
  1.1656 +                error(part, ModelerMessages.WSDLMODELER_JAXB_JAVATYPE_NOTFOUND(name, part.getName()));
  1.1657 +            }
  1.1658 +            JavaType javaType = new JavaSimpleType(new JAXBTypeAndAnnotation(typeAnno));
  1.1659 +            type = new JAXBType(new QName("", part.getName()), javaType);
  1.1660 +        }
  1.1661 +        return type;
  1.1662 +    }
  1.1663 +
  1.1664 +    private List<Parameter> getDoclitParameters(Request req, Response res, List<MessagePart> parameterList) {
  1.1665 +        if (parameterList.isEmpty()) {
  1.1666 +            return new ArrayList<Parameter>();
  1.1667 +        }
  1.1668 +        List<Parameter> params = new ArrayList<Parameter>();
  1.1669 +        Message inMsg = getInputMessage();
  1.1670 +        Message outMsg = getOutputMessage();
  1.1671 +        boolean unwrappable = isUnwrappable();
  1.1672 +        List<Parameter> outParams = null;
  1.1673 +        int pIndex = 0;
  1.1674 +        for (MessagePart part : parameterList) {
  1.1675 +            QName reqBodyName = part.getDescriptor();
  1.1676 +            JAXBType jaxbType = getJAXBType(part);
  1.1677 +            Block block = new Block(reqBodyName, jaxbType, part);
  1.1678 +            if (unwrappable) {
  1.1679 +                //So build body and header blocks and set to request and response
  1.1680 +                JAXBStructuredType jaxbStructType = ModelerUtils.createJAXBStructureType(jaxbType);
  1.1681 +                block = new Block(reqBodyName, jaxbStructType, part);
  1.1682 +                if (ModelerUtils.isBoundToSOAPBody(part)) {
  1.1683 +                    if (part.isIN()) {
  1.1684 +                        req.addBodyBlock(block);
  1.1685 +                    } else if (part.isOUT()) {
  1.1686 +                        res.addBodyBlock(block);
  1.1687 +                    } else if (part.isINOUT()) {
  1.1688 +                        req.addBodyBlock(block);
  1.1689 +                        res.addBodyBlock(block);
  1.1690 +                    }
  1.1691 +                } else if (ModelerUtils.isUnbound(part)) {
  1.1692 +                    if (part.isIN()) {
  1.1693 +                        req.addUnboundBlock(block);
  1.1694 +                    } else if (part.isOUT()) {
  1.1695 +                        res.addUnboundBlock(block);
  1.1696 +                    } else if (part.isINOUT()) {
  1.1697 +                        req.addUnboundBlock(block);
  1.1698 +                        res.addUnboundBlock(block);
  1.1699 +                    }
  1.1700 +                }
  1.1701 +                if (part.isIN() || part.isINOUT()) {
  1.1702 +                    params = ModelerUtils.createUnwrappedParameters(jaxbStructType, block);
  1.1703 +                    int index = 0;
  1.1704 +                    Mode mode = part.isINOUT() ? Mode.INOUT : Mode.IN;
  1.1705 +                    for (Parameter param : params) {
  1.1706 +                        param.setParameterIndex(index++);
  1.1707 +                        param.setMode(mode);
  1.1708 +                        setCustomizedParameterName(info.portTypeOperation, inMsg, part, param, unwrappable);
  1.1709 +                    }
  1.1710 +                } else if (part.isOUT()) {
  1.1711 +                    outParams = ModelerUtils.createUnwrappedParameters(jaxbStructType, block);
  1.1712 +                    for (Parameter param : outParams) {
  1.1713 +                        param.setMode(Mode.OUT);
  1.1714 +                        setCustomizedParameterName(info.portTypeOperation, outMsg, part, param, unwrappable);
  1.1715 +                    }
  1.1716 +                }
  1.1717 +            } else {
  1.1718 +                if (ModelerUtils.isBoundToSOAPBody(part)) {
  1.1719 +                    if (part.isIN()) {
  1.1720 +                        req.addBodyBlock(block);
  1.1721 +                    } else if (part.isOUT()) {
  1.1722 +                        res.addBodyBlock(block);
  1.1723 +                    } else if (part.isINOUT()) {
  1.1724 +                        req.addBodyBlock(block);
  1.1725 +                        res.addBodyBlock(block);
  1.1726 +                    }
  1.1727 +                } else if (ModelerUtils.isBoundToSOAPHeader(part)) {
  1.1728 +                    if (part.isIN()) {
  1.1729 +                        req.addHeaderBlock(block);
  1.1730 +                    } else if (part.isOUT()) {
  1.1731 +                        res.addHeaderBlock(block);
  1.1732 +                    } else if (part.isINOUT()) {
  1.1733 +                        req.addHeaderBlock(block);
  1.1734 +                        res.addHeaderBlock(block);
  1.1735 +                    }
  1.1736 +                } else if (ModelerUtils.isBoundToMimeContent(part)) {
  1.1737 +                    List<MIMEContent> mimeContents;
  1.1738 +
  1.1739 +                    if (part.isIN()) {
  1.1740 +                        mimeContents = getMimeContents(info.bindingOperation.getInput(),
  1.1741 +                                getInputMessage(), part.getName());
  1.1742 +                        jaxbType = getAttachmentType(mimeContents, part);
  1.1743 +                        block = new Block(jaxbType.getName(), jaxbType, part);
  1.1744 +                        req.addAttachmentBlock(block);
  1.1745 +                    } else if (part.isOUT()) {
  1.1746 +                        mimeContents = getMimeContents(info.bindingOperation.getOutput(),
  1.1747 +                                getOutputMessage(), part.getName());
  1.1748 +                        jaxbType = getAttachmentType(mimeContents, part);
  1.1749 +                        block = new Block(jaxbType.getName(), jaxbType, part);
  1.1750 +                        res.addAttachmentBlock(block);
  1.1751 +                    } else if (part.isINOUT()) {
  1.1752 +                        mimeContents = getMimeContents(info.bindingOperation.getInput(),
  1.1753 +                                getInputMessage(), part.getName());
  1.1754 +                        jaxbType = getAttachmentType(mimeContents, part);
  1.1755 +                        block = new Block(jaxbType.getName(), jaxbType, part);
  1.1756 +                        req.addAttachmentBlock(block);
  1.1757 +                        res.addAttachmentBlock(block);
  1.1758 +
  1.1759 +                        mimeContents = getMimeContents(info.bindingOperation.getOutput(),
  1.1760 +                                getOutputMessage(), part.getName());
  1.1761 +                        JAXBType outJaxbType = getAttachmentType(mimeContents, part);
  1.1762 +
  1.1763 +                        String inType = jaxbType.getJavaType().getType().getName();
  1.1764 +                        String outType = outJaxbType.getJavaType().getType().getName();
  1.1765 +
  1.1766 +                        TypeAndAnnotation inTa = jaxbType.getJavaType().getType().getTypeAnn();
  1.1767 +                        TypeAndAnnotation outTa = outJaxbType.getJavaType().getType().getTypeAnn();
  1.1768 +                        if ((((inTa != null) && (outTa != null) && inTa.equals(outTa))) && !inType.equals(outType)) {
  1.1769 +                            String javaType = "javax.activation.DataHandler";
  1.1770 +
  1.1771 +                            //S2JJAXBModel jaxbModel = getJAXBModelBuilder().getJAXBModel().getS2JJAXBModel();
  1.1772 +                            //JCodeModel cm = jaxbModel.generateCode(null, errReceiver);
  1.1773 +                            JType jt = options.getCodeModel().ref(javaType);
  1.1774 +                            JAXBTypeAndAnnotation jaxbTa = jaxbType.getJavaType().getType();
  1.1775 +                            jaxbTa.setType(jt);
  1.1776 +                        }
  1.1777 +                    }
  1.1778 +                } else if (ModelerUtils.isUnbound(part)) {
  1.1779 +                    if (part.isIN()) {
  1.1780 +                        req.addUnboundBlock(block);
  1.1781 +                    } else if (part.isOUT()) {
  1.1782 +                        res.addUnboundBlock(block);
  1.1783 +                    } else if (part.isINOUT()) {
  1.1784 +                        req.addUnboundBlock(block);
  1.1785 +                        res.addUnboundBlock(block);
  1.1786 +                    }
  1.1787 +                }
  1.1788 +                Parameter param = ModelerUtils.createParameter(part.getName(), jaxbType, block);
  1.1789 +                param.setMode(part.getMode());
  1.1790 +                if (part.isReturn()) {
  1.1791 +                    param.setParameterIndex(-1);
  1.1792 +                } else {
  1.1793 +                    param.setParameterIndex(pIndex++);
  1.1794 +                }
  1.1795 +
  1.1796 +                if (part.isIN()) {
  1.1797 +                    setCustomizedParameterName(info.bindingOperation, inMsg, part, param, false);
  1.1798 +                } else if (outMsg != null) {
  1.1799 +                    setCustomizedParameterName(info.bindingOperation, outMsg, part, param, false);
  1.1800 +                }
  1.1801 +
  1.1802 +                params.add(param);
  1.1803 +            }
  1.1804 +        }
  1.1805 +        if (unwrappable && (outParams != null)) {
  1.1806 +            int index = params.size();
  1.1807 +            for (Parameter param : outParams) {
  1.1808 +                if (BindingHelper.mangleNameToVariableName(param.getName()).equals("return")) {
  1.1809 +                    param.setParameterIndex(-1);
  1.1810 +                } else {
  1.1811 +                    Parameter inParam = ModelerUtils.getParameter(param.getName(), params);
  1.1812 +                    if ((inParam != null) && inParam.isIN()) {
  1.1813 +                        QName inElementName = inParam.getType().getName();
  1.1814 +                        QName outElementName = param.getType().getName();
  1.1815 +                        String inJavaType = inParam.getTypeName();
  1.1816 +                        String outJavaType = param.getTypeName();
  1.1817 +                        TypeAndAnnotation inTa = inParam.getType().getJavaType().getType().getTypeAnn();
  1.1818 +                        TypeAndAnnotation outTa = param.getType().getJavaType().getType().getTypeAnn();
  1.1819 +                        QName inRawTypeName = ModelerUtils.getRawTypeName(inParam);
  1.1820 +                        QName outRawTypeName = ModelerUtils.getRawTypeName(param);
  1.1821 +                        if (inElementName.getLocalPart().equals(outElementName.getLocalPart()) &&
  1.1822 +                                inJavaType.equals(outJavaType) &&
  1.1823 +                                (inTa == null || outTa == null || inTa.equals(outTa)) &&
  1.1824 +                                (inRawTypeName == null || outRawTypeName == null || inRawTypeName.equals(outRawTypeName))) {
  1.1825 +                            inParam.setMode(Mode.INOUT);
  1.1826 +                            continue;
  1.1827 +                        }
  1.1828 +                    }
  1.1829 +                    if (outParams.size() == 1) {
  1.1830 +                        param.setParameterIndex(-1);
  1.1831 +                    } else {
  1.1832 +                        param.setParameterIndex(index++);
  1.1833 +                    }
  1.1834 +                }
  1.1835 +                params.add(param);
  1.1836 +            }
  1.1837 +        }
  1.1838 +        return params;
  1.1839 +    }
  1.1840 +
  1.1841 +    private List<Parameter> getRpcLitParameters(Request req, Response res, Block reqBlock, Block resBlock, List<MessagePart> paramList) {
  1.1842 +        List<Parameter> params = new ArrayList<Parameter>();
  1.1843 +        Message inMsg = getInputMessage();
  1.1844 +        Message outMsg = getOutputMessage();
  1.1845 +        S2JJAXBModel jaxbModel = ((RpcLitStructure) reqBlock.getType()).getJaxbModel().getS2JJAXBModel();
  1.1846 +        List<Parameter> inParams = ModelerUtils.createRpcLitParameters(inMsg, reqBlock, jaxbModel, errReceiver);
  1.1847 +        List<Parameter> outParams = null;
  1.1848 +        if (outMsg != null) {
  1.1849 +            outParams = ModelerUtils.createRpcLitParameters(outMsg, resBlock, jaxbModel, errReceiver);
  1.1850 +        }
  1.1851 +
  1.1852 +        //create parameters for header and mime parts
  1.1853 +        int index = 0;
  1.1854 +        for (MessagePart part : paramList) {
  1.1855 +            Parameter param = null;
  1.1856 +            if (ModelerUtils.isBoundToSOAPBody(part)) {
  1.1857 +                if (part.isIN()) {
  1.1858 +                    param = ModelerUtils.getParameter(part.getName(), inParams);
  1.1859 +                } else if (outParams != null) {
  1.1860 +                    param = ModelerUtils.getParameter(part.getName(), outParams);
  1.1861 +                }
  1.1862 +            } else if (ModelerUtils.isBoundToSOAPHeader(part)) {
  1.1863 +                QName headerName = part.getDescriptor();
  1.1864 +                JAXBType jaxbType = getJAXBType(part);
  1.1865 +                Block headerBlock = new Block(headerName, jaxbType, part);
  1.1866 +                param = ModelerUtils.createParameter(part.getName(), jaxbType, headerBlock);
  1.1867 +                if (part.isIN()) {
  1.1868 +                    req.addHeaderBlock(headerBlock);
  1.1869 +                } else if (part.isOUT()) {
  1.1870 +                    res.addHeaderBlock(headerBlock);
  1.1871 +                } else if (part.isINOUT()) {
  1.1872 +                    req.addHeaderBlock(headerBlock);
  1.1873 +                    res.addHeaderBlock(headerBlock);
  1.1874 +                }
  1.1875 +            } else if (ModelerUtils.isBoundToMimeContent(part)) {
  1.1876 +                List<MIMEContent> mimeContents;
  1.1877 +                if (part.isIN() || part.isINOUT()) {
  1.1878 +                    mimeContents = getMimeContents(info.bindingOperation.getInput(),
  1.1879 +                            getInputMessage(), part.getName());
  1.1880 +                } else {
  1.1881 +                    mimeContents = getMimeContents(info.bindingOperation.getOutput(),
  1.1882 +                            getOutputMessage(), part.getName());
  1.1883 +                }
  1.1884 +
  1.1885 +                JAXBType type = getAttachmentType(mimeContents, part);
  1.1886 +                //create Parameters in request or response
  1.1887 +                //Block mimeBlock = new Block(new QName(part.getName()), type);
  1.1888 +                Block mimeBlock = new Block(type.getName(), type, part);
  1.1889 +                param = ModelerUtils.createParameter(part.getName(), type, mimeBlock);
  1.1890 +                if (part.isIN()) {
  1.1891 +                    req.addAttachmentBlock(mimeBlock);
  1.1892 +                } else if (part.isOUT()) {
  1.1893 +                    res.addAttachmentBlock(mimeBlock);
  1.1894 +                } else if (part.isINOUT()) {
  1.1895 +                    mimeContents = getMimeContents(info.bindingOperation.getOutput(),
  1.1896 +                            getOutputMessage(), part.getName());
  1.1897 +                    JAXBType outJaxbType = getAttachmentType(mimeContents, part);
  1.1898 +
  1.1899 +                    String inType = type.getJavaType().getType().getName();
  1.1900 +                    String outType = outJaxbType.getJavaType().getType().getName();
  1.1901 +                    if (!inType.equals(outType)) {
  1.1902 +                        String javaType = "javax.activation.DataHandler";
  1.1903 +                        JType jt = options.getCodeModel().ref(javaType);
  1.1904 +                        JAXBTypeAndAnnotation jaxbTa = type.getJavaType().getType();
  1.1905 +                        jaxbTa.setType(jt);
  1.1906 +                    }
  1.1907 +                    req.addAttachmentBlock(mimeBlock);
  1.1908 +                    res.addAttachmentBlock(mimeBlock);
  1.1909 +                }
  1.1910 +            } else if (ModelerUtils.isUnbound(part)) {
  1.1911 +                QName name = part.getDescriptor();
  1.1912 +                JAXBType type = getJAXBType(part);
  1.1913 +                Block unboundBlock = new Block(name, type, part);
  1.1914 +                if (part.isIN()) {
  1.1915 +                    req.addUnboundBlock(unboundBlock);
  1.1916 +                } else if (part.isOUT()) {
  1.1917 +                    res.addUnboundBlock(unboundBlock);
  1.1918 +                } else if (part.isINOUT()) {
  1.1919 +                    req.addUnboundBlock(unboundBlock);
  1.1920 +                    res.addUnboundBlock(unboundBlock);
  1.1921 +                }
  1.1922 +                param = ModelerUtils.createParameter(part.getName(), type, unboundBlock);
  1.1923 +            }
  1.1924 +            if (param != null) {
  1.1925 +                if (part.isReturn()) {
  1.1926 +                    param.setParameterIndex(-1);
  1.1927 +                } else {
  1.1928 +                    param.setParameterIndex(index++);
  1.1929 +                }
  1.1930 +                param.setMode(part.getMode());
  1.1931 +                params.add(param);
  1.1932 +            }
  1.1933 +        }
  1.1934 +        for (Parameter param : params) {
  1.1935 +            if (param.isIN()) {
  1.1936 +                setCustomizedParameterName(info.portTypeOperation, inMsg, inMsg.getPart(param.getName()), param, false);
  1.1937 +            } else if (outMsg != null) {
  1.1938 +                setCustomizedParameterName(info.portTypeOperation, outMsg, outMsg.getPart(param.getName()), param, false);
  1.1939 +            }
  1.1940 +        }
  1.1941 +        return params;
  1.1942 +    }
  1.1943 +
  1.1944 +    private List<Parameter> getRequestParameters(Request request, List<String> parameterList) {
  1.1945 +        Message inputMessage = getInputMessage();
  1.1946 +        //there is no input message, return zero parameters
  1.1947 +        if (inputMessage != null && !inputMessage.parts().hasNext()) {
  1.1948 +            return new ArrayList<Parameter>();
  1.1949 +        }
  1.1950 +
  1.1951 +        List<Parameter> inParameters = null;
  1.1952 +        QName reqBodyName;
  1.1953 +        Block reqBlock;
  1.1954 +        JAXBType jaxbReqType;
  1.1955 +        boolean unwrappable = isUnwrappable();
  1.1956 +        boolean doneSOAPBody = false;
  1.1957 +        //setup request parameters
  1.1958 +        for (String inParamName : parameterList) {
  1.1959 +            MessagePart part = inputMessage.getPart(inParamName);
  1.1960 +            if (part == null) {
  1.1961 +                continue;
  1.1962 +            }
  1.1963 +            reqBodyName = part.getDescriptor();
  1.1964 +            jaxbReqType = getJAXBType(part);
  1.1965 +            if (unwrappable) {
  1.1966 +                //So build body and header blocks and set to request and response
  1.1967 +                JAXBStructuredType jaxbRequestType = ModelerUtils.createJAXBStructureType(jaxbReqType);
  1.1968 +                reqBlock = new Block(reqBodyName, jaxbRequestType, part);
  1.1969 +                if (ModelerUtils.isBoundToSOAPBody(part)) {
  1.1970 +                    request.addBodyBlock(reqBlock);
  1.1971 +                } else if (ModelerUtils.isUnbound(part)) {
  1.1972 +                    request.addUnboundBlock(reqBlock);
  1.1973 +                }
  1.1974 +                inParameters = ModelerUtils.createUnwrappedParameters(jaxbRequestType, reqBlock);
  1.1975 +                for (Parameter param : inParameters) {
  1.1976 +                    setCustomizedParameterName(info.portTypeOperation, inputMessage, part, param, unwrappable);
  1.1977 +                }
  1.1978 +            } else {
  1.1979 +                reqBlock = new Block(reqBodyName, jaxbReqType, part);
  1.1980 +                if (ModelerUtils.isBoundToSOAPBody(part) && !doneSOAPBody) {
  1.1981 +                    doneSOAPBody = true;
  1.1982 +                    request.addBodyBlock(reqBlock);
  1.1983 +                } else if (ModelerUtils.isBoundToSOAPHeader(part)) {
  1.1984 +                    request.addHeaderBlock(reqBlock);
  1.1985 +                } else if (ModelerUtils.isBoundToMimeContent(part)) {
  1.1986 +                    List<MIMEContent> mimeContents = getMimeContents(info.bindingOperation.getInput(),
  1.1987 +                            getInputMessage(), part.getName());
  1.1988 +                    jaxbReqType = getAttachmentType(mimeContents, part);
  1.1989 +                    //reqBlock = new Block(new QName(part.getName()), jaxbReqType);
  1.1990 +                    reqBlock = new Block(jaxbReqType.getName(), jaxbReqType, part);
  1.1991 +                    request.addAttachmentBlock(reqBlock);
  1.1992 +                } else if (ModelerUtils.isUnbound(part)) {
  1.1993 +                    request.addUnboundBlock(reqBlock);
  1.1994 +                }
  1.1995 +                if (inParameters == null) {
  1.1996 +                    inParameters = new ArrayList<Parameter>();
  1.1997 +                }
  1.1998 +                Parameter param = ModelerUtils.createParameter(part.getName(), jaxbReqType, reqBlock);
  1.1999 +                setCustomizedParameterName(info.portTypeOperation, inputMessage, part, param, false);
  1.2000 +                inParameters.add(param);
  1.2001 +            }
  1.2002 +        }
  1.2003 +        return inParameters;
  1.2004 +    }
  1.2005 +
  1.2006 +    /**
  1.2007 +     * @param part
  1.2008 +     * @param param
  1.2009 +     * @param wrapperStyle TODO
  1.2010 +     */
  1.2011 +    private void setCustomizedParameterName(TWSDLExtensible extension, Message msg, MessagePart part, Parameter param, boolean wrapperStyle) {
  1.2012 +        JAXWSBinding jaxwsBinding = (JAXWSBinding) getExtensionOfType(extension, JAXWSBinding.class);
  1.2013 +        if (jaxwsBinding == null) {
  1.2014 +            return;
  1.2015 +        }
  1.2016 +        String paramName = part.getName();
  1.2017 +        QName elementName = part.getDescriptor();
  1.2018 +        if (wrapperStyle) {
  1.2019 +            elementName = param.getType().getName();
  1.2020 +        }
  1.2021 +        String customName = jaxwsBinding.getParameterName(msg.getName(), paramName, elementName, wrapperStyle);
  1.2022 +        if (customName != null && !customName.equals("")) {
  1.2023 +            param.setCustomName(customName);
  1.2024 +        }
  1.2025 +    }
  1.2026 +
  1.2027 +    @Override
  1.2028 +    protected boolean isConflictingPortClassName(String name) {
  1.2029 +        return false;
  1.2030 +    }
  1.2031 +
  1.2032 +    protected boolean isUnwrappable() {
  1.2033 +        if (!getWrapperStyleCustomization()) {
  1.2034 +            return false;
  1.2035 +        }
  1.2036 +
  1.2037 +        com.sun.tools.internal.ws.wsdl.document.Message inputMessage = getInputMessage();
  1.2038 +        com.sun.tools.internal.ws.wsdl.document.Message outputMessage = getOutputMessage();
  1.2039 +
  1.2040 +        // Wrapper style if the operation's input and output messages each contain
  1.2041 +        // only a single part
  1.2042 +        if ((inputMessage != null && inputMessage.numParts() != 1)
  1.2043 +                || (outputMessage != null && outputMessage.numParts() != 1)) {
  1.2044 +            return false;
  1.2045 +        }
  1.2046 +
  1.2047 +        MessagePart inputPart = inputMessage != null
  1.2048 +                ? inputMessage.parts().next() : null;
  1.2049 +        MessagePart outputPart = outputMessage != null
  1.2050 +                ? outputMessage.parts().next() : null;
  1.2051 +        String operationName = info.portTypeOperation.getName();
  1.2052 +
  1.2053 +        // Wrapper style if the input message part refers to a global element declaration whose localname
  1.2054 +        // is equal to the operation name
  1.2055 +        // Wrapper style if the output message part refers to a global element declaration
  1.2056 +        if ((inputPart != null && !inputPart.getDescriptor().getLocalPart().equals(operationName)) ||
  1.2057 +                (outputPart != null && outputPart.getDescriptorKind() != SchemaKinds.XSD_ELEMENT)) {
  1.2058 +            return false;
  1.2059 +        }
  1.2060 +
  1.2061 +        //check to see if either input or output message part not bound to soapbing:body
  1.2062 +        //in that case the operation is not wrapper style
  1.2063 +        if (((inputPart != null) && (inputPart.getBindingExtensibilityElementKind() != MessagePart.SOAP_BODY_BINDING)) ||
  1.2064 +                ((outputPart != null) && (outputPart.getBindingExtensibilityElementKind() != MessagePart.SOAP_BODY_BINDING))) {
  1.2065 +            return false;
  1.2066 +        }
  1.2067 +
  1.2068 +        // Wrapper style if the elements referred to by the input and output message parts
  1.2069 +        // (henceforth referred to as wrapper elements) are both complex types defined
  1.2070 +        // using the xsd:sequence compositor
  1.2071 +        // Wrapper style if the wrapper elements only contain child elements, they must not
  1.2072 +        // contain other structures such as xsd:choice, substitution groups1 or attributes
  1.2073 +        //These checkins are done by jaxb, we just check if jaxb has wrapper children. If there
  1.2074 +        // are then its wrapper style
  1.2075 +        //if(inputPart != null && outputPart != null){
  1.2076 +        if (inputPart != null) {
  1.2077 +            boolean inputWrappable = false;
  1.2078 +            JAXBType inputType = getJAXBType(inputPart);
  1.2079 +            if (inputType != null) {
  1.2080 +                inputWrappable = inputType.isUnwrappable();
  1.2081 +            }
  1.2082 +            //if there are no output part (oneway), the operation can still be wrapper style
  1.2083 +            if (outputPart == null) {
  1.2084 +                return inputWrappable;
  1.2085 +            }
  1.2086 +            JAXBType outputType = getJAXBType(outputPart);
  1.2087 +            if ((inputType != null) && (outputType != null)) {
  1.2088 +                return inputType.isUnwrappable() && outputType.isUnwrappable();
  1.2089 +            }
  1.2090 +        }
  1.2091 +
  1.2092 +        return false;
  1.2093 +    }
  1.2094 +
  1.2095 +    private boolean getWrapperStyleCustomization() {
  1.2096 +        //first we look into wsdl:portType/wsdl:operation
  1.2097 +        com.sun.tools.internal.ws.wsdl.document.Operation portTypeOperation = info.portTypeOperation;
  1.2098 +        JAXWSBinding jaxwsBinding = (JAXWSBinding) getExtensionOfType(portTypeOperation, JAXWSBinding.class);
  1.2099 +        if (jaxwsBinding != null) {
  1.2100 +            Boolean isWrappable = jaxwsBinding.isEnableWrapperStyle();
  1.2101 +            if (isWrappable != null) {
  1.2102 +                return isWrappable;
  1.2103 +            }
  1.2104 +        }
  1.2105 +
  1.2106 +        //then into wsdl:portType
  1.2107 +        PortType portType = info.port.resolveBinding(document).resolvePortType(document);
  1.2108 +        jaxwsBinding = (JAXWSBinding) getExtensionOfType(portType, JAXWSBinding.class);
  1.2109 +        if (jaxwsBinding != null) {
  1.2110 +            Boolean isWrappable = jaxwsBinding.isEnableWrapperStyle();
  1.2111 +            if (isWrappable != null) {
  1.2112 +                return isWrappable;
  1.2113 +            }
  1.2114 +        }
  1.2115 +
  1.2116 +        //then wsdl:definitions
  1.2117 +        jaxwsBinding = (JAXWSBinding) getExtensionOfType(document.getDefinitions(), JAXWSBinding.class);
  1.2118 +        if (jaxwsBinding != null) {
  1.2119 +            Boolean isWrappable = jaxwsBinding.isEnableWrapperStyle();
  1.2120 +            if (isWrappable != null) {
  1.2121 +                return isWrappable;
  1.2122 +            }
  1.2123 +        }
  1.2124 +        return true;
  1.2125 +    }
  1.2126 +
  1.2127 +    /* (non-Javadoc)
  1.2128 +     * @see WSDLModelerBase#isSingleInOutPart(Set, MessagePart)
  1.2129 +     */
  1.2130 +    protected boolean isSingleInOutPart(Set inputParameterNames,
  1.2131 +                                        MessagePart outputPart) {
  1.2132 +        // As of now, we dont have support for in/out in doc-lit. So return false.
  1.2133 +        SOAPOperation soapOperation =
  1.2134 +                (SOAPOperation) getExtensionOfType(info.bindingOperation,
  1.2135 +                        SOAPOperation.class);
  1.2136 +        if ((soapOperation != null) && (soapOperation.isDocument() || info.soapBinding.isDocument())) {
  1.2137 +            Iterator iter = getInputMessage().parts();
  1.2138 +            while (iter.hasNext()) {
  1.2139 +                MessagePart part = (MessagePart) iter.next();
  1.2140 +                if (outputPart.getName().equals(part.getName()) && outputPart.getDescriptor().equals(part.getDescriptor())) {
  1.2141 +                    return true;
  1.2142 +                }
  1.2143 +            }
  1.2144 +        } else if (soapOperation != null && soapOperation.isRPC() || info.soapBinding.isRPC()) {
  1.2145 +            com.sun.tools.internal.ws.wsdl.document.Message inputMessage = getInputMessage();
  1.2146 +            if (inputParameterNames.contains(outputPart.getName())) {
  1.2147 +                if (inputMessage.getPart(outputPart.getName()).getDescriptor().equals(outputPart.getDescriptor())) {
  1.2148 +                    return true;
  1.2149 +                }
  1.2150 +            }
  1.2151 +        }
  1.2152 +        return false;
  1.2153 +    }
  1.2154 +
  1.2155 +    private List<Parameter> createRpcLitRequestParameters(Request request, List<String> parameterList, Block block) {
  1.2156 +        Message message = getInputMessage();
  1.2157 +        S2JJAXBModel jaxbModel = ((RpcLitStructure) block.getType()).getJaxbModel().getS2JJAXBModel();
  1.2158 +        List<Parameter> parameters = ModelerUtils.createRpcLitParameters(message, block, jaxbModel, errReceiver);
  1.2159 +
  1.2160 +        //create parameters for header and mime parts
  1.2161 +        for (String paramName : parameterList) {
  1.2162 +            MessagePart part = message.getPart(paramName);
  1.2163 +            if (part == null) {
  1.2164 +                continue;
  1.2165 +            }
  1.2166 +            if (ModelerUtils.isBoundToSOAPHeader(part)) {
  1.2167 +                if (parameters == null) {
  1.2168 +                    parameters = new ArrayList<Parameter>();
  1.2169 +                }
  1.2170 +                QName headerName = part.getDescriptor();
  1.2171 +                JAXBType jaxbType = getJAXBType(part);
  1.2172 +                Block headerBlock = new Block(headerName, jaxbType, part);
  1.2173 +                request.addHeaderBlock(headerBlock);
  1.2174 +                Parameter param = ModelerUtils.createParameter(part.getName(), jaxbType, headerBlock);
  1.2175 +                if (param != null) {
  1.2176 +                    parameters.add(param);
  1.2177 +                }
  1.2178 +            } else if (ModelerUtils.isBoundToMimeContent(part)) {
  1.2179 +                if (parameters == null) {
  1.2180 +                    parameters = new ArrayList<Parameter>();
  1.2181 +                }
  1.2182 +                List<MIMEContent> mimeContents = getMimeContents(info.bindingOperation.getInput(),
  1.2183 +                        getInputMessage(), paramName);
  1.2184 +
  1.2185 +                JAXBType type = getAttachmentType(mimeContents, part);
  1.2186 +                //create Parameters in request or response
  1.2187 +                //Block mimeBlock = new Block(new QName(part.getName()), type);
  1.2188 +                Block mimeBlock = new Block(type.getName(), type, part);
  1.2189 +                request.addAttachmentBlock(mimeBlock);
  1.2190 +                Parameter param = ModelerUtils.createParameter(part.getName(), type, mimeBlock);
  1.2191 +                if (param != null) {
  1.2192 +                    parameters.add(param);
  1.2193 +                }
  1.2194 +            } else if (ModelerUtils.isUnbound(part)) {
  1.2195 +                if (parameters == null) {
  1.2196 +                    parameters = new ArrayList<Parameter>();
  1.2197 +                }
  1.2198 +                QName name = part.getDescriptor();
  1.2199 +                JAXBType type = getJAXBType(part);
  1.2200 +                Block unboundBlock = new Block(name, type, part);
  1.2201 +                request.addUnboundBlock(unboundBlock);
  1.2202 +                Parameter param = ModelerUtils.createParameter(part.getName(), type, unboundBlock);
  1.2203 +                if (param != null) {
  1.2204 +                    parameters.add(param);
  1.2205 +                }
  1.2206 +            }
  1.2207 +        }
  1.2208 +        for (Parameter param : parameters) {
  1.2209 +            setCustomizedParameterName(info.portTypeOperation, message, message.getPart(param.getName()), param, false);
  1.2210 +        }
  1.2211 +        return parameters;
  1.2212 +    }
  1.2213 +
  1.2214 +    private String getJavaTypeForMimeType(String mimeType) {
  1.2215 +        if (mimeType.equals("image/jpeg") || mimeType.equals("image/gif")) {
  1.2216 +            return "java.awt.Image";
  1.2217 +        } else if (mimeType.equals("text/xml") || mimeType.equals("application/xml")) {
  1.2218 +            return "javax.xml.transform.Source";
  1.2219 +        }
  1.2220 +        return "javax.activation.DataHandler";
  1.2221 +    }
  1.2222 +
  1.2223 +    private JAXBType getAttachmentType(List<MIMEContent> mimeContents, MessagePart part) {
  1.2224 +        if (!enableMimeContent()) {
  1.2225 +            return getJAXBType(part);
  1.2226 +        }
  1.2227 +        String javaType;
  1.2228 +        List<String> mimeTypes = getAlternateMimeTypes(mimeContents);
  1.2229 +        if (mimeTypes.size() > 1) {
  1.2230 +            javaType = "javax.activation.DataHandler";
  1.2231 +        } else {
  1.2232 +            javaType = getJavaTypeForMimeType(mimeTypes.get(0));
  1.2233 +        }
  1.2234 +
  1.2235 +        S2JJAXBModel jaxbModel = getJAXBModelBuilder().getJAXBModel().getS2JJAXBModel();
  1.2236 +        JType jt = options.getCodeModel().ref(javaType);
  1.2237 +        QName desc = part.getDescriptor();
  1.2238 +        TypeAndAnnotation typeAnno = null;
  1.2239 +
  1.2240 +        if (part.getDescriptorKind() == SchemaKinds.XSD_TYPE) {
  1.2241 +            typeAnno = jaxbModel.getJavaType(desc);
  1.2242 +            desc = new QName("", part.getName());
  1.2243 +        } else if (part.getDescriptorKind() == SchemaKinds.XSD_ELEMENT) {
  1.2244 +            typeAnno = getJAXBModelBuilder().getElementTypeAndAnn(desc);
  1.2245 +            if(typeAnno == null){
  1.2246 +                error(part, ModelerMessages.WSDLMODELER_JAXB_JAVATYPE_NOTFOUND(part.getDescriptor(), part.getName()));
  1.2247 +            }
  1.2248 +            for (String mimeType : mimeTypes) {
  1.2249 +                if ((!mimeType.equals("text/xml") && !mimeType.equals("application/xml"))) {
  1.2250 +                    //According to AP 1.0,
  1.2251 +                    //RZZZZ: In a DESCRIPTION, if a wsdl:part element refers to a
  1.2252 +                    //global element declaration (via the element attribute of the wsdl:part
  1.2253 +                    //element) then the value of the type attribute of a mime:content element
  1.2254 +                    //that binds that part MUST be a content type suitable for carrying an
  1.2255 +                    //XML serialization.
  1.2256 +                    //should we throw warning?
  1.2257 +                    //type = MimeHelper.javaType.DATA_HANDLER_JAVATYPE;
  1.2258 +                    warning(part, ModelerMessages.MIMEMODELER_ELEMENT_PART_INVALID_ELEMENT_MIME_TYPE(part.getName(), mimeType));
  1.2259 +                }
  1.2260 +            }
  1.2261 +        }
  1.2262 +        if (typeAnno == null) {
  1.2263 +            error(part, ModelerMessages.WSDLMODELER_JAXB_JAVATYPE_NOTFOUND(desc, part.getName()));
  1.2264 +        }
  1.2265 +        return new JAXBType(desc, new JavaSimpleType(new JAXBTypeAndAnnotation(typeAnno, jt)),
  1.2266 +                null, getJAXBModelBuilder().getJAXBModel());
  1.2267 +    }
  1.2268 +
  1.2269 +    protected void buildJAXBModel(WSDLDocument wsdlDocument) {
  1.2270 +        JAXBModelBuilder tempJaxbModelBuilder = new JAXBModelBuilder(options, classNameCollector, forest, errReceiver);
  1.2271 +        //set the java package where wsdl artifacts will be generated
  1.2272 +        //if user provided package name  using -p switch (or package property on wsimport ant task)
  1.2273 +        //ignore the package customization in the wsdl and schema bidnings
  1.2274 +        //formce the -p option only in the first pass
  1.2275 +        if (explicitDefaultPackage != null) {
  1.2276 +            tempJaxbModelBuilder.getJAXBSchemaCompiler().forcePackageName(options.defaultPackage);
  1.2277 +        } else {
  1.2278 +            options.defaultPackage = getJavaPackage();
  1.2279 +        }
  1.2280 +
  1.2281 +        //create pseudo schema for async operations(if any) response bean
  1.2282 +        List<InputSource> schemas = PseudoSchemaBuilder.build(this, options, errReceiver);
  1.2283 +        for (InputSource schema : schemas) {
  1.2284 +            tempJaxbModelBuilder.getJAXBSchemaCompiler().parseSchema(schema);
  1.2285 +        }
  1.2286 +        tempJaxbModelBuilder.bind();
  1.2287 +        this.jaxbModelBuilder = tempJaxbModelBuilder;
  1.2288 +    }
  1.2289 +
  1.2290 +    protected String getJavaPackage() {
  1.2291 +        String jaxwsPackage = null;
  1.2292 +        JAXWSBinding jaxwsCustomization = (JAXWSBinding) getExtensionOfType(document.getDefinitions(), JAXWSBinding.class);
  1.2293 +        if (jaxwsCustomization != null && jaxwsCustomization.getJaxwsPackage() != null) {
  1.2294 +            jaxwsPackage = jaxwsCustomization.getJaxwsPackage().getName();
  1.2295 +        }
  1.2296 +        if (jaxwsPackage != null) {
  1.2297 +            return jaxwsPackage;
  1.2298 +        }
  1.2299 +        String wsdlUri = document.getDefinitions().getTargetNamespaceURI();
  1.2300 +        return XJC.getDefaultPackageName(wsdlUri);
  1.2301 +
  1.2302 +    }
  1.2303 +
  1.2304 +    protected void createJavaInterfaceForProviderPort(Port port) {
  1.2305 +        String interfaceName = "javax.xml.ws.Provider";
  1.2306 +        JavaInterface intf = new JavaInterface(interfaceName);
  1.2307 +        port.setJavaInterface(intf);
  1.2308 +    }
  1.2309 +
  1.2310 +    protected void createJavaInterfaceForPort(Port port, boolean isProvider) {
  1.2311 +        if (isProvider) {
  1.2312 +            createJavaInterfaceForProviderPort(port);
  1.2313 +            return;
  1.2314 +        }
  1.2315 +        String interfaceName = getJavaNameOfSEI(port);
  1.2316 +
  1.2317 +        if (isConflictingPortClassName(interfaceName)) {
  1.2318 +            interfaceName += "_PortType";
  1.2319 +        }
  1.2320 +
  1.2321 +        JavaInterface intf = new JavaInterface(interfaceName);
  1.2322 +        for (Operation operation : port.getOperations()) {
  1.2323 +            createJavaMethodForOperation(
  1.2324 +                    port,
  1.2325 +                    operation,
  1.2326 +                    intf);
  1.2327 +
  1.2328 +            for (JavaParameter jParam : operation.getJavaMethod().getParametersList()) {
  1.2329 +                Parameter param = jParam.getParameter();
  1.2330 +                if (param.getCustomName() != null) {
  1.2331 +                    jParam.setName(param.getCustomName());
  1.2332 +                }
  1.2333 +            }
  1.2334 +        }
  1.2335 +
  1.2336 +        port.setJavaInterface(intf);
  1.2337 +    }
  1.2338 +
  1.2339 +    protected String getServiceInterfaceName(QName serviceQName, com.sun.tools.internal.ws.wsdl.document.Service wsdlService) {
  1.2340 +        String serviceName = wsdlService.getName();
  1.2341 +        JAXWSBinding jaxwsCust = (JAXWSBinding) getExtensionOfType(wsdlService, JAXWSBinding.class);
  1.2342 +        if (jaxwsCust != null && jaxwsCust.getClassName() != null) {
  1.2343 +            CustomName name = jaxwsCust.getClassName();
  1.2344 +            if (name != null && !name.getName().equals("")) {
  1.2345 +                return makePackageQualified(name.getName());
  1.2346 +            }
  1.2347 +        }
  1.2348 +        return makePackageQualified(BindingHelper.mangleNameToClassName(serviceName));
  1.2349 +    }
  1.2350 +
  1.2351 +    protected String getJavaNameOfSEI(Port port) {
  1.2352 +        QName portTypeName =
  1.2353 +                (QName) port.getProperty(
  1.2354 +                        ModelProperties.PROPERTY_WSDL_PORT_TYPE_NAME);
  1.2355 +        PortType pt = (PortType) document.find(Kinds.PORT_TYPE, portTypeName);
  1.2356 +        //populate the portType map here. We should get rid of all these properties
  1.2357 +        // lets not do it as it may break NB
  1.2358 +        //TODO: clean all these stuff part of NB RFE
  1.2359 +        port.portTypes.put(portTypeName, pt);
  1.2360 +        JAXWSBinding jaxwsCust = (JAXWSBinding) getExtensionOfType(pt, JAXWSBinding.class);
  1.2361 +        if (jaxwsCust != null && jaxwsCust.getClassName() != null) {
  1.2362 +            CustomName name = jaxwsCust.getClassName();
  1.2363 +            if (name != null && !name.getName().equals("")) {
  1.2364 +                return makePackageQualified(name.getName());
  1.2365 +            }
  1.2366 +        }
  1.2367 +
  1.2368 +        String interfaceName;
  1.2369 +        if (portTypeName != null) {
  1.2370 +            // got portType information from WSDL, use it to name the interface
  1.2371 +            interfaceName =
  1.2372 +                    makePackageQualified(BindingHelper.mangleNameToClassName(portTypeName.getLocalPart()));
  1.2373 +        } else {
  1.2374 +            // somehow we only got the port name, so we use that
  1.2375 +            interfaceName =
  1.2376 +                    makePackageQualified(BindingHelper.mangleNameToClassName(port.getName().getLocalPart()));
  1.2377 +        }
  1.2378 +        return interfaceName;
  1.2379 +    }
  1.2380 +
  1.2381 +    private void createJavaMethodForAsyncOperation(Port port, Operation operation,
  1.2382 +                                                   JavaInterface intf) {
  1.2383 +        String candidateName = getJavaNameForOperation(operation);
  1.2384 +        JavaMethod method = new JavaMethod(candidateName, options, errReceiver);
  1.2385 +
  1.2386 +        assert (operation.getRequest() != null);
  1.2387 +        Response response = operation.getResponse();
  1.2388 +
  1.2389 +        // build a signature of the form "opName%arg1type%arg2type%...%argntype so that we
  1.2390 +        // detect overloading conflicts in the generated java interface/classes
  1.2391 +        for (Iterator iter = operation.getRequest().getParameters(); iter.hasNext();) {
  1.2392 +            Parameter parameter = (Parameter) iter.next();
  1.2393 +
  1.2394 +            if (parameter.getJavaParameter() != null) {
  1.2395 +                error(operation.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION(operation.getName().getLocalPart()));
  1.2396 +            }
  1.2397 +
  1.2398 +            JavaType parameterType = parameter.getType().getJavaType();
  1.2399 +            JavaParameter javaParameter =
  1.2400 +                    new JavaParameter(
  1.2401 +                                BindingHelper.mangleNameToVariableName(parameter.getName()),
  1.2402 +                            parameterType,
  1.2403 +                            parameter,
  1.2404 +                            parameter.getLinkedParameter() != null);
  1.2405 +            if (javaParameter.isHolder()) {
  1.2406 +                javaParameter.setHolderName(javax.xml.ws.Holder.class.getName());
  1.2407 +            }
  1.2408 +            method.addParameter(javaParameter);
  1.2409 +            parameter.setJavaParameter(javaParameter);
  1.2410 +
  1.2411 +        }
  1.2412 +
  1.2413 +        if (response != null) {
  1.2414 +            String resultParameterName =
  1.2415 +                    (String) operation.getProperty(WSDL_RESULT_PARAMETER);
  1.2416 +            Parameter resultParameter =
  1.2417 +                    response.getParameterByName(resultParameterName);
  1.2418 +            JavaType returnType = resultParameter.getType().getJavaType();
  1.2419 +            method.setReturnType(returnType);
  1.2420 +
  1.2421 +        }
  1.2422 +        operation.setJavaMethod(method);
  1.2423 +        intf.addMethod(method);
  1.2424 +    }
  1.2425 +
  1.2426 +    /* (non-Javadoc)
  1.2427 +     * @see WSDLModelerBase#createJavaMethodForOperation(WSDLPort, WSDLOperation, JavaInterface, Set, Set)
  1.2428 +     */
  1.2429 +    protected void createJavaMethodForOperation(Port port, Operation operation, JavaInterface intf) {
  1.2430 +        if ((operation instanceof AsyncOperation)) {
  1.2431 +            createJavaMethodForAsyncOperation(port, operation, intf);
  1.2432 +            return;
  1.2433 +        }
  1.2434 +        String candidateName = getJavaNameForOperation(operation);
  1.2435 +        JavaMethod method = new JavaMethod(candidateName, options, errReceiver);
  1.2436 +        Parameter returnParam = (Parameter) operation.getProperty(WSDL_RESULT_PARAMETER);
  1.2437 +        if (returnParam != null) {
  1.2438 +            JavaType parameterType = returnParam.getType().getJavaType();
  1.2439 +            method.setReturnType(parameterType);
  1.2440 +        } else {
  1.2441 +            method.setReturnType(JavaSimpleTypeCreator.VOID_JAVATYPE);
  1.2442 +        }
  1.2443 +        List<Parameter> parameterOrder = (List<Parameter>) operation.getProperty(WSDL_PARAMETER_ORDER);
  1.2444 +        for (Parameter param : parameterOrder) {
  1.2445 +            JavaType parameterType = param.getType().getJavaType();
  1.2446 +            String name = (param.getCustomName() != null) ? param.getCustomName() : param.getName();
  1.2447 +            name = BindingHelper.mangleNameToVariableName(name);
  1.2448 +            //if its a java keyword after name mangling, then we simply put underscore as there is no
  1.2449 +            //need to ask user to customize the parameter name if its java keyword
  1.2450 +            if(Names.isJavaReservedWord(name)){
  1.2451 +                name = "_"+name;
  1.2452 +            }
  1.2453 +            JavaParameter javaParameter =
  1.2454 +                    new JavaParameter(
  1.2455 +                            name,
  1.2456 +                            parameterType,
  1.2457 +                            param,
  1.2458 +                            param.isINOUT() || param.isOUT());
  1.2459 +            if (javaParameter.isHolder()) {
  1.2460 +                javaParameter.setHolderName(javax.xml.ws.Holder.class.getName());
  1.2461 +            }
  1.2462 +            method.addParameter(javaParameter);
  1.2463 +            param.setJavaParameter(javaParameter);
  1.2464 +        }
  1.2465 +        operation.setJavaMethod(method);
  1.2466 +        intf.addMethod(method);
  1.2467 +
  1.2468 +        String opName = BindingHelper.mangleNameToVariableName(operation.getName().getLocalPart());
  1.2469 +        for (Iterator iter = operation.getFaults();
  1.2470 +             iter != null && iter.hasNext();
  1.2471 +                ) {
  1.2472 +            Fault fault = (Fault) iter.next();
  1.2473 +            createJavaExceptionFromLiteralType(fault, port, opName);
  1.2474 +        }
  1.2475 +        JavaException javaException;
  1.2476 +        Fault fault;
  1.2477 +        for (Iterator iter = operation.getFaults(); iter.hasNext();) {
  1.2478 +            fault = (Fault) iter.next();
  1.2479 +            javaException = fault.getJavaException();
  1.2480 +            method.addException(javaException.getName());
  1.2481 +        }
  1.2482 +
  1.2483 +    }
  1.2484 +
  1.2485 +    protected boolean createJavaExceptionFromLiteralType(Fault fault, com.sun.tools.internal.ws.processor.model.Port port, String operationName) {
  1.2486 +        JAXBType faultType = (JAXBType) fault.getBlock().getType();
  1.2487 +
  1.2488 +        String exceptionName = fault.getName();
  1.2489 +
  1.2490 +        // use fault namespace attribute
  1.2491 +        JAXBStructuredType jaxbStruct = new JAXBStructuredType(new QName(
  1.2492 +                fault.getBlock().getName().getNamespaceURI(),
  1.2493 +                fault.getName()));
  1.2494 +
  1.2495 +        QName memberName = fault.getElementName();
  1.2496 +        JAXBElementMember jaxbMember =
  1.2497 +                new JAXBElementMember(memberName, faultType);
  1.2498 +        //jaxbMember.setNillable(faultType.isNillable());
  1.2499 +
  1.2500 +        String javaMemberName = getLiteralJavaMemberName(fault);
  1.2501 +        JavaStructureMember javaMember = new JavaStructureMember(
  1.2502 +                javaMemberName,
  1.2503 +                faultType.getJavaType(),
  1.2504 +                jaxbMember);
  1.2505 +        jaxbMember.setJavaStructureMember(javaMember);
  1.2506 +        javaMember.setReadMethod(Names.getJavaMemberReadMethod(javaMember));
  1.2507 +        javaMember.setInherited(false);
  1.2508 +        jaxbMember.setJavaStructureMember(javaMember);
  1.2509 +        jaxbStruct.add(jaxbMember);
  1.2510 +
  1.2511 +        if (isConflictingExceptionClassName(exceptionName)) {
  1.2512 +            exceptionName += "_Exception";
  1.2513 +        }
  1.2514 +
  1.2515 +        JavaException existingJavaException = _javaExceptions.get(exceptionName);
  1.2516 +        if (existingJavaException != null) {
  1.2517 +            if (existingJavaException.getName().equals(exceptionName)) {
  1.2518 +                if (((JAXBType) existingJavaException.getOwner()).getName().equals(jaxbStruct.getName())
  1.2519 +                        || ModelerUtils.isEquivalentLiteralStructures(jaxbStruct, (JAXBStructuredType) existingJavaException.getOwner())) {
  1.2520 +                    // we have mapped this fault already
  1.2521 +                    if (faultType instanceof JAXBStructuredType) {
  1.2522 +                        fault.getBlock().setType((JAXBType) existingJavaException.getOwner());
  1.2523 +                    }
  1.2524 +                    fault.setJavaException(existingJavaException);
  1.2525 +                    return false;
  1.2526 +                }
  1.2527 +            }
  1.2528 +        }
  1.2529 +
  1.2530 +        JavaException javaException = new JavaException(exceptionName, false, jaxbStruct);
  1.2531 +        javaException.add(javaMember);
  1.2532 +        jaxbStruct.setJavaType(javaException);
  1.2533 +
  1.2534 +        _javaExceptions.put(javaException.getName(), javaException);
  1.2535 +
  1.2536 +        fault.setJavaException(javaException);
  1.2537 +        return true;
  1.2538 +    }
  1.2539 +
  1.2540 +    protected boolean isRequestResponse() {
  1.2541 +        return info.portTypeOperation.getStyle() == OperationStyle.REQUEST_RESPONSE;
  1.2542 +    }
  1.2543 +
  1.2544 +    protected java.util.List<String> getAsynParameterOrder() {
  1.2545 +        //for async operation ignore the parameterOrder
  1.2546 +        java.util.List<String> parameterList = new ArrayList<String>();
  1.2547 +        Message inputMessage = getInputMessage();
  1.2548 +        List<MessagePart> inputParts = inputMessage.getParts();
  1.2549 +        for (MessagePart part : inputParts) {
  1.2550 +            parameterList.add(part.getName());
  1.2551 +        }
  1.2552 +        return parameterList;
  1.2553 +    }
  1.2554 +
  1.2555 +
  1.2556 +    protected List<MessagePart> getParameterOrder() {
  1.2557 +        List<MessagePart> params = new ArrayList<MessagePart>();
  1.2558 +        String parameterOrder = info.portTypeOperation.getParameterOrder();
  1.2559 +        java.util.List<String> parameterList;
  1.2560 +        boolean parameterOrderPresent = false;
  1.2561 +        if ((parameterOrder != null) && !(parameterOrder.trim().equals(""))) {
  1.2562 +            parameterList = XmlUtil.parseTokenList(parameterOrder);
  1.2563 +            parameterOrderPresent = true;
  1.2564 +        } else {
  1.2565 +            parameterList = new ArrayList<String>();
  1.2566 +        }
  1.2567 +        Message inputMessage = getInputMessage();
  1.2568 +        Message outputMessage = getOutputMessage();
  1.2569 +        List<MessagePart> outputParts = null;
  1.2570 +        List<MessagePart> inputParts = inputMessage.getParts();
  1.2571 +        //reset the mode and ret flag, as MEssagePArts aer shared across ports
  1.2572 +        for (MessagePart part : inputParts) {
  1.2573 +            part.setMode(Mode.IN);
  1.2574 +            part.setReturn(false);
  1.2575 +        }
  1.2576 +        if (isRequestResponse()) {
  1.2577 +            outputParts = outputMessage.getParts();
  1.2578 +            for (MessagePart part : outputParts) {
  1.2579 +                part.setMode(Mode.OUT);
  1.2580 +                part.setReturn(false);
  1.2581 +            }
  1.2582 +        }
  1.2583 +
  1.2584 +        if (parameterOrderPresent) {
  1.2585 +            boolean validParameterOrder = true;
  1.2586 +            Iterator<String> paramOrders = parameterList.iterator();
  1.2587 +            // If any part in the parameterOrder is not present in the request or
  1.2588 +            // response message, we completely ignore the parameterOrder hint
  1.2589 +            while (paramOrders.hasNext()) {
  1.2590 +                String param = paramOrders.next();
  1.2591 +                boolean partFound = false;
  1.2592 +                for (MessagePart part : inputParts) {
  1.2593 +                    if (param.equals(part.getName())) {
  1.2594 +                        partFound = true;
  1.2595 +                        break;
  1.2596 +                    }
  1.2597 +                }
  1.2598 +                // if not found, check in output parts
  1.2599 +                if (!partFound) {
  1.2600 +                    for (MessagePart part : outputParts) {
  1.2601 +                        if (param.equals(part.getName())) {
  1.2602 +                            partFound = true;
  1.2603 +                            break;
  1.2604 +                        }
  1.2605 +                    }
  1.2606 +                }
  1.2607 +                if (!partFound) {
  1.2608 +                    warning(info.operation.getEntity(), ModelerMessages.WSDLMODELER_INVALID_PARAMETERORDER_PARAMETER(param, info.operation.getName().getLocalPart()));
  1.2609 +                    validParameterOrder = false;
  1.2610 +                }
  1.2611 +            }
  1.2612 +
  1.2613 +            List<MessagePart> inputUnlistedParts = new ArrayList<MessagePart>();
  1.2614 +            List<MessagePart> outputUnlistedParts = new ArrayList<MessagePart>();
  1.2615 +
  1.2616 +            //gather input Parts
  1.2617 +            if (validParameterOrder) {
  1.2618 +                for (String param : parameterList) {
  1.2619 +                    MessagePart part = inputMessage.getPart(param);
  1.2620 +                    if (part != null) {
  1.2621 +                        params.add(part);
  1.2622 +                        continue;
  1.2623 +                    }
  1.2624 +                    if (isRequestResponse()) {
  1.2625 +                        MessagePart outPart = outputMessage.getPart(param);
  1.2626 +                        if (outPart != null) {
  1.2627 +                            params.add(outPart);
  1.2628 +                        }
  1.2629 +                    }
  1.2630 +                }
  1.2631 +
  1.2632 +                for (MessagePart part : inputParts) {
  1.2633 +                    if (!parameterList.contains(part.getName())) {
  1.2634 +                        inputUnlistedParts.add(part);
  1.2635 +                    }
  1.2636 +                }
  1.2637 +
  1.2638 +                if (isRequestResponse()) {
  1.2639 +                    // at most one output part should be unlisted
  1.2640 +                    for (MessagePart part : outputParts) {
  1.2641 +                        if (!parameterList.contains(part.getName())) {
  1.2642 +                            MessagePart inPart = inputMessage.getPart(part.getName());
  1.2643 +                            //dont add inout as unlisted part
  1.2644 +                            if ((inPart != null) && inPart.getDescriptor().equals(part.getDescriptor())) {
  1.2645 +                                inPart.setMode(Mode.INOUT);
  1.2646 +                            } else {
  1.2647 +                                outputUnlistedParts.add(part);
  1.2648 +                            }
  1.2649 +                        } else {
  1.2650 +                            //param list may contain it, check if its INOUT
  1.2651 +                            MessagePart inPart = inputMessage.getPart(part.getName());
  1.2652 +                            //dont add inout as unlisted part
  1.2653 +                            if ((inPart != null) && inPart.getDescriptor().equals(part.getDescriptor())) {
  1.2654 +                                inPart.setMode(Mode.INOUT);
  1.2655 +                            } else if (!params.contains(part)) {
  1.2656 +                                params.add(part);
  1.2657 +                            }
  1.2658 +                        }
  1.2659 +                    }
  1.2660 +                    if (outputUnlistedParts.size() == 1) {
  1.2661 +                        MessagePart resultPart = outputUnlistedParts.get(0);
  1.2662 +                        resultPart.setReturn(true);
  1.2663 +                        params.add(resultPart);
  1.2664 +                        outputUnlistedParts.clear();
  1.2665 +                    }
  1.2666 +                }
  1.2667 +
  1.2668 +                //add the input and output unlisted parts
  1.2669 +                for (MessagePart part : inputUnlistedParts) {
  1.2670 +                    params.add(part);
  1.2671 +                }
  1.2672 +
  1.2673 +                for (MessagePart part : outputUnlistedParts) {
  1.2674 +                    params.add(part);
  1.2675 +                }
  1.2676 +                return params;
  1.2677 +
  1.2678 +            }
  1.2679 +            //parameterOrder attribute is not valid, we ignore it
  1.2680 +            warning(info.operation.getEntity(), ModelerMessages.WSDLMODELER_INVALID_PARAMETER_ORDER_INVALID_PARAMETER_ORDER(info.operation.getName().getLocalPart()));
  1.2681 +            parameterList.clear();
  1.2682 +        }
  1.2683 +
  1.2684 +        List<MessagePart> outParts = new ArrayList<MessagePart>();
  1.2685 +
  1.2686 +        //construct input parameter list with the same order as in input message
  1.2687 +        for (MessagePart part : inputParts) {
  1.2688 +            params.add(part);
  1.2689 +        }
  1.2690 +
  1.2691 +        if (isRequestResponse()) {
  1.2692 +            for (MessagePart part : outputParts) {
  1.2693 +                MessagePart inPart = inputMessage.getPart(part.getName());
  1.2694 +                if (inPart != null && part.getDescriptorKind() == inPart.getDescriptorKind() &&
  1.2695 +                        part.getDescriptor().equals(inPart.getDescriptor())) {
  1.2696 +                    inPart.setMode(Mode.INOUT);
  1.2697 +                    continue;
  1.2698 +                }
  1.2699 +                outParts.add(part);
  1.2700 +            }
  1.2701 +
  1.2702 +            //append the out parts to the parameterList
  1.2703 +            for (MessagePart part : outParts) {
  1.2704 +                if (outParts.size() == 1) {
  1.2705 +                    part.setReturn(true);
  1.2706 +                }
  1.2707 +                params.add(part);
  1.2708 +            }
  1.2709 +        }
  1.2710 +        return params;
  1.2711 +    }
  1.2712 +
  1.2713 +    /**
  1.2714 +     * @param port
  1.2715 +     * @param suffix
  1.2716 +     * @return the Java ClassName for a port
  1.2717 +     */
  1.2718 +    protected String getClassName(Port port, String suffix) {
  1.2719 +        String prefix = BindingHelper.mangleNameToClassName((port.getName().getLocalPart()));
  1.2720 +        return options.defaultPackage + "." + prefix + suffix;
  1.2721 +    }
  1.2722 +
  1.2723 +    @Override
  1.2724 +    protected boolean isConflictingServiceClassName(String name) {
  1.2725 +        return conflictsWithSEIClass(name) || conflictsWithJAXBClass(name) || conflictsWithExceptionClass(name);
  1.2726 +    }
  1.2727 +
  1.2728 +    private boolean conflictsWithSEIClass(String name) {
  1.2729 +        Set<String> seiNames = classNameCollector.getSeiClassNames();
  1.2730 +        return seiNames != null && seiNames.contains(name);
  1.2731 +    }
  1.2732 +
  1.2733 +    private boolean conflictsWithJAXBClass(String name) {
  1.2734 +        Set<String> jaxbNames = classNameCollector.getJaxbGeneratedClassNames();
  1.2735 +        return jaxbNames != null && jaxbNames.contains(name);
  1.2736 +    }
  1.2737 +
  1.2738 +    private boolean conflictsWithExceptionClass(String name) {
  1.2739 +        Set<String> exceptionNames = classNameCollector.getExceptionClassNames();
  1.2740 +        return exceptionNames != null && exceptionNames.contains(name);
  1.2741 +    }
  1.2742 +
  1.2743 +    @Override
  1.2744 +    protected boolean isConflictingExceptionClassName(String name) {
  1.2745 +        return conflictsWithSEIClass(name) || conflictsWithJAXBClass(name);
  1.2746 +    }
  1.2747 +
  1.2748 +    protected JAXBModelBuilder getJAXBModelBuilder() {
  1.2749 +        return jaxbModelBuilder;
  1.2750 +    }
  1.2751 +
  1.2752 +    protected boolean validateWSDLBindingStyle(Binding binding) {
  1.2753 +        SOAPBinding soapBinding =
  1.2754 +                (SOAPBinding) getExtensionOfType(binding, SOAPBinding.class);
  1.2755 +
  1.2756 +        //dont process the binding
  1.2757 +        if (soapBinding == null) {
  1.2758 +            soapBinding = (SOAPBinding) getExtensionOfType(binding, SOAP12Binding.class);
  1.2759 +        }
  1.2760 +        if (soapBinding == null) {
  1.2761 +            return false;
  1.2762 +        }
  1.2763 +
  1.2764 +        //if soapbind:binding has no style attribute, the default is DOCUMENT
  1.2765 +        if (soapBinding.getStyle() == null) {
  1.2766 +            soapBinding.setStyle(SOAPStyle.DOCUMENT);
  1.2767 +        }
  1.2768 +
  1.2769 +        SOAPStyle opStyle = soapBinding.getStyle();
  1.2770 +        for (Iterator iter = binding.operations(); iter.hasNext();) {
  1.2771 +            BindingOperation bindingOperation =
  1.2772 +                    (BindingOperation) iter.next();
  1.2773 +            SOAPOperation soapOperation =
  1.2774 +                    (SOAPOperation) getExtensionOfType(bindingOperation,
  1.2775 +                            SOAPOperation.class);
  1.2776 +            if (soapOperation != null) {
  1.2777 +                SOAPStyle currOpStyle = (soapOperation.getStyle() != null) ? soapOperation.getStyle() : soapBinding.getStyle();
  1.2778 +                //dont check for the first operation
  1.2779 +                if (!currOpStyle.equals(opStyle)) {
  1.2780 +                    return false;
  1.2781 +                }
  1.2782 +            }
  1.2783 +        }
  1.2784 +        return true;
  1.2785 +    }
  1.2786 +
  1.2787 +    /**
  1.2788 +     * @param port
  1.2789 +     */
  1.2790 +    private void applyWrapperStyleCustomization(Port port, PortType portType) {
  1.2791 +        JAXWSBinding jaxwsBinding = (JAXWSBinding) getExtensionOfType(portType, JAXWSBinding.class);
  1.2792 +        Boolean wrapperStyle = (jaxwsBinding != null) ? jaxwsBinding.isEnableWrapperStyle() : null;
  1.2793 +        if (wrapperStyle != null) {
  1.2794 +            port.setWrapped(wrapperStyle);
  1.2795 +        }
  1.2796 +    }
  1.2797 +
  1.2798 +    protected static void setDocumentationIfPresent(
  1.2799 +            ModelObject obj,
  1.2800 +            Documentation documentation) {
  1.2801 +        if (documentation != null && documentation.getContent() != null) {
  1.2802 +            obj.setJavaDoc(documentation.getContent());
  1.2803 +        }
  1.2804 +    }
  1.2805 +
  1.2806 +    protected String getJavaNameForOperation(Operation operation) {
  1.2807 +        String name = operation.getJavaMethodName();
  1.2808 +        if (Names.isJavaReservedWord(name)) {
  1.2809 +            name = "_" + name;
  1.2810 +        }
  1.2811 +        return name;
  1.2812 +    }
  1.2813 +
  1.2814 +    private void reportError(Entity entity,
  1.2815 +        String formattedMsg, Exception nestedException ) {
  1.2816 +        Locator locator = (entity == null)?null:entity.getLocator();
  1.2817 +
  1.2818 +        SAXParseException e = new SAXParseException2( formattedMsg,
  1.2819 +            locator,
  1.2820 +            nestedException );
  1.2821 +        errReceiver.error(e);
  1.2822 +    }
  1.2823 +
  1.2824 +}

mercurial