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