Wed, 27 Apr 2016 01:27:09 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/jaxws/
changeset: 657:d47a47f961ee
tag: jdk8u25-b17
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. Oracle designates this |
aoqi@0 | 8 | * particular file as subject to the "Classpath" exception as provided |
aoqi@0 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aoqi@0 | 10 | * |
aoqi@0 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 15 | * accompanied this code). |
aoqi@0 | 16 | * |
aoqi@0 | 17 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 20 | * |
aoqi@0 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 22 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 23 | * questions. |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | package com.sun.tools.internal.ws.processor.modeler.wsdl; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import com.sun.codemodel.internal.JType; |
aoqi@0 | 29 | import com.sun.istack.internal.NotNull; |
aoqi@0 | 30 | import com.sun.istack.internal.SAXParseException2; |
aoqi@0 | 31 | import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible; |
aoqi@0 | 32 | import com.sun.tools.internal.ws.processor.generator.Names; |
aoqi@0 | 33 | import com.sun.tools.internal.ws.processor.model.*; |
aoqi@0 | 34 | import com.sun.tools.internal.ws.processor.model.Fault; |
aoqi@0 | 35 | import com.sun.tools.internal.ws.processor.model.Operation; |
aoqi@0 | 36 | import com.sun.tools.internal.ws.processor.model.Port; |
aoqi@0 | 37 | import com.sun.tools.internal.ws.processor.model.Service; |
aoqi@0 | 38 | import com.sun.tools.internal.ws.processor.model.java.*; |
aoqi@0 | 39 | import com.sun.tools.internal.ws.processor.model.jaxb.*; |
aoqi@0 | 40 | import com.sun.tools.internal.ws.processor.modeler.JavaSimpleTypeCreator; |
aoqi@0 | 41 | import com.sun.tools.internal.ws.processor.util.ClassNameCollector; |
aoqi@0 | 42 | import com.sun.tools.internal.ws.resources.ModelerMessages; |
aoqi@0 | 43 | import com.sun.tools.internal.ws.wscompile.ErrorReceiver; |
aoqi@0 | 44 | import com.sun.tools.internal.ws.wscompile.WsimportOptions; |
aoqi@0 | 45 | import com.sun.tools.internal.ws.wsdl.document.*; |
aoqi@0 | 46 | import com.sun.tools.internal.ws.wsdl.document.Message; |
aoqi@0 | 47 | import com.sun.tools.internal.ws.wsdl.document.jaxws.CustomName; |
aoqi@0 | 48 | import com.sun.tools.internal.ws.wsdl.document.jaxws.JAXWSBinding; |
aoqi@0 | 49 | import com.sun.tools.internal.ws.wsdl.document.mime.MIMEContent; |
aoqi@0 | 50 | import com.sun.tools.internal.ws.wsdl.document.schema.SchemaKinds; |
aoqi@0 | 51 | import com.sun.tools.internal.ws.wsdl.document.soap.*; |
aoqi@0 | 52 | import com.sun.tools.internal.ws.wsdl.framework.*; |
aoqi@0 | 53 | import com.sun.tools.internal.ws.wsdl.parser.MetadataFinder; |
aoqi@0 | 54 | import com.sun.tools.internal.ws.wsdl.parser.WSDLParser; |
aoqi@0 | 55 | import com.sun.tools.internal.xjc.api.S2JJAXBModel; |
aoqi@0 | 56 | import com.sun.tools.internal.xjc.api.TypeAndAnnotation; |
aoqi@0 | 57 | import com.sun.tools.internal.xjc.api.XJC; |
aoqi@0 | 58 | import com.sun.xml.internal.ws.spi.db.BindingHelper; |
aoqi@0 | 59 | import com.sun.xml.internal.ws.util.xml.XmlUtil; |
aoqi@0 | 60 | import org.xml.sax.InputSource; |
aoqi@0 | 61 | import org.xml.sax.Locator; |
aoqi@0 | 62 | import org.xml.sax.SAXException; |
aoqi@0 | 63 | import org.xml.sax.SAXParseException; |
aoqi@0 | 64 | import org.xml.sax.helpers.LocatorImpl; |
aoqi@0 | 65 | |
aoqi@0 | 66 | import javax.jws.WebParam.Mode; |
aoqi@0 | 67 | import javax.xml.namespace.QName; |
aoqi@0 | 68 | import java.util.*; |
aoqi@0 | 69 | import java.io.IOException; |
aoqi@0 | 70 | |
aoqi@0 | 71 | |
aoqi@0 | 72 | /** |
aoqi@0 | 73 | * The WSDLModeler processes a WSDL to create a Model. |
aoqi@0 | 74 | * |
aoqi@0 | 75 | * @author WS Development Team |
aoqi@0 | 76 | */ |
aoqi@0 | 77 | public class WSDLModeler extends WSDLModelerBase { |
aoqi@0 | 78 | |
aoqi@0 | 79 | //map of wsdl:operation QName to <soapenv:Body> child, as per BP it must be unique in a port |
aoqi@0 | 80 | private final Map<QName, Operation> uniqueBodyBlocks = new HashMap<QName, Operation>(); |
aoqi@0 | 81 | private final QName VOID_BODYBLOCK = new QName(""); |
aoqi@0 | 82 | private final ClassNameCollector classNameCollector; |
aoqi@0 | 83 | private final String explicitDefaultPackage; |
aoqi@0 | 84 | |
aoqi@0 | 85 | public WSDLModeler(WsimportOptions options, ErrorReceiver receiver, MetadataFinder forest) { |
aoqi@0 | 86 | super(options, receiver,forest); |
aoqi@0 | 87 | this.classNameCollector = new ClassNameCollector(); |
aoqi@0 | 88 | this.explicitDefaultPackage = options.defaultPackage; |
aoqi@0 | 89 | } |
aoqi@0 | 90 | |
aoqi@0 | 91 | |
aoqi@0 | 92 | protected enum StyleAndUse { |
aoqi@0 | 93 | RPC_LITERAL, DOC_LITERAL |
aoqi@0 | 94 | } |
aoqi@0 | 95 | |
aoqi@0 | 96 | private JAXBModelBuilder jaxbModelBuilder; |
aoqi@0 | 97 | |
aoqi@0 | 98 | @Override |
aoqi@0 | 99 | public Model buildModel() { |
aoqi@0 | 100 | try { |
aoqi@0 | 101 | parser = new WSDLParser(options, errReceiver, forest); |
aoqi@0 | 102 | parser.addParserListener(new ParserListener() { |
aoqi@0 | 103 | @Override |
aoqi@0 | 104 | public void ignoringExtension(Entity entity, QName name, QName parent) { |
aoqi@0 | 105 | if (parent.equals(WSDLConstants.QNAME_TYPES)) { |
aoqi@0 | 106 | // check for a schema element with the wrong namespace URI |
aoqi@0 | 107 | if (name.getLocalPart().equals("schema") |
aoqi@0 | 108 | && !name.getNamespaceURI().equals("")) { |
aoqi@0 | 109 | warning(entity, ModelerMessages.WSDLMODELER_WARNING_IGNORING_UNRECOGNIZED_SCHEMA_EXTENSION(name.getNamespaceURI())); |
aoqi@0 | 110 | } |
aoqi@0 | 111 | } |
aoqi@0 | 112 | |
aoqi@0 | 113 | } |
aoqi@0 | 114 | |
aoqi@0 | 115 | @Override |
aoqi@0 | 116 | public void doneParsingEntity(QName element, Entity entity) { |
aoqi@0 | 117 | } |
aoqi@0 | 118 | }); |
aoqi@0 | 119 | |
aoqi@0 | 120 | document = parser.parse(); |
aoqi@0 | 121 | if (document == null || document.getDefinitions() == null) { |
aoqi@0 | 122 | return null; |
aoqi@0 | 123 | } |
aoqi@0 | 124 | |
aoqi@0 | 125 | document.validateLocally(); |
aoqi@0 | 126 | Model model = internalBuildModel(document); |
aoqi@0 | 127 | if (model == null || errReceiver.hadError()) { |
aoqi@0 | 128 | return null; |
aoqi@0 | 129 | } |
aoqi@0 | 130 | //ClassNameCollector classNameCollector = new ClassNameCollector(); |
aoqi@0 | 131 | classNameCollector.process(model); |
aoqi@0 | 132 | if (classNameCollector.getConflictingClassNames().isEmpty()) { |
aoqi@0 | 133 | if (errReceiver.hadError()) { |
aoqi@0 | 134 | return null; |
aoqi@0 | 135 | } |
aoqi@0 | 136 | return model; |
aoqi@0 | 137 | } |
aoqi@0 | 138 | // do another pass, this time with conflict resolution enabled |
aoqi@0 | 139 | model = internalBuildModel(document); |
aoqi@0 | 140 | |
aoqi@0 | 141 | classNameCollector.process(model); |
aoqi@0 | 142 | if (classNameCollector.getConflictingClassNames().isEmpty()) { |
aoqi@0 | 143 | // we're done |
aoqi@0 | 144 | if (errReceiver.hadError()) { |
aoqi@0 | 145 | return null; |
aoqi@0 | 146 | } |
aoqi@0 | 147 | return model; |
aoqi@0 | 148 | } |
aoqi@0 | 149 | // give up |
aoqi@0 | 150 | StringBuilder conflictList = new StringBuilder(); |
aoqi@0 | 151 | boolean first = true; |
aoqi@0 | 152 | for (Iterator iter = |
aoqi@0 | 153 | classNameCollector.getConflictingClassNames().iterator(); |
aoqi@0 | 154 | iter.hasNext(); |
aoqi@0 | 155 | ) { |
aoqi@0 | 156 | if (!first) { |
aoqi@0 | 157 | conflictList.append(", "); |
aoqi@0 | 158 | } else { |
aoqi@0 | 159 | first = false; |
aoqi@0 | 160 | } |
aoqi@0 | 161 | conflictList.append((String) iter.next()); |
aoqi@0 | 162 | } |
aoqi@0 | 163 | error(document.getDefinitions(), ModelerMessages.WSDLMODELER_UNSOLVABLE_NAMING_CONFLICTS(conflictList.toString())); |
aoqi@0 | 164 | } catch (ModelException e) { |
aoqi@0 | 165 | reportError(document.getDefinitions(), e.getMessage(), e); |
aoqi@0 | 166 | } catch (ParseException e) { |
aoqi@0 | 167 | errReceiver.error(e); |
aoqi@0 | 168 | } catch (ValidationException e) { |
aoqi@0 | 169 | errReceiver.error(e.getMessage(), e); |
aoqi@0 | 170 | } catch (SAXException e) { |
aoqi@0 | 171 | errReceiver.error(e); |
aoqi@0 | 172 | } catch (IOException e) { |
aoqi@0 | 173 | errReceiver.error(e); |
aoqi@0 | 174 | } |
aoqi@0 | 175 | //should never reach here |
aoqi@0 | 176 | return null; |
aoqi@0 | 177 | } |
aoqi@0 | 178 | |
aoqi@0 | 179 | private Model internalBuildModel(WSDLDocument document) { |
aoqi@0 | 180 | numPasses++; |
aoqi@0 | 181 | |
aoqi@0 | 182 | //build the jaxbModel to be used latter |
aoqi@0 | 183 | buildJAXBModel(document); |
aoqi@0 | 184 | |
aoqi@0 | 185 | QName modelName = |
aoqi@0 | 186 | new QName( |
aoqi@0 | 187 | document.getDefinitions().getTargetNamespaceURI(), |
aoqi@0 | 188 | document.getDefinitions().getName() == null |
aoqi@0 | 189 | ? "model" |
aoqi@0 | 190 | : document.getDefinitions().getName()); |
aoqi@0 | 191 | Model model = new Model(modelName, document.getDefinitions()); |
aoqi@0 | 192 | model.setJAXBModel(getJAXBModelBuilder().getJAXBModel()); |
aoqi@0 | 193 | |
aoqi@0 | 194 | // This fails with the changed classname (WSDLModeler to WSDLModeler11 etc.) |
aoqi@0 | 195 | // with this source comaptibility change the WSDL Modeler class name is changed. Right now hardcoding the |
aoqi@0 | 196 | // modeler class name to the same one being checked in WSDLGenerator. |
aoqi@0 | 197 | |
aoqi@0 | 198 | model.setProperty( |
aoqi@0 | 199 | ModelProperties.PROPERTY_MODELER_NAME, |
aoqi@0 | 200 | ModelProperties.WSDL_MODELER_NAME); |
aoqi@0 | 201 | |
aoqi@0 | 202 | _javaExceptions = new HashMap<String, JavaException>(); |
aoqi@0 | 203 | _bindingNameToPortMap = new HashMap<QName, Port>(); |
aoqi@0 | 204 | |
aoqi@0 | 205 | // grab target namespace |
aoqi@0 | 206 | model.setTargetNamespaceURI(document.getDefinitions().getTargetNamespaceURI()); |
aoqi@0 | 207 | |
aoqi@0 | 208 | setDocumentationIfPresent(model, |
aoqi@0 | 209 | document.getDefinitions().getDocumentation()); |
aoqi@0 | 210 | |
aoqi@0 | 211 | boolean hasServices = document.getDefinitions().services().hasNext(); |
aoqi@0 | 212 | if (hasServices) { |
aoqi@0 | 213 | for (Iterator iter = document.getDefinitions().services(); |
aoqi@0 | 214 | iter.hasNext(); |
aoqi@0 | 215 | ) { |
aoqi@0 | 216 | processService((com.sun.tools.internal.ws.wsdl.document.Service) iter.next(), |
aoqi@0 | 217 | model, document); |
aoqi@0 | 218 | } |
aoqi@0 | 219 | } else { |
aoqi@0 | 220 | // emit a warning if there are no service definitions |
aoqi@0 | 221 | warning(model.getEntity(), ModelerMessages.WSDLMODELER_WARNING_NO_SERVICE_DEFINITIONS_FOUND()); |
aoqi@0 | 222 | } |
aoqi@0 | 223 | |
aoqi@0 | 224 | return model; |
aoqi@0 | 225 | } |
aoqi@0 | 226 | |
aoqi@0 | 227 | /* (non-Javadoc) |
aoqi@0 | 228 | * @see WSDLModelerBase#processService(Service, Model, WSDLDocument) |
aoqi@0 | 229 | */ |
aoqi@0 | 230 | protected void processService(com.sun.tools.internal.ws.wsdl.document.Service wsdlService, Model model, WSDLDocument document) { |
aoqi@0 | 231 | QName serviceQName = getQNameOf(wsdlService); |
aoqi@0 | 232 | String serviceInterface = getServiceInterfaceName(serviceQName, wsdlService); |
aoqi@0 | 233 | if (isConflictingServiceClassName(serviceInterface)) { |
aoqi@0 | 234 | serviceInterface += "_Service"; |
aoqi@0 | 235 | } |
aoqi@0 | 236 | Service service = |
aoqi@0 | 237 | new Service( |
aoqi@0 | 238 | serviceQName, |
aoqi@0 | 239 | new JavaInterface(serviceInterface, serviceInterface + "Impl"), wsdlService); |
aoqi@0 | 240 | |
aoqi@0 | 241 | setDocumentationIfPresent(service, wsdlService.getDocumentation()); |
aoqi@0 | 242 | boolean hasPorts = false; |
aoqi@0 | 243 | for (Iterator iter = wsdlService.ports(); iter.hasNext();) { |
aoqi@0 | 244 | boolean processed = |
aoqi@0 | 245 | processPort( |
aoqi@0 | 246 | (com.sun.tools.internal.ws.wsdl.document.Port) iter.next(), |
aoqi@0 | 247 | service, |
aoqi@0 | 248 | document); |
aoqi@0 | 249 | hasPorts = hasPorts || processed; |
aoqi@0 | 250 | } |
aoqi@0 | 251 | if (!hasPorts) { |
aoqi@0 | 252 | // emit a warning if there are no ports |
aoqi@0 | 253 | warning(wsdlService, ModelerMessages.WSDLMODELER_WARNING_NO_PORTS_IN_SERVICE(wsdlService.getName())); |
aoqi@0 | 254 | } else { |
aoqi@0 | 255 | model.addService(service); |
aoqi@0 | 256 | } |
aoqi@0 | 257 | } |
aoqi@0 | 258 | |
aoqi@0 | 259 | /* (non-Javadoc) |
aoqi@0 | 260 | * @see WSDLModelerBase#processPort(WSDLPort, Service, WSDLDocument) |
aoqi@0 | 261 | */ |
aoqi@0 | 262 | protected boolean processPort(com.sun.tools.internal.ws.wsdl.document.Port wsdlPort, |
aoqi@0 | 263 | Service service, WSDLDocument document) { |
aoqi@0 | 264 | try { |
aoqi@0 | 265 | |
aoqi@0 | 266 | //clear the unique block map |
aoqi@0 | 267 | uniqueBodyBlocks.clear(); |
aoqi@0 | 268 | |
aoqi@0 | 269 | QName portQName = getQNameOf(wsdlPort); |
aoqi@0 | 270 | Port port = new Port(portQName, wsdlPort); |
aoqi@0 | 271 | |
aoqi@0 | 272 | setDocumentationIfPresent(port, wsdlPort.getDocumentation()); |
aoqi@0 | 273 | |
aoqi@0 | 274 | SOAPAddress soapAddress = |
aoqi@0 | 275 | (SOAPAddress) getExtensionOfType(wsdlPort, SOAPAddress.class); |
aoqi@0 | 276 | if (soapAddress == null) { |
aoqi@0 | 277 | if(options.isExtensionMode()){ |
aoqi@0 | 278 | warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_NO_SOAP_ADDRESS(wsdlPort.getName())); |
aoqi@0 | 279 | }else{ |
aoqi@0 | 280 | // not a SOAP port, ignore it |
aoqi@0 | 281 | warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_IGNORING_NON_SOAP_PORT_NO_ADDRESS(wsdlPort.getName())); |
aoqi@0 | 282 | return false; |
aoqi@0 | 283 | } |
aoqi@0 | 284 | } |
aoqi@0 | 285 | if (soapAddress != null) { |
aoqi@0 | 286 | port.setAddress(soapAddress.getLocation()); |
aoqi@0 | 287 | } |
aoqi@0 | 288 | Binding binding = wsdlPort.resolveBinding(document); |
aoqi@0 | 289 | QName bindingName = getQNameOf(binding); |
aoqi@0 | 290 | PortType portType = binding.resolvePortType(document); |
aoqi@0 | 291 | |
aoqi@0 | 292 | port.setProperty( |
aoqi@0 | 293 | ModelProperties.PROPERTY_WSDL_PORT_NAME, |
aoqi@0 | 294 | getQNameOf(wsdlPort)); |
aoqi@0 | 295 | port.setProperty( |
aoqi@0 | 296 | ModelProperties.PROPERTY_WSDL_PORT_TYPE_NAME, |
aoqi@0 | 297 | getQNameOf(portType)); |
aoqi@0 | 298 | port.setProperty( |
aoqi@0 | 299 | ModelProperties.PROPERTY_WSDL_BINDING_NAME, |
aoqi@0 | 300 | bindingName); |
aoqi@0 | 301 | |
aoqi@0 | 302 | boolean isProvider = isProvider(wsdlPort); |
aoqi@0 | 303 | if (_bindingNameToPortMap.containsKey(bindingName) && !isProvider) { |
aoqi@0 | 304 | // this binding has been processed before |
aoqi@0 | 305 | Port existingPort = |
aoqi@0 | 306 | _bindingNameToPortMap.get(bindingName); |
aoqi@0 | 307 | port.setOperations(existingPort.getOperations()); |
aoqi@0 | 308 | port.setJavaInterface(existingPort.getJavaInterface()); |
aoqi@0 | 309 | port.setStyle(existingPort.getStyle()); |
aoqi@0 | 310 | port.setWrapped(existingPort.isWrapped()); |
aoqi@0 | 311 | } else { |
aoqi@0 | 312 | // find out the SOAP binding extension, if any |
aoqi@0 | 313 | SOAPBinding soapBinding = |
aoqi@0 | 314 | (SOAPBinding) getExtensionOfType(binding, SOAPBinding.class); |
aoqi@0 | 315 | |
aoqi@0 | 316 | if (soapBinding == null) { |
aoqi@0 | 317 | soapBinding = |
aoqi@0 | 318 | (SOAPBinding) getExtensionOfType(binding, SOAP12Binding.class); |
aoqi@0 | 319 | if (soapBinding == null) { |
aoqi@0 | 320 | if(!options.isExtensionMode()){ |
aoqi@0 | 321 | // cannot deal with non-SOAP ports |
aoqi@0 | 322 | warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_IGNORING_NON_SOAP_PORT(wsdlPort.getName())); |
aoqi@0 | 323 | return false; |
aoqi@0 | 324 | }else{ |
aoqi@0 | 325 | warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_NON_SOAP_PORT(wsdlPort.getName())); |
aoqi@0 | 326 | } |
aoqi@0 | 327 | }else{ |
aoqi@0 | 328 | // we can only do soap1.2 if extensions are on |
aoqi@0 | 329 | if (options.isExtensionMode()) { |
aoqi@0 | 330 | warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_PORT_SOAP_BINDING_12(wsdlPort.getName())); |
aoqi@0 | 331 | } else { |
aoqi@0 | 332 | warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_IGNORING_SOAP_BINDING_12(wsdlPort.getName())); |
aoqi@0 | 333 | return false; |
aoqi@0 | 334 | } |
aoqi@0 | 335 | } |
aoqi@0 | 336 | } |
aoqi@0 | 337 | |
aoqi@0 | 338 | if (soapBinding != null && (soapBinding.getTransport() == null |
aoqi@0 | 339 | || (!soapBinding.getTransport().equals( |
aoqi@0 | 340 | SOAPConstants.URI_SOAP_TRANSPORT_HTTP) && !soapBinding.getTransport().equals( |
aoqi@0 | 341 | SOAP12Constants.URI_SOAP_TRANSPORT_HTTP)))) { |
aoqi@0 | 342 | if (!options.isExtensionMode()) { |
aoqi@0 | 343 | // cannot deal with non-HTTP ports |
aoqi@0 | 344 | warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_IGNORING_SOAP_BINDING_NON_HTTP_TRANSPORT(wsdlPort.getName())); |
aoqi@0 | 345 | return false; |
aoqi@0 | 346 | } |
aoqi@0 | 347 | |
aoqi@0 | 348 | } |
aoqi@0 | 349 | |
aoqi@0 | 350 | /** |
aoqi@0 | 351 | * validate wsdl:binding uniqueness in style, e.g. rpclit or doclit |
aoqi@0 | 352 | * ref: WSI BP 1.1 R 2705 |
aoqi@0 | 353 | */ |
aoqi@0 | 354 | if (soapBinding != null && !validateWSDLBindingStyle(binding)) { |
aoqi@0 | 355 | if (options.isExtensionMode()) { |
aoqi@0 | 356 | warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_PORT_SOAP_BINDING_MIXED_STYLE(wsdlPort.getName())); |
aoqi@0 | 357 | } else { |
aoqi@0 | 358 | error(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_IGNORING_SOAP_BINDING_MIXED_STYLE(wsdlPort.getName())); |
aoqi@0 | 359 | } |
aoqi@0 | 360 | } |
aoqi@0 | 361 | |
aoqi@0 | 362 | if(soapBinding != null){ |
aoqi@0 | 363 | port.setStyle(soapBinding.getStyle()); |
aoqi@0 | 364 | } |
aoqi@0 | 365 | |
aoqi@0 | 366 | boolean hasOverloadedOperations = false; |
aoqi@0 | 367 | Set<String> operationNames = new HashSet<String>(); |
aoqi@0 | 368 | for (Iterator iter = portType.operations(); iter.hasNext();) { |
aoqi@0 | 369 | com.sun.tools.internal.ws.wsdl.document.Operation operation = |
aoqi@0 | 370 | (com.sun.tools.internal.ws.wsdl.document.Operation) iter.next(); |
aoqi@0 | 371 | |
aoqi@0 | 372 | if (operationNames.contains(operation.getName())) { |
aoqi@0 | 373 | hasOverloadedOperations = true; |
aoqi@0 | 374 | break; |
aoqi@0 | 375 | } |
aoqi@0 | 376 | operationNames.add(operation.getName()); |
aoqi@0 | 377 | |
aoqi@0 | 378 | for (Iterator itr = binding.operations(); |
aoqi@0 | 379 | iter.hasNext(); |
aoqi@0 | 380 | ) { |
aoqi@0 | 381 | BindingOperation bindingOperation = |
aoqi@0 | 382 | (BindingOperation) itr.next(); |
aoqi@0 | 383 | if (operation |
aoqi@0 | 384 | .getName() |
aoqi@0 | 385 | .equals(bindingOperation.getName())) { |
aoqi@0 | 386 | break; |
aoqi@0 | 387 | } else if (!itr.hasNext()) { |
aoqi@0 | 388 | error(bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_NOT_FOUND(operation.getName(), bindingOperation.getName())); |
aoqi@0 | 389 | } |
aoqi@0 | 390 | } |
aoqi@0 | 391 | } |
aoqi@0 | 392 | |
aoqi@0 | 393 | Map headers = new HashMap(); |
aoqi@0 | 394 | boolean hasOperations = false; |
aoqi@0 | 395 | for (Iterator iter = binding.operations(); iter.hasNext();) { |
aoqi@0 | 396 | BindingOperation bindingOperation = |
aoqi@0 | 397 | (BindingOperation) iter.next(); |
aoqi@0 | 398 | |
aoqi@0 | 399 | com.sun.tools.internal.ws.wsdl.document.Operation portTypeOperation = |
aoqi@0 | 400 | null; |
aoqi@0 | 401 | Set operations = |
aoqi@0 | 402 | portType.getOperationsNamed(bindingOperation.getName()); |
aoqi@0 | 403 | if (operations.isEmpty()) { |
aoqi@0 | 404 | // the WSDL document is invalid |
aoqi@0 | 405 | error(bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_NOT_IN_PORT_TYPE(bindingOperation.getName(), binding.getName())); |
aoqi@0 | 406 | } else if (operations.size() == 1) { |
aoqi@0 | 407 | portTypeOperation = |
aoqi@0 | 408 | (com.sun.tools.internal.ws.wsdl.document.Operation) operations |
aoqi@0 | 409 | .iterator() |
aoqi@0 | 410 | .next(); |
aoqi@0 | 411 | } else { |
aoqi@0 | 412 | boolean found = false; |
aoqi@0 | 413 | String expectedInputName = |
aoqi@0 | 414 | bindingOperation.getInput().getName(); |
aoqi@0 | 415 | String expectedOutputName = |
aoqi@0 | 416 | bindingOperation.getOutput().getName(); |
aoqi@0 | 417 | |
aoqi@0 | 418 | for (Iterator iter2 = operations.iterator(); iter2.hasNext();) { |
aoqi@0 | 419 | com.sun.tools.internal.ws.wsdl.document.Operation candidateOperation = |
aoqi@0 | 420 | (com.sun.tools.internal.ws.wsdl.document.Operation) iter2 |
aoqi@0 | 421 | .next(); |
aoqi@0 | 422 | |
aoqi@0 | 423 | if (expectedInputName == null) { |
aoqi@0 | 424 | // the WSDL document is invalid |
aoqi@0 | 425 | error(bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_MISSING_INPUT_NAME(bindingOperation.getName())); |
aoqi@0 | 426 | } |
aoqi@0 | 427 | if (expectedOutputName == null) { |
aoqi@0 | 428 | // the WSDL document is invalid |
aoqi@0 | 429 | error(bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_MISSING_OUTPUT_NAME(bindingOperation.getName())); |
aoqi@0 | 430 | } |
aoqi@0 | 431 | if (expectedInputName |
aoqi@0 | 432 | .equals(candidateOperation.getInput().getName()) |
aoqi@0 | 433 | && expectedOutputName.equals( |
aoqi@0 | 434 | candidateOperation |
aoqi@0 | 435 | .getOutput() |
aoqi@0 | 436 | .getName())) { |
aoqi@0 | 437 | if (found) { |
aoqi@0 | 438 | // the WSDL document is invalid |
aoqi@0 | 439 | error(bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_MULTIPLE_MATCHING_OPERATIONS(bindingOperation.getName(), bindingOperation.getName())); |
aoqi@0 | 440 | } |
aoqi@0 | 441 | // got it! |
aoqi@0 | 442 | found = true; |
aoqi@0 | 443 | portTypeOperation = candidateOperation; |
aoqi@0 | 444 | } |
aoqi@0 | 445 | } |
aoqi@0 | 446 | if (!found) { |
aoqi@0 | 447 | // the WSDL document is invalid |
aoqi@0 | 448 | error(bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_NOT_FOUND(bindingOperation.getName(), binding.getName())); |
aoqi@0 | 449 | } |
aoqi@0 | 450 | } |
aoqi@0 | 451 | if (!isProvider) { |
aoqi@0 | 452 | this.info = |
aoqi@0 | 453 | new ProcessSOAPOperationInfo( |
aoqi@0 | 454 | port, |
aoqi@0 | 455 | wsdlPort, |
aoqi@0 | 456 | portTypeOperation, |
aoqi@0 | 457 | bindingOperation, |
aoqi@0 | 458 | soapBinding, |
aoqi@0 | 459 | document, |
aoqi@0 | 460 | hasOverloadedOperations, |
aoqi@0 | 461 | headers); |
aoqi@0 | 462 | |
aoqi@0 | 463 | |
aoqi@0 | 464 | Operation operation; |
aoqi@0 | 465 | if (soapBinding != null) { |
aoqi@0 | 466 | operation = processSOAPOperation(); |
aoqi@0 | 467 | } else { |
aoqi@0 | 468 | operation = processNonSOAPOperation(); |
aoqi@0 | 469 | } |
aoqi@0 | 470 | if (operation != null) { |
aoqi@0 | 471 | port.addOperation(operation); |
aoqi@0 | 472 | hasOperations = true; |
aoqi@0 | 473 | } |
aoqi@0 | 474 | } |
aoqi@0 | 475 | } |
aoqi@0 | 476 | if (!isProvider && !hasOperations) { |
aoqi@0 | 477 | // emit a warning if there are no operations, except when its a provider port |
aoqi@0 | 478 | warning(wsdlPort, ModelerMessages.WSDLMODELER_WARNING_NO_OPERATIONS_IN_PORT(wsdlPort.getName())); |
aoqi@0 | 479 | return false; |
aoqi@0 | 480 | } |
aoqi@0 | 481 | createJavaInterfaceForPort(port, isProvider); |
aoqi@0 | 482 | PortType pt = binding.resolvePortType(document); |
aoqi@0 | 483 | String jd = (pt.getDocumentation() != null) ? pt.getDocumentation().getContent() : null; |
aoqi@0 | 484 | port.getJavaInterface().setJavaDoc(jd); |
aoqi@0 | 485 | _bindingNameToPortMap.put(bindingName, port); |
aoqi@0 | 486 | } |
aoqi@0 | 487 | |
aoqi@0 | 488 | service.addPort(port); |
aoqi@0 | 489 | applyPortMethodCustomization(port, wsdlPort); |
aoqi@0 | 490 | applyWrapperStyleCustomization(port, binding.resolvePortType(document)); |
aoqi@0 | 491 | |
aoqi@0 | 492 | return true; |
aoqi@0 | 493 | |
aoqi@0 | 494 | } catch (NoSuchEntityException e) { |
aoqi@0 | 495 | warning(document.getDefinitions(), e.getMessage()); |
aoqi@0 | 496 | // should not happen |
aoqi@0 | 497 | return false; |
aoqi@0 | 498 | } |
aoqi@0 | 499 | } |
aoqi@0 | 500 | |
aoqi@0 | 501 | /** |
aoqi@0 | 502 | * Returns an operation purely from abstract operation |
aoqi@0 | 503 | */ |
aoqi@0 | 504 | private Operation processNonSOAPOperation() { |
aoqi@0 | 505 | Operation operation = |
aoqi@0 | 506 | new Operation(new QName(null, info.bindingOperation.getName()), info.bindingOperation); |
aoqi@0 | 507 | |
aoqi@0 | 508 | setDocumentationIfPresent( |
aoqi@0 | 509 | operation, |
aoqi@0 | 510 | info.portTypeOperation.getDocumentation()); |
aoqi@0 | 511 | |
aoqi@0 | 512 | if (info.portTypeOperation.getStyle() |
aoqi@0 | 513 | != OperationStyle.REQUEST_RESPONSE |
aoqi@0 | 514 | && info.portTypeOperation.getStyle() != OperationStyle.ONE_WAY) { |
aoqi@0 | 515 | if (options.isExtensionMode()) { |
aoqi@0 | 516 | warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_NOT_SUPPORTED_STYLE(info.portTypeOperation.getName())); |
aoqi@0 | 517 | return null; |
aoqi@0 | 518 | } else { |
aoqi@0 | 519 | error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_OPERATION_NOT_SUPPORTED_STYLE(info.portTypeOperation.getName(), |
aoqi@0 | 520 | info.port.resolveBinding(document).resolvePortType(document).getName())); |
aoqi@0 | 521 | } |
aoqi@0 | 522 | } |
aoqi@0 | 523 | |
aoqi@0 | 524 | boolean isRequestResponse = info.portTypeOperation.getStyle() == OperationStyle.REQUEST_RESPONSE; |
aoqi@0 | 525 | Message inputMessage = getInputMessage(); |
aoqi@0 | 526 | Request request = new Request(inputMessage, errReceiver); |
aoqi@0 | 527 | request.setErrorReceiver(errReceiver); |
aoqi@0 | 528 | info.operation = operation; |
aoqi@0 | 529 | info.operation.setWSDLPortTypeOperation(info.portTypeOperation); |
aoqi@0 | 530 | |
aoqi@0 | 531 | Response response; |
aoqi@0 | 532 | |
aoqi@0 | 533 | Message outputMessage = null; |
aoqi@0 | 534 | if (isRequestResponse) { |
aoqi@0 | 535 | outputMessage = getOutputMessage(); |
aoqi@0 | 536 | response = new Response(outputMessage, errReceiver); |
aoqi@0 | 537 | }else{ |
aoqi@0 | 538 | response = new Response(null, errReceiver); |
aoqi@0 | 539 | } |
aoqi@0 | 540 | |
aoqi@0 | 541 | //set the style based on heuristic that message has either all parts defined |
aoqi@0 | 542 | // using type(RPC) or element(DOCUMENT) |
aoqi@0 | 543 | setNonSoapStyle(inputMessage, outputMessage); |
aoqi@0 | 544 | |
aoqi@0 | 545 | // Process parameterOrder and get the parameterList |
aoqi@0 | 546 | List<MessagePart> parameterList = getParameterOrder(); |
aoqi@0 | 547 | |
aoqi@0 | 548 | boolean unwrappable = isUnwrappable(); |
aoqi@0 | 549 | info.operation.setWrapped(unwrappable); |
aoqi@0 | 550 | List<Parameter> params = getDoclitParameters(request, response, parameterList); |
aoqi@0 | 551 | if (!validateParameterName(params)) { |
aoqi@0 | 552 | return null; |
aoqi@0 | 553 | } |
aoqi@0 | 554 | |
aoqi@0 | 555 | // create a definitive list of parameters to match what we'd like to get |
aoqi@0 | 556 | // in the java interface (which is generated much later), parameterOrder |
aoqi@0 | 557 | List<Parameter> definitiveParameterList = new ArrayList<Parameter>(); |
aoqi@0 | 558 | for (Parameter param : params) { |
aoqi@0 | 559 | if (param.isReturn()) { |
aoqi@0 | 560 | info.operation.setProperty(WSDL_RESULT_PARAMETER, param); |
aoqi@0 | 561 | response.addParameter(param); |
aoqi@0 | 562 | continue; |
aoqi@0 | 563 | } |
aoqi@0 | 564 | if (param.isIN()) { |
aoqi@0 | 565 | request.addParameter(param); |
aoqi@0 | 566 | } else if (param.isOUT()) { |
aoqi@0 | 567 | response.addParameter(param); |
aoqi@0 | 568 | } else if (param.isINOUT()) { |
aoqi@0 | 569 | request.addParameter(param); |
aoqi@0 | 570 | response.addParameter(param); |
aoqi@0 | 571 | } |
aoqi@0 | 572 | definitiveParameterList.add(param); |
aoqi@0 | 573 | } |
aoqi@0 | 574 | |
aoqi@0 | 575 | info.operation.setRequest(request); |
aoqi@0 | 576 | |
aoqi@0 | 577 | if (isRequestResponse) { |
aoqi@0 | 578 | info.operation.setResponse(response); |
aoqi@0 | 579 | } |
aoqi@0 | 580 | |
aoqi@0 | 581 | // faults with duplicate names |
aoqi@0 | 582 | Set duplicateNames = getDuplicateFaultNames(); |
aoqi@0 | 583 | |
aoqi@0 | 584 | // handle soap:fault |
aoqi@0 | 585 | handleLiteralSOAPFault(response, duplicateNames); |
aoqi@0 | 586 | info.operation.setProperty( |
aoqi@0 | 587 | WSDL_PARAMETER_ORDER, |
aoqi@0 | 588 | definitiveParameterList); |
aoqi@0 | 589 | |
aoqi@0 | 590 | Binding binding = info.port.resolveBinding(document); |
aoqi@0 | 591 | PortType portType = binding.resolvePortType(document); |
aoqi@0 | 592 | if (isAsync(portType, info.portTypeOperation)) { |
aoqi@0 | 593 | warning(portType, "Can not generate Async methods for non-soap binding!"); |
aoqi@0 | 594 | } |
aoqi@0 | 595 | return info.operation; |
aoqi@0 | 596 | } |
aoqi@0 | 597 | |
aoqi@0 | 598 | /** |
aoqi@0 | 599 | * This method is added to fix one of the use case for j2ee se folks, so that we determine |
aoqi@0 | 600 | * for non_soap wsdl what could be the style - rpc or document based on parts in the message. |
aoqi@0 | 601 | * |
aoqi@0 | 602 | * We assume that the message parts could have either all of them with type attribute (RPC) |
aoqi@0 | 603 | * or element (DOCUMENT) |
aoqi@0 | 604 | * |
aoqi@0 | 605 | * Shall this check if parts are mixed and throw error message? |
aoqi@0 | 606 | */ |
aoqi@0 | 607 | private void setNonSoapStyle(Message inputMessage, Message outputMessage) { |
aoqi@0 | 608 | SOAPStyle style = SOAPStyle.DOCUMENT; |
aoqi@0 | 609 | for(MessagePart part:inputMessage.getParts()){ |
aoqi@0 | 610 | if (part.getDescriptorKind() == SchemaKinds.XSD_TYPE) { |
aoqi@0 | 611 | style = SOAPStyle.RPC; |
aoqi@0 | 612 | } else { |
aoqi@0 | 613 | style = SOAPStyle.DOCUMENT; |
aoqi@0 | 614 | } |
aoqi@0 | 615 | } |
aoqi@0 | 616 | |
aoqi@0 | 617 | //check the outputMessage parts |
aoqi@0 | 618 | if(outputMessage != null){ |
aoqi@0 | 619 | for(MessagePart part:outputMessage.getParts()){ |
aoqi@0 | 620 | if (part.getDescriptorKind() == SchemaKinds.XSD_TYPE) { |
aoqi@0 | 621 | style = SOAPStyle.RPC; |
aoqi@0 | 622 | } else { |
aoqi@0 | 623 | style = SOAPStyle.DOCUMENT; |
aoqi@0 | 624 | } |
aoqi@0 | 625 | } |
aoqi@0 | 626 | } |
aoqi@0 | 627 | info.modelPort.setStyle(style); |
aoqi@0 | 628 | } |
aoqi@0 | 629 | |
aoqi@0 | 630 | /* (non-Javadoc) |
aoqi@0 | 631 | * @see WSDLModelerBase#processSOAPOperation() |
aoqi@0 | 632 | */ |
aoqi@0 | 633 | protected Operation processSOAPOperation() { |
aoqi@0 | 634 | Operation operation = |
aoqi@0 | 635 | new Operation(new QName(null, info.bindingOperation.getName()), info.bindingOperation); |
aoqi@0 | 636 | |
aoqi@0 | 637 | setDocumentationIfPresent( |
aoqi@0 | 638 | operation, |
aoqi@0 | 639 | info.portTypeOperation.getDocumentation()); |
aoqi@0 | 640 | |
aoqi@0 | 641 | if (info.portTypeOperation.getStyle() |
aoqi@0 | 642 | != OperationStyle.REQUEST_RESPONSE |
aoqi@0 | 643 | && info.portTypeOperation.getStyle() != OperationStyle.ONE_WAY) { |
aoqi@0 | 644 | if (options.isExtensionMode()) { |
aoqi@0 | 645 | warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_NOT_SUPPORTED_STYLE(info.portTypeOperation.getName())); |
aoqi@0 | 646 | return null; |
aoqi@0 | 647 | } else { |
aoqi@0 | 648 | error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_OPERATION_NOT_SUPPORTED_STYLE(info.portTypeOperation.getName(), |
aoqi@0 | 649 | info.port.resolveBinding(document).resolvePortType(document).getName())); |
aoqi@0 | 650 | } |
aoqi@0 | 651 | } |
aoqi@0 | 652 | |
aoqi@0 | 653 | SOAPStyle soapStyle = info.soapBinding.getStyle(); |
aoqi@0 | 654 | |
aoqi@0 | 655 | // find out the SOAP operation extension, if any |
aoqi@0 | 656 | SOAPOperation soapOperation = |
aoqi@0 | 657 | (SOAPOperation) getExtensionOfType(info.bindingOperation, |
aoqi@0 | 658 | SOAPOperation.class); |
aoqi@0 | 659 | |
aoqi@0 | 660 | if (soapOperation != null) { |
aoqi@0 | 661 | if (soapOperation.getStyle() != null) { |
aoqi@0 | 662 | soapStyle = soapOperation.getStyle(); |
aoqi@0 | 663 | } |
aoqi@0 | 664 | if (soapOperation.getSOAPAction() != null) { |
aoqi@0 | 665 | operation.setSOAPAction(soapOperation.getSOAPAction()); |
aoqi@0 | 666 | } |
aoqi@0 | 667 | } |
aoqi@0 | 668 | |
aoqi@0 | 669 | operation.setStyle(soapStyle); |
aoqi@0 | 670 | |
aoqi@0 | 671 | String uniqueOperationName = |
aoqi@0 | 672 | getUniqueName(info.portTypeOperation, info.hasOverloadedOperations); |
aoqi@0 | 673 | if (info.hasOverloadedOperations) { |
aoqi@0 | 674 | operation.setUniqueName(uniqueOperationName); |
aoqi@0 | 675 | } |
aoqi@0 | 676 | |
aoqi@0 | 677 | info.operation = operation; |
aoqi@0 | 678 | |
aoqi@0 | 679 | //attachment |
aoqi@0 | 680 | SOAPBody soapRequestBody = getSOAPRequestBody(); |
aoqi@0 | 681 | if (soapRequestBody == null) { |
aoqi@0 | 682 | // the WSDL document is invalid |
aoqi@0 | 683 | error(info.bindingOperation, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_INPUT_MISSING_SOAP_BODY(info.bindingOperation.getName())); |
aoqi@0 | 684 | } |
aoqi@0 | 685 | |
aoqi@0 | 686 | if (soapStyle == SOAPStyle.RPC) { |
aoqi@0 | 687 | if (soapRequestBody.isEncoded()) { |
aoqi@0 | 688 | if(options.isExtensionMode()){ |
aoqi@0 | 689 | warning(soapRequestBody, ModelerMessages.WSDLMODELER_20_RPCENC_NOT_SUPPORTED()); |
aoqi@0 | 690 | processNonSOAPOperation(); |
aoqi@0 | 691 | }else{ |
aoqi@0 | 692 | error(soapRequestBody, ModelerMessages.WSDLMODELER_20_RPCENC_NOT_SUPPORTED()); |
aoqi@0 | 693 | } |
aoqi@0 | 694 | } |
aoqi@0 | 695 | return processLiteralSOAPOperation(StyleAndUse.RPC_LITERAL); |
aoqi@0 | 696 | } |
aoqi@0 | 697 | // document style |
aoqi@0 | 698 | return processLiteralSOAPOperation(StyleAndUse.DOC_LITERAL); |
aoqi@0 | 699 | } |
aoqi@0 | 700 | |
aoqi@0 | 701 | protected Operation processLiteralSOAPOperation(StyleAndUse styleAndUse) { |
aoqi@0 | 702 | //returns false if the operation name is not acceptable |
aoqi@0 | 703 | if (!applyOperationNameCustomization()) { |
aoqi@0 | 704 | return null; |
aoqi@0 | 705 | } |
aoqi@0 | 706 | |
aoqi@0 | 707 | boolean isRequestResponse = info.portTypeOperation.getStyle() == OperationStyle.REQUEST_RESPONSE; |
aoqi@0 | 708 | Message inputMessage = getInputMessage(); |
aoqi@0 | 709 | Request request = new Request(inputMessage, errReceiver); |
aoqi@0 | 710 | request.setErrorReceiver(errReceiver); |
aoqi@0 | 711 | info.operation.setUse(SOAPUse.LITERAL); |
aoqi@0 | 712 | info.operation.setWSDLPortTypeOperation(info.portTypeOperation); |
aoqi@0 | 713 | SOAPBody soapRequestBody = getSOAPRequestBody(); |
aoqi@0 | 714 | if ((StyleAndUse.DOC_LITERAL == styleAndUse) && (soapRequestBody.getNamespace() != null)) { |
aoqi@0 | 715 | warning(soapRequestBody, ModelerMessages.WSDLMODELER_WARNING_R_2716("soapbind:body", info.bindingOperation.getName())); |
aoqi@0 | 716 | } |
aoqi@0 | 717 | |
aoqi@0 | 718 | |
aoqi@0 | 719 | Response response; |
aoqi@0 | 720 | |
aoqi@0 | 721 | SOAPBody soapResponseBody = null; |
aoqi@0 | 722 | Message outputMessage = null; |
aoqi@0 | 723 | if (isRequestResponse) { |
aoqi@0 | 724 | soapResponseBody = getSOAPResponseBody(); |
aoqi@0 | 725 | if (isOperationDocumentLiteral(styleAndUse) && (soapResponseBody.getNamespace() != null)) { |
aoqi@0 | 726 | warning(soapResponseBody, ModelerMessages.WSDLMODELER_WARNING_R_2716("soapbind:body", info.bindingOperation.getName())); |
aoqi@0 | 727 | } |
aoqi@0 | 728 | outputMessage = getOutputMessage(); |
aoqi@0 | 729 | response = new Response(outputMessage, errReceiver); |
aoqi@0 | 730 | }else{ |
aoqi@0 | 731 | response = new Response(null, errReceiver); |
aoqi@0 | 732 | } |
aoqi@0 | 733 | |
aoqi@0 | 734 | //ignore operation if there are more than one root part |
aoqi@0 | 735 | if (!validateMimeParts(getMimeParts(info.bindingOperation.getInput())) || |
aoqi@0 | 736 | !validateMimeParts(getMimeParts(info.bindingOperation.getOutput()))) { |
aoqi@0 | 737 | return null; |
aoqi@0 | 738 | } |
aoqi@0 | 739 | |
aoqi@0 | 740 | if (!validateBodyParts(info.bindingOperation)) { |
aoqi@0 | 741 | // BP 1.1 |
aoqi@0 | 742 | // R2204 A document-literal binding in a DESCRIPTION MUST refer, in each of its soapbind:body element(s), |
aoqi@0 | 743 | // only to wsdl:part element(s) that have been defined using the element attribute. |
aoqi@0 | 744 | |
aoqi@0 | 745 | // R2203 An rpc-literal binding in a DESCRIPTION MUST refer, in its soapbind:body element(s), |
aoqi@0 | 746 | // only to wsdNl:part element(s) that have been defined using the type attribute. |
aoqi@0 | 747 | if (isOperationDocumentLiteral(styleAndUse)) { |
aoqi@0 | 748 | if (options.isExtensionMode()) { |
aoqi@0 | 749 | warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_CANNOT_HANDLE_TYPE_MESSAGE_PART(info.portTypeOperation.getName())); |
aoqi@0 | 750 | } else { |
aoqi@0 | 751 | error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_DOCLITOPERATION(info.portTypeOperation.getName())); |
aoqi@0 | 752 | } |
aoqi@0 | 753 | } else if (isOperationRpcLiteral(styleAndUse)) { |
aoqi@0 | 754 | if (options.isExtensionMode()) { |
aoqi@0 | 755 | warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_CANNOT_HANDLE_ELEMENT_MESSAGE_PART(info.portTypeOperation.getName())); |
aoqi@0 | 756 | } else { |
aoqi@0 | 757 | error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_RPCLITOPERATION(info.portTypeOperation.getName())); |
aoqi@0 | 758 | } |
aoqi@0 | 759 | } |
aoqi@0 | 760 | return null; |
aoqi@0 | 761 | } |
aoqi@0 | 762 | |
aoqi@0 | 763 | // Process parameterOrder and get the parameterList |
aoqi@0 | 764 | List<MessagePart> parameterList = getParameterOrder(); |
aoqi@0 | 765 | |
aoqi@0 | 766 | //binding is invalid in the wsdl, ignore the operation. |
aoqi@0 | 767 | if (!setMessagePartsBinding(styleAndUse)) { |
aoqi@0 | 768 | return null; |
aoqi@0 | 769 | } |
aoqi@0 | 770 | |
aoqi@0 | 771 | List<Parameter> params = null; |
aoqi@0 | 772 | boolean unwrappable = isUnwrappable(); |
aoqi@0 | 773 | info.operation.setWrapped(unwrappable); |
aoqi@0 | 774 | if (isOperationDocumentLiteral(styleAndUse)) { |
aoqi@0 | 775 | params = getDoclitParameters(request, response, parameterList); |
aoqi@0 | 776 | } else if (isOperationRpcLiteral(styleAndUse)) { |
aoqi@0 | 777 | String operationName = info.bindingOperation.getName(); |
aoqi@0 | 778 | Block reqBlock = null; |
aoqi@0 | 779 | if (inputMessage != null) { |
aoqi@0 | 780 | QName name = new QName(getRequestNamespaceURI(soapRequestBody), operationName); |
aoqi@0 | 781 | RpcLitStructure rpcStruct = new RpcLitStructure(name, getJAXBModelBuilder().getJAXBModel()); |
aoqi@0 | 782 | rpcStruct.setJavaType(new JavaSimpleType("com.sun.xml.internal.ws.encoding.jaxb.RpcLitPayload", null)); |
aoqi@0 | 783 | reqBlock = new Block(name, rpcStruct, inputMessage); |
aoqi@0 | 784 | request.addBodyBlock(reqBlock); |
aoqi@0 | 785 | } |
aoqi@0 | 786 | |
aoqi@0 | 787 | Block resBlock = null; |
aoqi@0 | 788 | if (isRequestResponse && outputMessage != null) { |
aoqi@0 | 789 | QName name = new QName(getResponseNamespaceURI(soapResponseBody), operationName + "Response"); |
aoqi@0 | 790 | RpcLitStructure rpcStruct = new RpcLitStructure(name, getJAXBModelBuilder().getJAXBModel()); |
aoqi@0 | 791 | rpcStruct.setJavaType(new JavaSimpleType("com.sun.xml.internal.ws.encoding.jaxb.RpcLitPayload", null)); |
aoqi@0 | 792 | resBlock = new Block(name, rpcStruct, outputMessage); |
aoqi@0 | 793 | response.addBodyBlock(resBlock); |
aoqi@0 | 794 | } |
aoqi@0 | 795 | params = getRpcLitParameters(request, response, reqBlock, resBlock, parameterList); |
aoqi@0 | 796 | } |
aoqi@0 | 797 | |
aoqi@0 | 798 | |
aoqi@0 | 799 | if (!validateParameterName(params)) { |
aoqi@0 | 800 | return null; |
aoqi@0 | 801 | } |
aoqi@0 | 802 | |
aoqi@0 | 803 | // create a definitive list of parameters to match what we'd like to get |
aoqi@0 | 804 | // in the java interface (which is generated much later), parameterOrder |
aoqi@0 | 805 | List<Parameter> definitiveParameterList = new ArrayList<Parameter>(); |
aoqi@0 | 806 | for (Parameter param : params) { |
aoqi@0 | 807 | if (param.isReturn()) { |
aoqi@0 | 808 | info.operation.setProperty(WSDL_RESULT_PARAMETER, param); |
aoqi@0 | 809 | response.addParameter(param); |
aoqi@0 | 810 | continue; |
aoqi@0 | 811 | } |
aoqi@0 | 812 | if (param.isIN()) { |
aoqi@0 | 813 | request.addParameter(param); |
aoqi@0 | 814 | } else if (param.isOUT()) { |
aoqi@0 | 815 | response.addParameter(param); |
aoqi@0 | 816 | } else if (param.isINOUT()) { |
aoqi@0 | 817 | request.addParameter(param); |
aoqi@0 | 818 | response.addParameter(param); |
aoqi@0 | 819 | } |
aoqi@0 | 820 | definitiveParameterList.add(param); |
aoqi@0 | 821 | } |
aoqi@0 | 822 | |
aoqi@0 | 823 | info.operation.setRequest(request); |
aoqi@0 | 824 | |
aoqi@0 | 825 | if (isRequestResponse) { |
aoqi@0 | 826 | info.operation.setResponse(response); |
aoqi@0 | 827 | } |
aoqi@0 | 828 | |
aoqi@0 | 829 | Iterator<Block> bb = request.getBodyBlocks(); |
aoqi@0 | 830 | QName body; |
aoqi@0 | 831 | Operation thatOp; |
aoqi@0 | 832 | if (bb.hasNext()) { |
aoqi@0 | 833 | body = bb.next().getName(); |
aoqi@0 | 834 | thatOp = uniqueBodyBlocks.get(body); |
aoqi@0 | 835 | } else { |
aoqi@0 | 836 | //there is no body block |
aoqi@0 | 837 | body = VOID_BODYBLOCK; |
aoqi@0 | 838 | thatOp = uniqueBodyBlocks.get(VOID_BODYBLOCK); |
aoqi@0 | 839 | } |
aoqi@0 | 840 | |
aoqi@0 | 841 | if(thatOp != null){ |
aoqi@0 | 842 | if(options.isExtensionMode()){ |
aoqi@0 | 843 | warning(info.port, ModelerMessages.WSDLMODELER_NON_UNIQUE_BODY_WARNING(info.port.getName(), info.operation.getName(), thatOp.getName(), body)); |
aoqi@0 | 844 | }else{ |
aoqi@0 | 845 | error(info.port, ModelerMessages.WSDLMODELER_NON_UNIQUE_BODY_ERROR(info.port.getName(), info.operation.getName(), thatOp.getName(), body)); |
aoqi@0 | 846 | } |
aoqi@0 | 847 | }else{ |
aoqi@0 | 848 | uniqueBodyBlocks.put(body, info.operation); |
aoqi@0 | 849 | } |
aoqi@0 | 850 | |
aoqi@0 | 851 | //Add additional headers |
aoqi@0 | 852 | if (options.additionalHeaders) { |
aoqi@0 | 853 | List<Parameter> additionalHeaders = new ArrayList<Parameter>(); |
aoqi@0 | 854 | if (inputMessage != null) { |
aoqi@0 | 855 | for (MessagePart part : getAdditionHeaderParts(info.bindingOperation, inputMessage, true)) { |
aoqi@0 | 856 | QName name = part.getDescriptor(); |
aoqi@0 | 857 | JAXBType jaxbType = getJAXBType(part); |
aoqi@0 | 858 | Block block = new Block(name, jaxbType, part); |
aoqi@0 | 859 | Parameter param = ModelerUtils.createParameter(part.getName(), jaxbType, block); |
aoqi@0 | 860 | additionalHeaders.add(param); |
aoqi@0 | 861 | request.addHeaderBlock(block); |
aoqi@0 | 862 | request.addParameter(param); |
aoqi@0 | 863 | definitiveParameterList.add(param); |
aoqi@0 | 864 | } |
aoqi@0 | 865 | } |
aoqi@0 | 866 | |
aoqi@0 | 867 | if (isRequestResponse && outputMessage != null) { |
aoqi@0 | 868 | List<Parameter> outParams = new ArrayList<Parameter>(); |
aoqi@0 | 869 | for (MessagePart part : getAdditionHeaderParts(info.bindingOperation,outputMessage, false)) { |
aoqi@0 | 870 | QName name = part.getDescriptor(); |
aoqi@0 | 871 | JAXBType jaxbType = getJAXBType(part); |
aoqi@0 | 872 | Block block = new Block(name, jaxbType, part); |
aoqi@0 | 873 | Parameter param = ModelerUtils.createParameter(part.getName(), jaxbType, block); |
aoqi@0 | 874 | param.setMode(Mode.OUT); |
aoqi@0 | 875 | outParams.add(param); |
aoqi@0 | 876 | response.addHeaderBlock(block); |
aoqi@0 | 877 | response.addParameter(param); |
aoqi@0 | 878 | } |
aoqi@0 | 879 | for (Parameter outParam : outParams) { |
aoqi@0 | 880 | for (Parameter inParam : additionalHeaders) { |
aoqi@0 | 881 | if (inParam.getName().equals(outParam.getName()) && |
aoqi@0 | 882 | inParam.getBlock().getName().equals(outParam.getBlock().getName())) { |
aoqi@0 | 883 | //it is INOUT |
aoqi@0 | 884 | inParam.setMode(Mode.INOUT); |
aoqi@0 | 885 | outParam.setMode(Mode.INOUT); |
aoqi@0 | 886 | break; |
aoqi@0 | 887 | } |
aoqi@0 | 888 | } |
aoqi@0 | 889 | if (outParam.isOUT()) { |
aoqi@0 | 890 | definitiveParameterList.add(outParam); |
aoqi@0 | 891 | } |
aoqi@0 | 892 | } |
aoqi@0 | 893 | } |
aoqi@0 | 894 | } |
aoqi@0 | 895 | |
aoqi@0 | 896 | // faults with duplicate names |
aoqi@0 | 897 | Set duplicateNames = getDuplicateFaultNames(); |
aoqi@0 | 898 | |
aoqi@0 | 899 | // handle soap:fault |
aoqi@0 | 900 | handleLiteralSOAPFault(response, duplicateNames); |
aoqi@0 | 901 | info.operation.setProperty( |
aoqi@0 | 902 | WSDL_PARAMETER_ORDER, |
aoqi@0 | 903 | definitiveParameterList); |
aoqi@0 | 904 | |
aoqi@0 | 905 | //set Async property |
aoqi@0 | 906 | Binding binding = info.port.resolveBinding(document); |
aoqi@0 | 907 | PortType portType = binding.resolvePortType(document); |
aoqi@0 | 908 | if (isAsync(portType, info.portTypeOperation)) { |
aoqi@0 | 909 | addAsyncOperations(info.operation, styleAndUse); |
aoqi@0 | 910 | } |
aoqi@0 | 911 | |
aoqi@0 | 912 | return info.operation; |
aoqi@0 | 913 | } |
aoqi@0 | 914 | |
aoqi@0 | 915 | |
aoqi@0 | 916 | private boolean validateParameterName(List<Parameter> params) { |
aoqi@0 | 917 | if (options.isExtensionMode()) { |
aoqi@0 | 918 | return true; |
aoqi@0 | 919 | } |
aoqi@0 | 920 | |
aoqi@0 | 921 | Message msg = getInputMessage(); |
aoqi@0 | 922 | for (Parameter param : params) { |
aoqi@0 | 923 | if (param.isOUT()) { |
aoqi@0 | 924 | continue; |
aoqi@0 | 925 | } |
aoqi@0 | 926 | if (param.getCustomName() != null) { |
aoqi@0 | 927 | if (Names.isJavaReservedWord(param.getCustomName())) { |
aoqi@0 | 928 | error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_CUSTOM_NAME(info.operation.getName(), param.getCustomName())); |
aoqi@0 | 929 | return false; |
aoqi@0 | 930 | } |
aoqi@0 | 931 | return true; |
aoqi@0 | 932 | } |
aoqi@0 | 933 | //process doclit wrapper style |
aoqi@0 | 934 | if (param.isEmbedded() && !(param.getBlock().getType() instanceof RpcLitStructure)) { |
aoqi@0 | 935 | if (Names.isJavaReservedWord(param.getName())) { |
aoqi@0 | 936 | error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_WRAPPER_STYLE(info.operation.getName(), param.getName(), param.getBlock().getName())); |
aoqi@0 | 937 | return false; |
aoqi@0 | 938 | } |
aoqi@0 | 939 | } else { |
aoqi@0 | 940 | //non-wrapper style and rpclit |
aoqi@0 | 941 | if (Names.isJavaReservedWord(param.getName())) { |
aoqi@0 | 942 | error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_NON_WRAPPER_STYLE(info.operation.getName(), msg.getName(), param.getName())); |
aoqi@0 | 943 | return false; |
aoqi@0 | 944 | } |
aoqi@0 | 945 | } |
aoqi@0 | 946 | } |
aoqi@0 | 947 | |
aoqi@0 | 948 | boolean isRequestResponse = info.portTypeOperation.getStyle() == OperationStyle.REQUEST_RESPONSE; |
aoqi@0 | 949 | if (isRequestResponse) { |
aoqi@0 | 950 | msg = getOutputMessage(); |
aoqi@0 | 951 | for (Parameter param : params) { |
aoqi@0 | 952 | if (param.isIN()) { |
aoqi@0 | 953 | continue; |
aoqi@0 | 954 | } |
aoqi@0 | 955 | if (param.getCustomName() != null) { |
aoqi@0 | 956 | if (Names.isJavaReservedWord(param.getCustomName())) { |
aoqi@0 | 957 | error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_CUSTOM_NAME(info.operation.getName(), param.getCustomName())); |
aoqi@0 | 958 | return false; |
aoqi@0 | 959 | } |
aoqi@0 | 960 | return true; |
aoqi@0 | 961 | } |
aoqi@0 | 962 | //process doclit wrapper style |
aoqi@0 | 963 | if (param.isEmbedded() && !(param.getBlock().getType() instanceof RpcLitStructure)) { |
aoqi@0 | 964 | if (param.isReturn()) { |
aoqi@0 | 965 | continue; |
aoqi@0 | 966 | } |
aoqi@0 | 967 | if (!param.getName().equals("return") && Names.isJavaReservedWord(param.getName())) { |
aoqi@0 | 968 | error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_WRAPPER_STYLE(info.operation.getName(), param.getName(), param.getBlock().getName())); |
aoqi@0 | 969 | return false; |
aoqi@0 | 970 | } |
aoqi@0 | 971 | } else { |
aoqi@0 | 972 | if (param.isReturn()) { |
aoqi@0 | 973 | continue; |
aoqi@0 | 974 | } |
aoqi@0 | 975 | |
aoqi@0 | 976 | //non-wrapper style and rpclit |
aoqi@0 | 977 | if (Names.isJavaReservedWord(param.getName())) { |
aoqi@0 | 978 | error(param.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_NON_WRAPPER_STYLE(info.operation.getName(), msg.getName(), param.getName())); |
aoqi@0 | 979 | return false; |
aoqi@0 | 980 | } |
aoqi@0 | 981 | } |
aoqi@0 | 982 | } |
aoqi@0 | 983 | } |
aoqi@0 | 984 | |
aoqi@0 | 985 | return true; |
aoqi@0 | 986 | } |
aoqi@0 | 987 | |
aoqi@0 | 988 | private boolean enableMimeContent() { |
aoqi@0 | 989 | //first we look at binding operation |
aoqi@0 | 990 | JAXWSBinding jaxwsCustomization = (JAXWSBinding) getExtensionOfType(info.bindingOperation, JAXWSBinding.class); |
aoqi@0 | 991 | Boolean mimeContentMapping = (jaxwsCustomization != null) ? jaxwsCustomization.isEnableMimeContentMapping() : null; |
aoqi@0 | 992 | if (mimeContentMapping != null) { |
aoqi@0 | 993 | return mimeContentMapping; |
aoqi@0 | 994 | } |
aoqi@0 | 995 | |
aoqi@0 | 996 | //then in wsdl:binding |
aoqi@0 | 997 | Binding binding = info.port.resolveBinding(info.document); |
aoqi@0 | 998 | jaxwsCustomization = (JAXWSBinding) getExtensionOfType(binding, JAXWSBinding.class); |
aoqi@0 | 999 | mimeContentMapping = (jaxwsCustomization != null) ? jaxwsCustomization.isEnableMimeContentMapping() : null; |
aoqi@0 | 1000 | if (mimeContentMapping != null) { |
aoqi@0 | 1001 | return mimeContentMapping; |
aoqi@0 | 1002 | } |
aoqi@0 | 1003 | |
aoqi@0 | 1004 | //at last look in wsdl:definitions |
aoqi@0 | 1005 | jaxwsCustomization = (JAXWSBinding) getExtensionOfType(info.document.getDefinitions(), JAXWSBinding.class); |
aoqi@0 | 1006 | mimeContentMapping = (jaxwsCustomization != null) ? jaxwsCustomization.isEnableMimeContentMapping() : null; |
aoqi@0 | 1007 | if (mimeContentMapping != null) { |
aoqi@0 | 1008 | return mimeContentMapping; |
aoqi@0 | 1009 | } |
aoqi@0 | 1010 | return false; |
aoqi@0 | 1011 | } |
aoqi@0 | 1012 | |
aoqi@0 | 1013 | private boolean applyOperationNameCustomization() { |
aoqi@0 | 1014 | JAXWSBinding jaxwsCustomization = (JAXWSBinding) getExtensionOfType(info.portTypeOperation, JAXWSBinding.class); |
aoqi@0 | 1015 | String operationName = (jaxwsCustomization != null) ? ((jaxwsCustomization.getMethodName() != null) ? jaxwsCustomization.getMethodName().getName() : null) : null; |
aoqi@0 | 1016 | if (operationName != null) { |
aoqi@0 | 1017 | if (Names.isJavaReservedWord(operationName)) { |
aoqi@0 | 1018 | if (options.isExtensionMode()) { |
aoqi@0 | 1019 | warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_CUSTOMIZED_OPERATION_NAME(info.operation.getName(), operationName)); |
aoqi@0 | 1020 | } else { |
aoqi@0 | 1021 | error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_CUSTOMIZED_OPERATION_NAME(info.operation.getName(), operationName)); |
aoqi@0 | 1022 | } |
aoqi@0 | 1023 | return false; |
aoqi@0 | 1024 | } |
aoqi@0 | 1025 | |
aoqi@0 | 1026 | info.operation.setCustomizedName(operationName); |
aoqi@0 | 1027 | } |
aoqi@0 | 1028 | |
aoqi@0 | 1029 | if (Names.isJavaReservedWord(info.operation.getJavaMethodName())) { |
aoqi@0 | 1030 | if (options.isExtensionMode()) { |
aoqi@0 | 1031 | warning(info.portTypeOperation, ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_OPERATION_NAME(info.operation.getName())); |
aoqi@0 | 1032 | } else { |
aoqi@0 | 1033 | error(info.portTypeOperation, ModelerMessages.WSDLMODELER_INVALID_OPERATION_JAVA_RESERVED_WORD_NOT_ALLOWED_OPERATION_NAME(info.operation.getName())); |
aoqi@0 | 1034 | } |
aoqi@0 | 1035 | return false; |
aoqi@0 | 1036 | } |
aoqi@0 | 1037 | return true; |
aoqi@0 | 1038 | } |
aoqi@0 | 1039 | |
aoqi@0 | 1040 | protected String getAsyncOperationName(Operation operation) { |
aoqi@0 | 1041 | String name = operation.getCustomizedName(); |
aoqi@0 | 1042 | if (name == null) { |
aoqi@0 | 1043 | name = operation.getUniqueName(); |
aoqi@0 | 1044 | } |
aoqi@0 | 1045 | return name; |
aoqi@0 | 1046 | } |
aoqi@0 | 1047 | |
aoqi@0 | 1048 | /** |
aoqi@0 | 1049 | * @param styleAndUse |
aoqi@0 | 1050 | */ |
aoqi@0 | 1051 | private void addAsyncOperations(Operation syncOperation, StyleAndUse styleAndUse) { |
aoqi@0 | 1052 | Operation operation = createAsyncOperation(syncOperation, styleAndUse, AsyncOperationType.POLLING); |
aoqi@0 | 1053 | if (operation != null) { |
aoqi@0 | 1054 | info.modelPort.addOperation(operation); |
aoqi@0 | 1055 | } |
aoqi@0 | 1056 | |
aoqi@0 | 1057 | operation = createAsyncOperation(syncOperation, styleAndUse, AsyncOperationType.CALLBACK); |
aoqi@0 | 1058 | if (operation != null) { |
aoqi@0 | 1059 | info.modelPort.addOperation(operation); |
aoqi@0 | 1060 | } |
aoqi@0 | 1061 | } |
aoqi@0 | 1062 | |
aoqi@0 | 1063 | private Operation createAsyncOperation(Operation syncOperation, StyleAndUse styleAndUse, AsyncOperationType asyncType) { |
aoqi@0 | 1064 | boolean isRequestResponse = info.portTypeOperation.getStyle() == OperationStyle.REQUEST_RESPONSE; |
aoqi@0 | 1065 | if (!isRequestResponse) { |
aoqi@0 | 1066 | return null; |
aoqi@0 | 1067 | } |
aoqi@0 | 1068 | |
aoqi@0 | 1069 | //create async operations |
aoqi@0 | 1070 | AsyncOperation operation = new AsyncOperation(info.operation, info.bindingOperation); |
aoqi@0 | 1071 | |
aoqi@0 | 1072 | //creation the async operation name: operationName+Async or customized name |
aoqi@0 | 1073 | //operation.setName(new QName(operation.getName().getNamespaceURI(), getAsyncOperationName(info.portTypeOperation, operation))); |
aoqi@0 | 1074 | if (asyncType.equals(AsyncOperationType.CALLBACK)) { |
aoqi@0 | 1075 | operation.setUniqueName(info.operation.getUniqueName() + "_async_callback"); |
aoqi@0 | 1076 | } else if (asyncType.equals(AsyncOperationType.POLLING)) { |
aoqi@0 | 1077 | operation.setUniqueName(info.operation.getUniqueName() + "_async_polling"); |
aoqi@0 | 1078 | } |
aoqi@0 | 1079 | |
aoqi@0 | 1080 | setDocumentationIfPresent( |
aoqi@0 | 1081 | operation, |
aoqi@0 | 1082 | info.portTypeOperation.getDocumentation()); |
aoqi@0 | 1083 | |
aoqi@0 | 1084 | operation.setAsyncType(asyncType); |
aoqi@0 | 1085 | operation.setSOAPAction(info.operation.getSOAPAction()); |
aoqi@0 | 1086 | boolean unwrappable = info.operation.isWrapped(); |
aoqi@0 | 1087 | operation.setWrapped(unwrappable); |
aoqi@0 | 1088 | SOAPBody soapRequestBody = getSOAPRequestBody(); |
aoqi@0 | 1089 | |
aoqi@0 | 1090 | Message inputMessage = getInputMessage(); |
aoqi@0 | 1091 | Request request = new Request(inputMessage, errReceiver); |
aoqi@0 | 1092 | |
aoqi@0 | 1093 | SOAPBody soapResponseBody = getSOAPResponseBody(); |
aoqi@0 | 1094 | Message outputMessage = getOutputMessage(); |
aoqi@0 | 1095 | Response response = new Response(outputMessage, errReceiver); |
aoqi@0 | 1096 | |
aoqi@0 | 1097 | // Process parameterOrder and get the parameterList |
aoqi@0 | 1098 | java.util.List<String> parameterList = getAsynParameterOrder(); |
aoqi@0 | 1099 | |
aoqi@0 | 1100 | List<Parameter> inParameters = null; |
aoqi@0 | 1101 | if (isOperationDocumentLiteral(styleAndUse)) { |
aoqi@0 | 1102 | inParameters = getRequestParameters(request, parameterList); |
aoqi@0 | 1103 | // outParameters = getResponseParameters(response); |
aoqi@0 | 1104 | // re-create parameterList with unwrapped parameters |
aoqi@0 | 1105 | if (unwrappable) { |
aoqi@0 | 1106 | List<String> unwrappedParameterList = new ArrayList<String>(); |
aoqi@0 | 1107 | if (inputMessage != null) { |
aoqi@0 | 1108 | Iterator<MessagePart> parts = inputMessage.parts(); |
aoqi@0 | 1109 | if (parts.hasNext()) { |
aoqi@0 | 1110 | MessagePart part = parts.next(); |
aoqi@0 | 1111 | JAXBType jaxbType = getJAXBType(part); |
aoqi@0 | 1112 | List<JAXBProperty> memberList = jaxbType.getWrapperChildren(); |
aoqi@0 | 1113 | Iterator<JAXBProperty> props = memberList.iterator(); |
aoqi@0 | 1114 | while (props.hasNext()) { |
aoqi@0 | 1115 | JAXBProperty prop = props.next(); |
aoqi@0 | 1116 | unwrappedParameterList.add(prop.getElementName().getLocalPart()); |
aoqi@0 | 1117 | } |
aoqi@0 | 1118 | } |
aoqi@0 | 1119 | } |
aoqi@0 | 1120 | |
aoqi@0 | 1121 | parameterList.clear(); |
aoqi@0 | 1122 | parameterList.addAll(unwrappedParameterList); |
aoqi@0 | 1123 | } |
aoqi@0 | 1124 | } else if (isOperationRpcLiteral(styleAndUse)) { |
aoqi@0 | 1125 | String operationName = info.bindingOperation.getName(); |
aoqi@0 | 1126 | Block reqBlock = null; |
aoqi@0 | 1127 | if (inputMessage != null) { |
aoqi@0 | 1128 | QName name = new QName(getRequestNamespaceURI(soapRequestBody), operationName); |
aoqi@0 | 1129 | RpcLitStructure rpcStruct = new RpcLitStructure(name, getJAXBModelBuilder().getJAXBModel()); |
aoqi@0 | 1130 | rpcStruct.setJavaType(new JavaSimpleType("com.sun.xml.internal.ws.encoding.jaxb.RpcLitPayload", null)); |
aoqi@0 | 1131 | reqBlock = new Block(name, rpcStruct, inputMessage); |
aoqi@0 | 1132 | request.addBodyBlock(reqBlock); |
aoqi@0 | 1133 | } |
aoqi@0 | 1134 | inParameters = createRpcLitRequestParameters(request, parameterList, reqBlock); |
aoqi@0 | 1135 | } |
aoqi@0 | 1136 | |
aoqi@0 | 1137 | // add response blocks, we dont need to create respnse parameters, just blocks will be fine, lets |
aoqi@0 | 1138 | // copy them from sync optraions |
aoqi@0 | 1139 | //copy the response blocks from the sync operation |
aoqi@0 | 1140 | Iterator<Block> blocks = info.operation.getResponse().getBodyBlocks(); |
aoqi@0 | 1141 | |
aoqi@0 | 1142 | while (blocks.hasNext()) { |
aoqi@0 | 1143 | response.addBodyBlock(blocks.next()); |
aoqi@0 | 1144 | } |
aoqi@0 | 1145 | |
aoqi@0 | 1146 | blocks = info.operation.getResponse().getHeaderBlocks(); |
aoqi@0 | 1147 | while (blocks.hasNext()) { |
aoqi@0 | 1148 | response.addHeaderBlock(blocks.next()); |
aoqi@0 | 1149 | } |
aoqi@0 | 1150 | |
aoqi@0 | 1151 | blocks = info.operation.getResponse().getAttachmentBlocks(); |
aoqi@0 | 1152 | while (blocks.hasNext()) { |
aoqi@0 | 1153 | response.addAttachmentBlock(blocks.next()); |
aoqi@0 | 1154 | } |
aoqi@0 | 1155 | |
aoqi@0 | 1156 | List<MessagePart> outputParts = outputMessage.getParts(); |
aoqi@0 | 1157 | |
aoqi@0 | 1158 | // handle headers |
aoqi@0 | 1159 | int numOfOutMsgParts = outputParts.size(); |
aoqi@0 | 1160 | |
aoqi@0 | 1161 | if (numOfOutMsgParts == 1) { |
aoqi@0 | 1162 | MessagePart part = outputParts.get(0); |
aoqi@0 | 1163 | if (isOperationDocumentLiteral(styleAndUse)) { |
aoqi@0 | 1164 | JAXBType type = getJAXBType(part); |
aoqi@0 | 1165 | operation.setResponseBean(type); |
aoqi@0 | 1166 | } else if (isOperationRpcLiteral(styleAndUse)) { |
aoqi@0 | 1167 | String operationName = info.bindingOperation.getName(); |
aoqi@0 | 1168 | Block resBlock = info.operation.getResponse().getBodyBlocksMap().get(new QName(getResponseNamespaceURI(soapResponseBody), |
aoqi@0 | 1169 | operationName + "Response")); |
aoqi@0 | 1170 | |
aoqi@0 | 1171 | RpcLitStructure resBean = (RpcLitStructure) resBlock.getType(); |
aoqi@0 | 1172 | List<RpcLitMember> members = resBean.getRpcLitMembers(); |
aoqi@0 | 1173 | operation.setResponseBean(members.get(0)); |
aoqi@0 | 1174 | } |
aoqi@0 | 1175 | } else { |
aoqi@0 | 1176 | //create response bean |
aoqi@0 | 1177 | String nspace = ""; |
aoqi@0 | 1178 | QName responseBeanName = new QName(nspace, getAsyncOperationName(info.operation) + "Response"); |
aoqi@0 | 1179 | JAXBType responseBeanType = getJAXBModelBuilder().getJAXBType(responseBeanName); |
aoqi@0 | 1180 | if (responseBeanType == null) { |
aoqi@0 | 1181 | error(info.operation.getEntity(), ModelerMessages.WSDLMODELER_RESPONSEBEAN_NOTFOUND(info.operation.getName())); |
aoqi@0 | 1182 | } |
aoqi@0 | 1183 | operation.setResponseBean(responseBeanType); |
aoqi@0 | 1184 | } |
aoqi@0 | 1185 | |
aoqi@0 | 1186 | QName respBeanName = new QName(soapResponseBody.getNamespace(), getAsyncOperationName(info.operation) + "Response"); |
aoqi@0 | 1187 | Block block = new Block(respBeanName, operation.getResponseBeanType(), outputMessage); |
aoqi@0 | 1188 | JavaType respJavaType = operation.getResponseBeanJavaType(); |
aoqi@0 | 1189 | JAXBType respType = new JAXBType(respBeanName, respJavaType); |
aoqi@0 | 1190 | Parameter respParam = ModelerUtils.createParameter(info.operation.getName() + "Response", respType, block); |
aoqi@0 | 1191 | respParam.setParameterIndex(-1); |
aoqi@0 | 1192 | response.addParameter(respParam); |
aoqi@0 | 1193 | operation.setProperty(WSDL_RESULT_PARAMETER, respParam.getName()); |
aoqi@0 | 1194 | |
aoqi@0 | 1195 | |
aoqi@0 | 1196 | int parameterOrderPosition = 0; |
aoqi@0 | 1197 | for (String name : parameterList) { |
aoqi@0 | 1198 | Parameter inParameter = ModelerUtils.getParameter(name, inParameters); |
aoqi@0 | 1199 | if (inParameter == null) { |
aoqi@0 | 1200 | if (options.isExtensionMode()) { |
aoqi@0 | 1201 | warning(info.operation.getEntity(), ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_PART_NOT_FOUND(info.operation.getName().getLocalPart(), name)); |
aoqi@0 | 1202 | } else { |
aoqi@0 | 1203 | error(info.operation.getEntity(), ModelerMessages.WSDLMODELER_ERROR_PART_NOT_FOUND(info.operation.getName().getLocalPart(), name)); |
aoqi@0 | 1204 | } |
aoqi@0 | 1205 | return null; |
aoqi@0 | 1206 | } |
aoqi@0 | 1207 | request.addParameter(inParameter); |
aoqi@0 | 1208 | inParameter.setParameterIndex(parameterOrderPosition); |
aoqi@0 | 1209 | parameterOrderPosition++; |
aoqi@0 | 1210 | } |
aoqi@0 | 1211 | |
aoqi@0 | 1212 | operation.setResponse(response); |
aoqi@0 | 1213 | |
aoqi@0 | 1214 | // add callback handlerb Parameter to request |
aoqi@0 | 1215 | if (operation.getAsyncType().equals(AsyncOperationType.CALLBACK)) { |
aoqi@0 | 1216 | JavaType cbJavaType = operation.getCallBackType(); |
aoqi@0 | 1217 | JAXBType callbackType = new JAXBType(respBeanName, cbJavaType); |
aoqi@0 | 1218 | Parameter cbParam = ModelerUtils.createParameter("asyncHandler", callbackType, block); |
aoqi@0 | 1219 | request.addParameter(cbParam); |
aoqi@0 | 1220 | } |
aoqi@0 | 1221 | |
aoqi@0 | 1222 | operation.setRequest(request); |
aoqi@0 | 1223 | |
aoqi@0 | 1224 | return operation; |
aoqi@0 | 1225 | } |
aoqi@0 | 1226 | |
aoqi@0 | 1227 | protected boolean isAsync(com.sun.tools.internal.ws.wsdl.document.PortType portType, com.sun.tools.internal.ws.wsdl.document.Operation wsdlOperation) { |
aoqi@0 | 1228 | //First look into wsdl:operation |
aoqi@0 | 1229 | JAXWSBinding jaxwsCustomization = (JAXWSBinding) getExtensionOfType(wsdlOperation, JAXWSBinding.class); |
aoqi@0 | 1230 | Boolean isAsync = (jaxwsCustomization != null) ? jaxwsCustomization.isEnableAsyncMapping() : null; |
aoqi@0 | 1231 | |
aoqi@0 | 1232 | if (isAsync != null) { |
aoqi@0 | 1233 | return isAsync; |
aoqi@0 | 1234 | } |
aoqi@0 | 1235 | |
aoqi@0 | 1236 | // then into wsdl:portType |
aoqi@0 | 1237 | jaxwsCustomization = (JAXWSBinding) getExtensionOfType(portType, JAXWSBinding.class); |
aoqi@0 | 1238 | isAsync = (jaxwsCustomization != null) ? jaxwsCustomization.isEnableAsyncMapping() : null; |
aoqi@0 | 1239 | if (isAsync != null) { |
aoqi@0 | 1240 | return isAsync; |
aoqi@0 | 1241 | } |
aoqi@0 | 1242 | |
aoqi@0 | 1243 | //then wsdl:definitions |
aoqi@0 | 1244 | jaxwsCustomization = (JAXWSBinding) getExtensionOfType(document.getDefinitions(), JAXWSBinding.class); |
aoqi@0 | 1245 | isAsync = (jaxwsCustomization != null) ? jaxwsCustomization.isEnableAsyncMapping() : null; |
aoqi@0 | 1246 | if (isAsync != null) { |
aoqi@0 | 1247 | return isAsync; |
aoqi@0 | 1248 | } |
aoqi@0 | 1249 | return false; |
aoqi@0 | 1250 | } |
aoqi@0 | 1251 | |
aoqi@0 | 1252 | protected void handleLiteralSOAPHeaders(Request request, Response response, Iterator headerParts, Set duplicateNames, @NotNull List<String> definitiveParameterList, boolean processRequest) { |
aoqi@0 | 1253 | QName headerName; |
aoqi@0 | 1254 | Block headerBlock; |
aoqi@0 | 1255 | JAXBType jaxbType; |
aoqi@0 | 1256 | int parameterOrderPosition = definitiveParameterList.size(); |
aoqi@0 | 1257 | while (headerParts.hasNext()) { |
aoqi@0 | 1258 | MessagePart part = (MessagePart) headerParts.next(); |
aoqi@0 | 1259 | headerName = part.getDescriptor(); |
aoqi@0 | 1260 | jaxbType = getJAXBType(part); |
aoqi@0 | 1261 | headerBlock = new Block(headerName, jaxbType, part); |
aoqi@0 | 1262 | TWSDLExtensible ext; |
aoqi@0 | 1263 | if (processRequest) { |
aoqi@0 | 1264 | ext = info.bindingOperation.getInput(); |
aoqi@0 | 1265 | } else { |
aoqi@0 | 1266 | ext = info.bindingOperation.getOutput(); |
aoqi@0 | 1267 | } |
aoqi@0 | 1268 | Message headerMessage = getHeaderMessage(part, ext); |
aoqi@0 | 1269 | |
aoqi@0 | 1270 | if (processRequest) { |
aoqi@0 | 1271 | request.addHeaderBlock(headerBlock); |
aoqi@0 | 1272 | } else { |
aoqi@0 | 1273 | response.addHeaderBlock(headerBlock); |
aoqi@0 | 1274 | } |
aoqi@0 | 1275 | |
aoqi@0 | 1276 | Parameter parameter = ModelerUtils.createParameter(part.getName(), jaxbType, headerBlock); |
aoqi@0 | 1277 | parameter.setParameterIndex(parameterOrderPosition); |
aoqi@0 | 1278 | setCustomizedParameterName(info.bindingOperation, headerMessage, part, parameter, false); |
aoqi@0 | 1279 | if (processRequest) { |
aoqi@0 | 1280 | request.addParameter(parameter); |
aoqi@0 | 1281 | definitiveParameterList.add(parameter.getName()); |
aoqi@0 | 1282 | } else { |
aoqi@0 | 1283 | for (String inParamName : definitiveParameterList) { |
aoqi@0 | 1284 | if (inParamName.equals(parameter.getName())) { |
aoqi@0 | 1285 | Parameter inParam = request.getParameterByName(inParamName); |
aoqi@0 | 1286 | parameter.setLinkedParameter(inParam); |
aoqi@0 | 1287 | inParam.setLinkedParameter(parameter); |
aoqi@0 | 1288 | //its in/out parameter, input and output parameter have the same order position. |
aoqi@0 | 1289 | parameter.setParameterIndex(inParam.getParameterIndex()); |
aoqi@0 | 1290 | } |
aoqi@0 | 1291 | } |
aoqi@0 | 1292 | if (!definitiveParameterList.contains(parameter.getName())) { |
aoqi@0 | 1293 | definitiveParameterList.add(parameter.getName()); |
aoqi@0 | 1294 | } |
aoqi@0 | 1295 | response.addParameter(parameter); |
aoqi@0 | 1296 | } |
aoqi@0 | 1297 | parameterOrderPosition++; |
aoqi@0 | 1298 | } |
aoqi@0 | 1299 | |
aoqi@0 | 1300 | } |
aoqi@0 | 1301 | |
aoqi@0 | 1302 | protected void handleLiteralSOAPFault(Response response, Set duplicateNames) { |
aoqi@0 | 1303 | for (BindingFault bindingFault : info.bindingOperation.faults()) { |
aoqi@0 | 1304 | com.sun.tools.internal.ws.wsdl.document.Fault portTypeFault = null; |
aoqi@0 | 1305 | for (com.sun.tools.internal.ws.wsdl.document.Fault aFault : info.portTypeOperation.faults()) { |
aoqi@0 | 1306 | if (aFault.getName().equals(bindingFault.getName())) { |
aoqi@0 | 1307 | if (portTypeFault != null) { |
aoqi@0 | 1308 | // the WSDL document is invalid, a wsld:fault in a wsdl:operation of a portType can be bound only once |
aoqi@0 | 1309 | error(portTypeFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_NOT_UNIQUE(bindingFault.getName(), info.bindingOperation.getName())); |
aoqi@0 | 1310 | } |
aoqi@0 | 1311 | portTypeFault = aFault; |
aoqi@0 | 1312 | } |
aoqi@0 | 1313 | } |
aoqi@0 | 1314 | |
aoqi@0 | 1315 | // The WSDL document is invalid, the wsdl:fault in abstract operation is does not have any binding |
aoqi@0 | 1316 | if (portTypeFault == null) { |
aoqi@0 | 1317 | error(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_NOT_FOUND(bindingFault.getName(), info.bindingOperation.getName())); |
aoqi@0 | 1318 | |
aoqi@0 | 1319 | } |
aoqi@0 | 1320 | } |
aoqi@0 | 1321 | for ( com.sun.tools.internal.ws.wsdl.document.Fault portTypeFault : info.portTypeOperation.faults()) { |
aoqi@0 | 1322 | |
aoqi@0 | 1323 | BindingFault bindingFault = null ; |
aoqi@0 | 1324 | for(BindingFault bFault: info.bindingOperation.faults()) { |
aoqi@0 | 1325 | if (bFault.getName().equals(portTypeFault.getName())) { |
aoqi@0 | 1326 | bindingFault = bFault; |
aoqi@0 | 1327 | } |
aoqi@0 | 1328 | } |
aoqi@0 | 1329 | |
aoqi@0 | 1330 | if(bindingFault == null) { |
aoqi@0 | 1331 | warning(portTypeFault,ModelerMessages.WSDLMODELER_INVALID_PORT_TYPE_FAULT_NOT_FOUND(portTypeFault.getName(),info.portTypeOperation.getName())); |
aoqi@0 | 1332 | } |
aoqi@0 | 1333 | // wsdl:fault message name is used to create the java exception name later on |
aoqi@0 | 1334 | String faultName = getFaultClassName(portTypeFault); |
aoqi@0 | 1335 | Fault fault = new Fault(faultName, portTypeFault); |
aoqi@0 | 1336 | fault.setWsdlFaultName(portTypeFault.getName()); |
aoqi@0 | 1337 | setDocumentationIfPresent(fault, portTypeFault.getDocumentation()); |
aoqi@0 | 1338 | if (bindingFault != null) { |
aoqi@0 | 1339 | //get the soapbind:fault from wsdl:fault in the binding |
aoqi@0 | 1340 | SOAPFault soapFault = (SOAPFault) getExtensionOfType(bindingFault, SOAPFault.class); |
aoqi@0 | 1341 | |
aoqi@0 | 1342 | // The WSDL document is invalid, can't have wsdl:fault without soapbind:fault |
aoqi@0 | 1343 | if (soapFault == null) { |
aoqi@0 | 1344 | if (options.isExtensionMode()) { |
aoqi@0 | 1345 | warning(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_OUTPUT_MISSING_SOAP_FAULT(bindingFault.getName(), info.bindingOperation.getName())); |
aoqi@0 | 1346 | soapFault = new SOAPFault(new LocatorImpl()); |
aoqi@0 | 1347 | } else { |
aoqi@0 | 1348 | error(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_OUTPUT_MISSING_SOAP_FAULT(bindingFault.getName(), info.bindingOperation.getName())); |
aoqi@0 | 1349 | } |
aoqi@0 | 1350 | } |
aoqi@0 | 1351 | |
aoqi@0 | 1352 | //the soapbind:fault must have use="literal" or no use attribute, in that case its assumed "literal" |
aoqi@0 | 1353 | if (!soapFault.isLiteral()) { |
aoqi@0 | 1354 | if (options.isExtensionMode()) { |
aoqi@0 | 1355 | warning(soapFault, ModelerMessages.WSDLMODELER_WARNING_IGNORING_FAULT_NOT_LITERAL(bindingFault.getName(), info.bindingOperation.getName())); |
aoqi@0 | 1356 | } else { |
aoqi@0 | 1357 | error(soapFault, ModelerMessages.WSDLMODELER_INVALID_OPERATION_FAULT_NOT_LITERAL(bindingFault.getName(), info.bindingOperation.getName())); |
aoqi@0 | 1358 | } |
aoqi@0 | 1359 | continue; |
aoqi@0 | 1360 | } |
aoqi@0 | 1361 | |
aoqi@0 | 1362 | // the soapFault name must be present |
aoqi@0 | 1363 | if (soapFault.getName() == null) { |
aoqi@0 | 1364 | warning(bindingFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_NO_SOAP_FAULT_NAME(bindingFault.getName(), info.bindingOperation.getName())); |
aoqi@0 | 1365 | } else if (!soapFault.getName().equals(bindingFault.getName())) { |
aoqi@0 | 1366 | warning(soapFault, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_WRONG_SOAP_FAULT_NAME(soapFault.getName(), bindingFault.getName(), info.bindingOperation.getName())); |
aoqi@0 | 1367 | } else if (soapFault.getNamespace() != null) { |
aoqi@0 | 1368 | warning(soapFault, ModelerMessages.WSDLMODELER_WARNING_R_2716_R_2726("soapbind:fault", soapFault.getName())); |
aoqi@0 | 1369 | } |
aoqi@0 | 1370 | |
aoqi@0 | 1371 | } |
aoqi@0 | 1372 | |
aoqi@0 | 1373 | com.sun.tools.internal.ws.wsdl.document.Message faultMessage = portTypeFault.resolveMessage(info.document); |
aoqi@0 | 1374 | Iterator iter2 = faultMessage.parts(); |
aoqi@0 | 1375 | if (!iter2.hasNext()) { |
aoqi@0 | 1376 | // the WSDL document is invalid |
aoqi@0 | 1377 | error(faultMessage, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_EMPTY_MESSAGE(portTypeFault.getName(), faultMessage.getName())); |
aoqi@0 | 1378 | } |
aoqi@0 | 1379 | MessagePart faultPart = (MessagePart) iter2.next(); |
aoqi@0 | 1380 | QName faultQName = faultPart.getDescriptor(); |
aoqi@0 | 1381 | |
aoqi@0 | 1382 | // Don't include fault messages with non-unique soap:fault names |
aoqi@0 | 1383 | if (duplicateNames.contains(faultQName)) { |
aoqi@0 | 1384 | warning(faultPart, ModelerMessages.WSDLMODELER_DUPLICATE_FAULT_SOAP_NAME(portTypeFault.getName(), info.portTypeOperation.getName(), faultPart.getName())); |
aoqi@0 | 1385 | continue; |
aoqi@0 | 1386 | } |
aoqi@0 | 1387 | |
aoqi@0 | 1388 | if (iter2.hasNext()) { |
aoqi@0 | 1389 | // the WSDL document is invalid |
aoqi@0 | 1390 | error(faultMessage, ModelerMessages.WSDLMODELER_INVALID_BINDING_FAULT_MESSAGE_HAS_MORE_THAN_ONE_PART(portTypeFault.getName(), faultMessage.getName())); |
aoqi@0 | 1391 | } |
aoqi@0 | 1392 | |
aoqi@0 | 1393 | if (faultPart.getDescriptorKind() != SchemaKinds.XSD_ELEMENT) { |
aoqi@0 | 1394 | if (options.isExtensionMode()) { |
aoqi@0 | 1395 | warning(faultPart, ModelerMessages.WSDLMODELER_INVALID_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(faultMessage.getName(), faultPart.getName())); |
aoqi@0 | 1396 | } else { |
aoqi@0 | 1397 | error(faultPart, ModelerMessages.WSDLMODELER_INVALID_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(faultMessage.getName(), faultPart.getName())); |
aoqi@0 | 1398 | } |
aoqi@0 | 1399 | } |
aoqi@0 | 1400 | |
aoqi@0 | 1401 | JAXBType jaxbType = getJAXBType(faultPart); |
aoqi@0 | 1402 | |
aoqi@0 | 1403 | fault.setElementName(faultPart.getDescriptor()); |
aoqi@0 | 1404 | fault.setJavaMemberName(Names.getExceptionClassMemberName()); |
aoqi@0 | 1405 | |
aoqi@0 | 1406 | Block faultBlock = new Block(faultQName, jaxbType, faultPart); |
aoqi@0 | 1407 | fault.setBlock(faultBlock); |
aoqi@0 | 1408 | //createParentFault(fault); |
aoqi@0 | 1409 | //createSubfaults(fault); |
aoqi@0 | 1410 | if (!response.getFaultBlocksMap().containsKey(faultBlock.getName())) { |
aoqi@0 | 1411 | response.addFaultBlock(faultBlock); |
aoqi@0 | 1412 | } |
aoqi@0 | 1413 | info.operation.addFault(fault); |
aoqi@0 | 1414 | } |
aoqi@0 | 1415 | } |
aoqi@0 | 1416 | |
aoqi@0 | 1417 | private String getFaultClassName(com.sun.tools.internal.ws.wsdl.document.Fault portTypeFault) { |
aoqi@0 | 1418 | JAXWSBinding jaxwsBinding = (JAXWSBinding) getExtensionOfType(portTypeFault, JAXWSBinding.class); |
aoqi@0 | 1419 | if (jaxwsBinding != null) { |
aoqi@0 | 1420 | CustomName className = jaxwsBinding.getClassName(); |
aoqi@0 | 1421 | if (className != null) { |
aoqi@0 | 1422 | return makePackageQualified(className.getName()); |
aoqi@0 | 1423 | } |
aoqi@0 | 1424 | } |
aoqi@0 | 1425 | return makePackageQualified(BindingHelper.mangleNameToClassName(portTypeFault.getMessage().getLocalPart())); |
aoqi@0 | 1426 | } |
aoqi@0 | 1427 | |
aoqi@0 | 1428 | protected boolean setMessagePartsBinding(StyleAndUse styleAndUse) { |
aoqi@0 | 1429 | SOAPBody inBody = getSOAPRequestBody(); |
aoqi@0 | 1430 | Message inMessage = getInputMessage(); |
aoqi@0 | 1431 | if (!setMessagePartsBinding(inBody, inMessage, styleAndUse, true)) { |
aoqi@0 | 1432 | return false; |
aoqi@0 | 1433 | } |
aoqi@0 | 1434 | |
aoqi@0 | 1435 | if (isRequestResponse()) { |
aoqi@0 | 1436 | SOAPBody outBody = getSOAPResponseBody(); |
aoqi@0 | 1437 | Message outMessage = getOutputMessage(); |
aoqi@0 | 1438 | if (!setMessagePartsBinding(outBody, outMessage, styleAndUse, false)) { |
aoqi@0 | 1439 | return false; |
aoqi@0 | 1440 | } |
aoqi@0 | 1441 | } |
aoqi@0 | 1442 | return true; |
aoqi@0 | 1443 | } |
aoqi@0 | 1444 | |
aoqi@0 | 1445 | //returns false if the wsdl is invalid and operation should be ignored |
aoqi@0 | 1446 | protected boolean setMessagePartsBinding(SOAPBody body, Message message, StyleAndUse styleAndUse, boolean isInput) { |
aoqi@0 | 1447 | |
aoqi@0 | 1448 | //get Mime parts |
aoqi@0 | 1449 | List<MessagePart> mimeParts; |
aoqi@0 | 1450 | List<MessagePart> headerParts; |
aoqi@0 | 1451 | List<MessagePart> bodyParts = getBodyParts(body, message); |
aoqi@0 | 1452 | |
aoqi@0 | 1453 | if (isInput) { |
aoqi@0 | 1454 | headerParts = getHeaderPartsFromMessage(message, isInput); |
aoqi@0 | 1455 | mimeParts = getMimeContentParts(message, info.bindingOperation.getInput()); |
aoqi@0 | 1456 | } else { |
aoqi@0 | 1457 | headerParts = getHeaderPartsFromMessage(message, isInput); |
aoqi@0 | 1458 | mimeParts = getMimeContentParts(message, info.bindingOperation.getOutput()); |
aoqi@0 | 1459 | } |
aoqi@0 | 1460 | |
aoqi@0 | 1461 | //As of now WSDL MIME binding is not supported, so throw the exception when such binding is encounterd |
aoqi@0 | 1462 | // if(mimeParts.size() > 0){ |
aoqi@0 | 1463 | // fail("wsdlmodeler.unsupportedBinding.mime", new Object[]{}); |
aoqi@0 | 1464 | // } |
aoqi@0 | 1465 | |
aoqi@0 | 1466 | //if soap:body parts attribute not there, then all unbounded message parts will |
aoqi@0 | 1467 | // belong to the soap body |
aoqi@0 | 1468 | if (bodyParts == null) { |
aoqi@0 | 1469 | bodyParts = new ArrayList<MessagePart>(); |
aoqi@0 | 1470 | for (Iterator<MessagePart> iter = message.parts(); iter.hasNext();) { |
aoqi@0 | 1471 | MessagePart mPart = iter.next(); |
aoqi@0 | 1472 | //Its a safe assumption that the parts in the message not belonging to header or mime will |
aoqi@0 | 1473 | // belong to the body? |
aoqi@0 | 1474 | if (mimeParts.contains(mPart) || headerParts.contains(mPart) || boundToFault(mPart.getName())) { |
aoqi@0 | 1475 | //throw error that a part cant be bound multiple times, not ignoring operation, if there |
aoqi@0 | 1476 | //is conflict it will fail latter |
aoqi@0 | 1477 | if (options.isExtensionMode()) { |
aoqi@0 | 1478 | warning(mPart, ModelerMessages.WSDLMODELER_WARNING_BINDING_OPERATION_MULTIPLE_PART_BINDING(info.bindingOperation.getName(), mPart.getName())); |
aoqi@0 | 1479 | } else { |
aoqi@0 | 1480 | error(mPart, ModelerMessages.WSDLMODELER_INVALID_BINDING_OPERATION_MULTIPLE_PART_BINDING(info.bindingOperation.getName(), mPart.getName())); |
aoqi@0 | 1481 | } |
aoqi@0 | 1482 | } |
aoqi@0 | 1483 | bodyParts.add(mPart); |
aoqi@0 | 1484 | } |
aoqi@0 | 1485 | } |
aoqi@0 | 1486 | |
aoqi@0 | 1487 | //now build the final parts list with header, mime parts and body parts |
aoqi@0 | 1488 | for (Iterator iter = message.parts(); iter.hasNext();) { |
aoqi@0 | 1489 | MessagePart mPart = (MessagePart) iter.next(); |
aoqi@0 | 1490 | if (mimeParts.contains(mPart)) { |
aoqi@0 | 1491 | mPart.setBindingExtensibilityElementKind(MessagePart.WSDL_MIME_BINDING); |
aoqi@0 | 1492 | } else if (headerParts.contains(mPart)) { |
aoqi@0 | 1493 | mPart.setBindingExtensibilityElementKind(MessagePart.SOAP_HEADER_BINDING); |
aoqi@0 | 1494 | } else if (bodyParts.contains(mPart)) { |
aoqi@0 | 1495 | mPart.setBindingExtensibilityElementKind(MessagePart.SOAP_BODY_BINDING); |
aoqi@0 | 1496 | } else { |
aoqi@0 | 1497 | mPart.setBindingExtensibilityElementKind(MessagePart.PART_NOT_BOUNDED); |
aoqi@0 | 1498 | } |
aoqi@0 | 1499 | } |
aoqi@0 | 1500 | |
aoqi@0 | 1501 | if (isOperationDocumentLiteral(styleAndUse) && bodyParts.size() > 1) { |
aoqi@0 | 1502 | if (options.isExtensionMode()) { |
aoqi@0 | 1503 | warning(message, ModelerMessages.WSDLMODELER_WARNING_OPERATION_MORE_THAN_ONE_PART_IN_MESSAGE(info.portTypeOperation.getName())); |
aoqi@0 | 1504 | } else { |
aoqi@0 | 1505 | error(message, ModelerMessages.WSDLMODELER_INVALID_OPERATION_MORE_THAN_ONE_PART_IN_MESSAGE(info.portTypeOperation.getName())); |
aoqi@0 | 1506 | } |
aoqi@0 | 1507 | return false; |
aoqi@0 | 1508 | } |
aoqi@0 | 1509 | return true; |
aoqi@0 | 1510 | } |
aoqi@0 | 1511 | |
aoqi@0 | 1512 | private boolean boundToFault(String partName) { |
aoqi@0 | 1513 | for (BindingFault bindingFault : info.bindingOperation.faults()) { |
aoqi@0 | 1514 | if (partName.equals(bindingFault.getName())) { |
aoqi@0 | 1515 | return true; |
aoqi@0 | 1516 | } |
aoqi@0 | 1517 | } |
aoqi@0 | 1518 | return false; |
aoqi@0 | 1519 | } |
aoqi@0 | 1520 | |
aoqi@0 | 1521 | //get MessagePart(s) referenced by parts attribute of soap:body element |
aoqi@0 | 1522 | private List<MessagePart> getBodyParts(SOAPBody body, Message message) { |
aoqi@0 | 1523 | String bodyParts = body.getParts(); |
aoqi@0 | 1524 | if (bodyParts != null) { |
aoqi@0 | 1525 | List<MessagePart> partsList = new ArrayList<MessagePart>(); |
aoqi@0 | 1526 | StringTokenizer in = new StringTokenizer(bodyParts.trim(), " "); |
aoqi@0 | 1527 | while (in.hasMoreTokens()) { |
aoqi@0 | 1528 | String part = in.nextToken(); |
aoqi@0 | 1529 | MessagePart mPart = message.getPart(part); |
aoqi@0 | 1530 | if (null == mPart) { |
aoqi@0 | 1531 | error(message, ModelerMessages.WSDLMODELER_ERROR_PARTS_NOT_FOUND(part, message.getName())); |
aoqi@0 | 1532 | } |
aoqi@0 | 1533 | mPart.setBindingExtensibilityElementKind(MessagePart.SOAP_BODY_BINDING); |
aoqi@0 | 1534 | partsList.add(mPart); |
aoqi@0 | 1535 | } |
aoqi@0 | 1536 | return partsList; |
aoqi@0 | 1537 | } |
aoqi@0 | 1538 | return null; |
aoqi@0 | 1539 | } |
aoqi@0 | 1540 | |
aoqi@0 | 1541 | List<MessagePart> getAdditionHeaderParts(BindingOperation bindingOperation,Message message, boolean isInput){ |
aoqi@0 | 1542 | List<MessagePart> headerParts = new ArrayList<MessagePart>(); |
aoqi@0 | 1543 | List<MessagePart> parts = message.getParts(); |
aoqi@0 | 1544 | List<MessagePart> headers = getHeaderParts(bindingOperation, isInput); |
aoqi@0 | 1545 | |
aoqi@0 | 1546 | for(MessagePart part: headers){ |
aoqi@0 | 1547 | if (parts.contains(part)) { |
aoqi@0 | 1548 | continue; |
aoqi@0 | 1549 | } |
aoqi@0 | 1550 | headerParts.add(part); |
aoqi@0 | 1551 | } |
aoqi@0 | 1552 | return headerParts; |
aoqi@0 | 1553 | } |
aoqi@0 | 1554 | |
aoqi@0 | 1555 | private List<MessagePart> getHeaderPartsFromMessage(Message message, boolean isInput) { |
aoqi@0 | 1556 | List<MessagePart> headerParts = new ArrayList<MessagePart>(); |
aoqi@0 | 1557 | Iterator<MessagePart> parts = message.parts(); |
aoqi@0 | 1558 | List<MessagePart> headers = getHeaderParts(info.bindingOperation, isInput); |
aoqi@0 | 1559 | while (parts.hasNext()) { |
aoqi@0 | 1560 | MessagePart part = parts.next(); |
aoqi@0 | 1561 | if (headers.contains(part)) { |
aoqi@0 | 1562 | headerParts.add(part); |
aoqi@0 | 1563 | } |
aoqi@0 | 1564 | } |
aoqi@0 | 1565 | return headerParts; |
aoqi@0 | 1566 | } |
aoqi@0 | 1567 | |
aoqi@0 | 1568 | private Message getHeaderMessage(MessagePart part, TWSDLExtensible ext) { |
aoqi@0 | 1569 | Iterator<SOAPHeader> headers = getHeaderExtensions(ext).iterator(); |
aoqi@0 | 1570 | while (headers.hasNext()) { |
aoqi@0 | 1571 | SOAPHeader header = headers.next(); |
aoqi@0 | 1572 | if (!header.isLiteral()) { |
aoqi@0 | 1573 | continue; |
aoqi@0 | 1574 | } |
aoqi@0 | 1575 | com.sun.tools.internal.ws.wsdl.document.Message headerMessage = findMessage(header.getMessage(), document); |
aoqi@0 | 1576 | if (headerMessage == null) { |
aoqi@0 | 1577 | continue; |
aoqi@0 | 1578 | } |
aoqi@0 | 1579 | |
aoqi@0 | 1580 | MessagePart headerPart = headerMessage.getPart(header.getPart()); |
aoqi@0 | 1581 | if (headerPart == part) { |
aoqi@0 | 1582 | return headerMessage; |
aoqi@0 | 1583 | } |
aoqi@0 | 1584 | } |
aoqi@0 | 1585 | return null; |
aoqi@0 | 1586 | } |
aoqi@0 | 1587 | |
aoqi@0 | 1588 | private List<MessagePart> getHeaderParts(BindingOperation bindingOperation, boolean isInput) { |
aoqi@0 | 1589 | TWSDLExtensible ext; |
aoqi@0 | 1590 | if (isInput) { |
aoqi@0 | 1591 | ext = bindingOperation.getInput(); |
aoqi@0 | 1592 | } else { |
aoqi@0 | 1593 | ext = bindingOperation.getOutput(); |
aoqi@0 | 1594 | } |
aoqi@0 | 1595 | |
aoqi@0 | 1596 | List<MessagePart> parts = new ArrayList<MessagePart>(); |
aoqi@0 | 1597 | Iterator<SOAPHeader> headers = getHeaderExtensions(ext).iterator(); |
aoqi@0 | 1598 | while (headers.hasNext()) { |
aoqi@0 | 1599 | SOAPHeader header = headers.next(); |
aoqi@0 | 1600 | if (!header.isLiteral()) { |
aoqi@0 | 1601 | error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_NOT_LITERAL(header.getPart(), bindingOperation.getName())); |
aoqi@0 | 1602 | } |
aoqi@0 | 1603 | |
aoqi@0 | 1604 | if (header.getNamespace() != null) { |
aoqi@0 | 1605 | warning(header, ModelerMessages.WSDLMODELER_WARNING_R_2716_R_2726("soapbind:header", bindingOperation.getName())); |
aoqi@0 | 1606 | } |
aoqi@0 | 1607 | com.sun.tools.internal.ws.wsdl.document.Message headerMessage = findMessage(header.getMessage(),document); |
aoqi@0 | 1608 | if (headerMessage == null) { |
aoqi@0 | 1609 | error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_CANT_RESOLVE_MESSAGE(header.getMessage(), bindingOperation.getName())); |
aoqi@0 | 1610 | } |
aoqi@0 | 1611 | |
aoqi@0 | 1612 | MessagePart part = headerMessage.getPart(header.getPart()); |
aoqi@0 | 1613 | if (part == null) { |
aoqi@0 | 1614 | error(header, ModelerMessages.WSDLMODELER_INVALID_HEADER_NOT_FOUND(header.getPart(), bindingOperation.getName())); |
aoqi@0 | 1615 | } |
aoqi@0 | 1616 | if (part.getDescriptorKind() != SchemaKinds.XSD_ELEMENT) { |
aoqi@0 | 1617 | if (options.isExtensionMode()) { |
aoqi@0 | 1618 | warning(part, ModelerMessages.WSDLMODELER_INVALID_HEADER_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(part.getName(), bindingOperation.getName())); |
aoqi@0 | 1619 | } else { |
aoqi@0 | 1620 | error(part, ModelerMessages.WSDLMODELER_INVALID_HEADER_MESSAGE_PART_MUST_HAVE_ELEMENT_DESCRIPTOR(part.getName(), bindingOperation.getName())); |
aoqi@0 | 1621 | } |
aoqi@0 | 1622 | } |
aoqi@0 | 1623 | part.setBindingExtensibilityElementKind(MessagePart.SOAP_HEADER_BINDING); |
aoqi@0 | 1624 | parts.add(part); |
aoqi@0 | 1625 | } |
aoqi@0 | 1626 | return parts; |
aoqi@0 | 1627 | } |
aoqi@0 | 1628 | |
aoqi@0 | 1629 | private boolean isOperationDocumentLiteral(StyleAndUse styleAndUse) { |
aoqi@0 | 1630 | return StyleAndUse.DOC_LITERAL == styleAndUse; |
aoqi@0 | 1631 | } |
aoqi@0 | 1632 | |
aoqi@0 | 1633 | private boolean isOperationRpcLiteral(StyleAndUse styleAndUse) { |
aoqi@0 | 1634 | return StyleAndUse.RPC_LITERAL == styleAndUse; |
aoqi@0 | 1635 | } |
aoqi@0 | 1636 | |
aoqi@0 | 1637 | /** |
aoqi@0 | 1638 | * @param part |
aoqi@0 | 1639 | * @return Returns a JAXBType object |
aoqi@0 | 1640 | */ |
aoqi@0 | 1641 | private JAXBType getJAXBType(MessagePart part) { |
aoqi@0 | 1642 | JAXBType type; |
aoqi@0 | 1643 | QName name = part.getDescriptor(); |
aoqi@0 | 1644 | if (part.getDescriptorKind().equals(SchemaKinds.XSD_ELEMENT)) { |
aoqi@0 | 1645 | type = getJAXBModelBuilder().getJAXBType(name); |
aoqi@0 | 1646 | if(type == null){ |
aoqi@0 | 1647 | error(part, ModelerMessages.WSDLMODELER_JAXB_JAVATYPE_NOTFOUND(name, part.getName())); |
aoqi@0 | 1648 | } |
aoqi@0 | 1649 | } else { |
aoqi@0 | 1650 | S2JJAXBModel jaxbModel = getJAXBModelBuilder().getJAXBModel().getS2JJAXBModel(); |
aoqi@0 | 1651 | TypeAndAnnotation typeAnno = jaxbModel.getJavaType(name); |
aoqi@0 | 1652 | if (typeAnno == null) { |
aoqi@0 | 1653 | error(part, ModelerMessages.WSDLMODELER_JAXB_JAVATYPE_NOTFOUND(name, part.getName())); |
aoqi@0 | 1654 | } |
aoqi@0 | 1655 | JavaType javaType = new JavaSimpleType(new JAXBTypeAndAnnotation(typeAnno)); |
aoqi@0 | 1656 | type = new JAXBType(new QName("", part.getName()), javaType); |
aoqi@0 | 1657 | } |
aoqi@0 | 1658 | return type; |
aoqi@0 | 1659 | } |
aoqi@0 | 1660 | |
aoqi@0 | 1661 | private List<Parameter> getDoclitParameters(Request req, Response res, List<MessagePart> parameterList) { |
aoqi@0 | 1662 | if (parameterList.isEmpty()) { |
aoqi@0 | 1663 | return new ArrayList<Parameter>(); |
aoqi@0 | 1664 | } |
aoqi@0 | 1665 | List<Parameter> params = new ArrayList<Parameter>(); |
aoqi@0 | 1666 | Message inMsg = getInputMessage(); |
aoqi@0 | 1667 | Message outMsg = getOutputMessage(); |
aoqi@0 | 1668 | boolean unwrappable = isUnwrappable(); |
aoqi@0 | 1669 | List<Parameter> outParams = null; |
aoqi@0 | 1670 | int pIndex = 0; |
aoqi@0 | 1671 | for (MessagePart part : parameterList) { |
aoqi@0 | 1672 | QName reqBodyName = part.getDescriptor(); |
aoqi@0 | 1673 | JAXBType jaxbType = getJAXBType(part); |
aoqi@0 | 1674 | Block block = new Block(reqBodyName, jaxbType, part); |
aoqi@0 | 1675 | if (unwrappable) { |
aoqi@0 | 1676 | //So build body and header blocks and set to request and response |
aoqi@0 | 1677 | JAXBStructuredType jaxbStructType = ModelerUtils.createJAXBStructureType(jaxbType); |
aoqi@0 | 1678 | block = new Block(reqBodyName, jaxbStructType, part); |
aoqi@0 | 1679 | if (ModelerUtils.isBoundToSOAPBody(part)) { |
aoqi@0 | 1680 | if (part.isIN()) { |
aoqi@0 | 1681 | req.addBodyBlock(block); |
aoqi@0 | 1682 | } else if (part.isOUT()) { |
aoqi@0 | 1683 | res.addBodyBlock(block); |
aoqi@0 | 1684 | } else if (part.isINOUT()) { |
aoqi@0 | 1685 | req.addBodyBlock(block); |
aoqi@0 | 1686 | res.addBodyBlock(block); |
aoqi@0 | 1687 | } |
aoqi@0 | 1688 | } else if (ModelerUtils.isUnbound(part)) { |
aoqi@0 | 1689 | if (part.isIN()) { |
aoqi@0 | 1690 | req.addUnboundBlock(block); |
aoqi@0 | 1691 | } else if (part.isOUT()) { |
aoqi@0 | 1692 | res.addUnboundBlock(block); |
aoqi@0 | 1693 | } else if (part.isINOUT()) { |
aoqi@0 | 1694 | req.addUnboundBlock(block); |
aoqi@0 | 1695 | res.addUnboundBlock(block); |
aoqi@0 | 1696 | } |
aoqi@0 | 1697 | } |
aoqi@0 | 1698 | if (part.isIN() || part.isINOUT()) { |
aoqi@0 | 1699 | params = ModelerUtils.createUnwrappedParameters(jaxbStructType, block); |
aoqi@0 | 1700 | int index = 0; |
aoqi@0 | 1701 | Mode mode = part.isINOUT() ? Mode.INOUT : Mode.IN; |
aoqi@0 | 1702 | for (Parameter param : params) { |
aoqi@0 | 1703 | param.setParameterIndex(index++); |
aoqi@0 | 1704 | param.setMode(mode); |
aoqi@0 | 1705 | setCustomizedParameterName(info.portTypeOperation, inMsg, part, param, unwrappable); |
aoqi@0 | 1706 | } |
aoqi@0 | 1707 | } else if (part.isOUT()) { |
aoqi@0 | 1708 | outParams = ModelerUtils.createUnwrappedParameters(jaxbStructType, block); |
aoqi@0 | 1709 | for (Parameter param : outParams) { |
aoqi@0 | 1710 | param.setMode(Mode.OUT); |
aoqi@0 | 1711 | setCustomizedParameterName(info.portTypeOperation, outMsg, part, param, unwrappable); |
aoqi@0 | 1712 | } |
aoqi@0 | 1713 | } |
aoqi@0 | 1714 | } else { |
aoqi@0 | 1715 | if (ModelerUtils.isBoundToSOAPBody(part)) { |
aoqi@0 | 1716 | if (part.isIN()) { |
aoqi@0 | 1717 | req.addBodyBlock(block); |
aoqi@0 | 1718 | } else if (part.isOUT()) { |
aoqi@0 | 1719 | res.addBodyBlock(block); |
aoqi@0 | 1720 | } else if (part.isINOUT()) { |
aoqi@0 | 1721 | req.addBodyBlock(block); |
aoqi@0 | 1722 | res.addBodyBlock(block); |
aoqi@0 | 1723 | } |
aoqi@0 | 1724 | } else if (ModelerUtils.isBoundToSOAPHeader(part)) { |
aoqi@0 | 1725 | if (part.isIN()) { |
aoqi@0 | 1726 | req.addHeaderBlock(block); |
aoqi@0 | 1727 | } else if (part.isOUT()) { |
aoqi@0 | 1728 | res.addHeaderBlock(block); |
aoqi@0 | 1729 | } else if (part.isINOUT()) { |
aoqi@0 | 1730 | req.addHeaderBlock(block); |
aoqi@0 | 1731 | res.addHeaderBlock(block); |
aoqi@0 | 1732 | } |
aoqi@0 | 1733 | } else if (ModelerUtils.isBoundToMimeContent(part)) { |
aoqi@0 | 1734 | List<MIMEContent> mimeContents; |
aoqi@0 | 1735 | |
aoqi@0 | 1736 | if (part.isIN()) { |
aoqi@0 | 1737 | mimeContents = getMimeContents(info.bindingOperation.getInput(), |
aoqi@0 | 1738 | getInputMessage(), part.getName()); |
aoqi@0 | 1739 | jaxbType = getAttachmentType(mimeContents, part); |
aoqi@0 | 1740 | block = new Block(jaxbType.getName(), jaxbType, part); |
aoqi@0 | 1741 | req.addAttachmentBlock(block); |
aoqi@0 | 1742 | } else if (part.isOUT()) { |
aoqi@0 | 1743 | mimeContents = getMimeContents(info.bindingOperation.getOutput(), |
aoqi@0 | 1744 | getOutputMessage(), part.getName()); |
aoqi@0 | 1745 | jaxbType = getAttachmentType(mimeContents, part); |
aoqi@0 | 1746 | block = new Block(jaxbType.getName(), jaxbType, part); |
aoqi@0 | 1747 | res.addAttachmentBlock(block); |
aoqi@0 | 1748 | } else if (part.isINOUT()) { |
aoqi@0 | 1749 | mimeContents = getMimeContents(info.bindingOperation.getInput(), |
aoqi@0 | 1750 | getInputMessage(), part.getName()); |
aoqi@0 | 1751 | jaxbType = getAttachmentType(mimeContents, part); |
aoqi@0 | 1752 | block = new Block(jaxbType.getName(), jaxbType, part); |
aoqi@0 | 1753 | req.addAttachmentBlock(block); |
aoqi@0 | 1754 | res.addAttachmentBlock(block); |
aoqi@0 | 1755 | |
aoqi@0 | 1756 | mimeContents = getMimeContents(info.bindingOperation.getOutput(), |
aoqi@0 | 1757 | getOutputMessage(), part.getName()); |
aoqi@0 | 1758 | JAXBType outJaxbType = getAttachmentType(mimeContents, part); |
aoqi@0 | 1759 | |
aoqi@0 | 1760 | String inType = jaxbType.getJavaType().getType().getName(); |
aoqi@0 | 1761 | String outType = outJaxbType.getJavaType().getType().getName(); |
aoqi@0 | 1762 | |
aoqi@0 | 1763 | TypeAndAnnotation inTa = jaxbType.getJavaType().getType().getTypeAnn(); |
aoqi@0 | 1764 | TypeAndAnnotation outTa = outJaxbType.getJavaType().getType().getTypeAnn(); |
aoqi@0 | 1765 | if ((((inTa != null) && (outTa != null) && inTa.equals(outTa))) && !inType.equals(outType)) { |
aoqi@0 | 1766 | String javaType = "javax.activation.DataHandler"; |
aoqi@0 | 1767 | |
aoqi@0 | 1768 | //S2JJAXBModel jaxbModel = getJAXBModelBuilder().getJAXBModel().getS2JJAXBModel(); |
aoqi@0 | 1769 | //JCodeModel cm = jaxbModel.generateCode(null, errReceiver); |
aoqi@0 | 1770 | JType jt = options.getCodeModel().ref(javaType); |
aoqi@0 | 1771 | JAXBTypeAndAnnotation jaxbTa = jaxbType.getJavaType().getType(); |
aoqi@0 | 1772 | jaxbTa.setType(jt); |
aoqi@0 | 1773 | } |
aoqi@0 | 1774 | } |
aoqi@0 | 1775 | } else if (ModelerUtils.isUnbound(part)) { |
aoqi@0 | 1776 | if (part.isIN()) { |
aoqi@0 | 1777 | req.addUnboundBlock(block); |
aoqi@0 | 1778 | } else if (part.isOUT()) { |
aoqi@0 | 1779 | res.addUnboundBlock(block); |
aoqi@0 | 1780 | } else if (part.isINOUT()) { |
aoqi@0 | 1781 | req.addUnboundBlock(block); |
aoqi@0 | 1782 | res.addUnboundBlock(block); |
aoqi@0 | 1783 | } |
aoqi@0 | 1784 | } |
aoqi@0 | 1785 | Parameter param = ModelerUtils.createParameter(part.getName(), jaxbType, block); |
aoqi@0 | 1786 | param.setMode(part.getMode()); |
aoqi@0 | 1787 | if (part.isReturn()) { |
aoqi@0 | 1788 | param.setParameterIndex(-1); |
aoqi@0 | 1789 | } else { |
aoqi@0 | 1790 | param.setParameterIndex(pIndex++); |
aoqi@0 | 1791 | } |
aoqi@0 | 1792 | |
aoqi@0 | 1793 | if (part.isIN()) { |
aoqi@0 | 1794 | setCustomizedParameterName(info.bindingOperation, inMsg, part, param, false); |
aoqi@0 | 1795 | } else if (outMsg != null) { |
aoqi@0 | 1796 | setCustomizedParameterName(info.bindingOperation, outMsg, part, param, false); |
aoqi@0 | 1797 | } |
aoqi@0 | 1798 | |
aoqi@0 | 1799 | params.add(param); |
aoqi@0 | 1800 | } |
aoqi@0 | 1801 | } |
aoqi@0 | 1802 | if (unwrappable && (outParams != null)) { |
aoqi@0 | 1803 | int index = params.size(); |
aoqi@0 | 1804 | for (Parameter param : outParams) { |
aoqi@0 | 1805 | if (BindingHelper.mangleNameToVariableName(param.getName()).equals("return")) { |
aoqi@0 | 1806 | param.setParameterIndex(-1); |
aoqi@0 | 1807 | } else { |
aoqi@0 | 1808 | Parameter inParam = ModelerUtils.getParameter(param.getName(), params); |
aoqi@0 | 1809 | if ((inParam != null) && inParam.isIN()) { |
aoqi@0 | 1810 | QName inElementName = inParam.getType().getName(); |
aoqi@0 | 1811 | QName outElementName = param.getType().getName(); |
aoqi@0 | 1812 | String inJavaType = inParam.getTypeName(); |
aoqi@0 | 1813 | String outJavaType = param.getTypeName(); |
aoqi@0 | 1814 | TypeAndAnnotation inTa = inParam.getType().getJavaType().getType().getTypeAnn(); |
aoqi@0 | 1815 | TypeAndAnnotation outTa = param.getType().getJavaType().getType().getTypeAnn(); |
aoqi@0 | 1816 | QName inRawTypeName = ModelerUtils.getRawTypeName(inParam); |
aoqi@0 | 1817 | QName outRawTypeName = ModelerUtils.getRawTypeName(param); |
aoqi@0 | 1818 | if (inElementName.getLocalPart().equals(outElementName.getLocalPart()) && |
aoqi@0 | 1819 | inJavaType.equals(outJavaType) && |
aoqi@0 | 1820 | (inTa == null || outTa == null || inTa.equals(outTa)) && |
aoqi@0 | 1821 | (inRawTypeName == null || outRawTypeName == null || inRawTypeName.equals(outRawTypeName))) { |
aoqi@0 | 1822 | inParam.setMode(Mode.INOUT); |
aoqi@0 | 1823 | continue; |
aoqi@0 | 1824 | } |
aoqi@0 | 1825 | } |
aoqi@0 | 1826 | if (outParams.size() == 1) { |
aoqi@0 | 1827 | param.setParameterIndex(-1); |
aoqi@0 | 1828 | } else { |
aoqi@0 | 1829 | param.setParameterIndex(index++); |
aoqi@0 | 1830 | } |
aoqi@0 | 1831 | } |
aoqi@0 | 1832 | params.add(param); |
aoqi@0 | 1833 | } |
aoqi@0 | 1834 | } |
aoqi@0 | 1835 | return params; |
aoqi@0 | 1836 | } |
aoqi@0 | 1837 | |
aoqi@0 | 1838 | private List<Parameter> getRpcLitParameters(Request req, Response res, Block reqBlock, Block resBlock, List<MessagePart> paramList) { |
aoqi@0 | 1839 | List<Parameter> params = new ArrayList<Parameter>(); |
aoqi@0 | 1840 | Message inMsg = getInputMessage(); |
aoqi@0 | 1841 | Message outMsg = getOutputMessage(); |
aoqi@0 | 1842 | S2JJAXBModel jaxbModel = ((RpcLitStructure) reqBlock.getType()).getJaxbModel().getS2JJAXBModel(); |
aoqi@0 | 1843 | List<Parameter> inParams = ModelerUtils.createRpcLitParameters(inMsg, reqBlock, jaxbModel, errReceiver); |
aoqi@0 | 1844 | List<Parameter> outParams = null; |
aoqi@0 | 1845 | if (outMsg != null) { |
aoqi@0 | 1846 | outParams = ModelerUtils.createRpcLitParameters(outMsg, resBlock, jaxbModel, errReceiver); |
aoqi@0 | 1847 | } |
aoqi@0 | 1848 | |
aoqi@0 | 1849 | //create parameters for header and mime parts |
aoqi@0 | 1850 | int index = 0; |
aoqi@0 | 1851 | for (MessagePart part : paramList) { |
aoqi@0 | 1852 | Parameter param = null; |
aoqi@0 | 1853 | if (ModelerUtils.isBoundToSOAPBody(part)) { |
aoqi@0 | 1854 | if (part.isIN()) { |
aoqi@0 | 1855 | param = ModelerUtils.getParameter(part.getName(), inParams); |
aoqi@0 | 1856 | } else if (outParams != null) { |
aoqi@0 | 1857 | param = ModelerUtils.getParameter(part.getName(), outParams); |
aoqi@0 | 1858 | } |
aoqi@0 | 1859 | } else if (ModelerUtils.isBoundToSOAPHeader(part)) { |
aoqi@0 | 1860 | QName headerName = part.getDescriptor(); |
aoqi@0 | 1861 | JAXBType jaxbType = getJAXBType(part); |
aoqi@0 | 1862 | Block headerBlock = new Block(headerName, jaxbType, part); |
aoqi@0 | 1863 | param = ModelerUtils.createParameter(part.getName(), jaxbType, headerBlock); |
aoqi@0 | 1864 | if (part.isIN()) { |
aoqi@0 | 1865 | req.addHeaderBlock(headerBlock); |
aoqi@0 | 1866 | } else if (part.isOUT()) { |
aoqi@0 | 1867 | res.addHeaderBlock(headerBlock); |
aoqi@0 | 1868 | } else if (part.isINOUT()) { |
aoqi@0 | 1869 | req.addHeaderBlock(headerBlock); |
aoqi@0 | 1870 | res.addHeaderBlock(headerBlock); |
aoqi@0 | 1871 | } |
aoqi@0 | 1872 | } else if (ModelerUtils.isBoundToMimeContent(part)) { |
aoqi@0 | 1873 | List<MIMEContent> mimeContents; |
aoqi@0 | 1874 | if (part.isIN() || part.isINOUT()) { |
aoqi@0 | 1875 | mimeContents = getMimeContents(info.bindingOperation.getInput(), |
aoqi@0 | 1876 | getInputMessage(), part.getName()); |
aoqi@0 | 1877 | } else { |
aoqi@0 | 1878 | mimeContents = getMimeContents(info.bindingOperation.getOutput(), |
aoqi@0 | 1879 | getOutputMessage(), part.getName()); |
aoqi@0 | 1880 | } |
aoqi@0 | 1881 | |
aoqi@0 | 1882 | JAXBType type = getAttachmentType(mimeContents, part); |
aoqi@0 | 1883 | //create Parameters in request or response |
aoqi@0 | 1884 | //Block mimeBlock = new Block(new QName(part.getName()), type); |
aoqi@0 | 1885 | Block mimeBlock = new Block(type.getName(), type, part); |
aoqi@0 | 1886 | param = ModelerUtils.createParameter(part.getName(), type, mimeBlock); |
aoqi@0 | 1887 | if (part.isIN()) { |
aoqi@0 | 1888 | req.addAttachmentBlock(mimeBlock); |
aoqi@0 | 1889 | } else if (part.isOUT()) { |
aoqi@0 | 1890 | res.addAttachmentBlock(mimeBlock); |
aoqi@0 | 1891 | } else if (part.isINOUT()) { |
aoqi@0 | 1892 | mimeContents = getMimeContents(info.bindingOperation.getOutput(), |
aoqi@0 | 1893 | getOutputMessage(), part.getName()); |
aoqi@0 | 1894 | JAXBType outJaxbType = getAttachmentType(mimeContents, part); |
aoqi@0 | 1895 | |
aoqi@0 | 1896 | String inType = type.getJavaType().getType().getName(); |
aoqi@0 | 1897 | String outType = outJaxbType.getJavaType().getType().getName(); |
aoqi@0 | 1898 | if (!inType.equals(outType)) { |
aoqi@0 | 1899 | String javaType = "javax.activation.DataHandler"; |
aoqi@0 | 1900 | JType jt = options.getCodeModel().ref(javaType); |
aoqi@0 | 1901 | JAXBTypeAndAnnotation jaxbTa = type.getJavaType().getType(); |
aoqi@0 | 1902 | jaxbTa.setType(jt); |
aoqi@0 | 1903 | } |
aoqi@0 | 1904 | req.addAttachmentBlock(mimeBlock); |
aoqi@0 | 1905 | res.addAttachmentBlock(mimeBlock); |
aoqi@0 | 1906 | } |
aoqi@0 | 1907 | } else if (ModelerUtils.isUnbound(part)) { |
aoqi@0 | 1908 | QName name = part.getDescriptor(); |
aoqi@0 | 1909 | JAXBType type = getJAXBType(part); |
aoqi@0 | 1910 | Block unboundBlock = new Block(name, type, part); |
aoqi@0 | 1911 | if (part.isIN()) { |
aoqi@0 | 1912 | req.addUnboundBlock(unboundBlock); |
aoqi@0 | 1913 | } else if (part.isOUT()) { |
aoqi@0 | 1914 | res.addUnboundBlock(unboundBlock); |
aoqi@0 | 1915 | } else if (part.isINOUT()) { |
aoqi@0 | 1916 | req.addUnboundBlock(unboundBlock); |
aoqi@0 | 1917 | res.addUnboundBlock(unboundBlock); |
aoqi@0 | 1918 | } |
aoqi@0 | 1919 | param = ModelerUtils.createParameter(part.getName(), type, unboundBlock); |
aoqi@0 | 1920 | } |
aoqi@0 | 1921 | if (param != null) { |
aoqi@0 | 1922 | if (part.isReturn()) { |
aoqi@0 | 1923 | param.setParameterIndex(-1); |
aoqi@0 | 1924 | } else { |
aoqi@0 | 1925 | param.setParameterIndex(index++); |
aoqi@0 | 1926 | } |
aoqi@0 | 1927 | param.setMode(part.getMode()); |
aoqi@0 | 1928 | params.add(param); |
aoqi@0 | 1929 | } |
aoqi@0 | 1930 | } |
aoqi@0 | 1931 | for (Parameter param : params) { |
aoqi@0 | 1932 | if (param.isIN()) { |
aoqi@0 | 1933 | setCustomizedParameterName(info.portTypeOperation, inMsg, inMsg.getPart(param.getName()), param, false); |
aoqi@0 | 1934 | } else if (outMsg != null) { |
aoqi@0 | 1935 | setCustomizedParameterName(info.portTypeOperation, outMsg, outMsg.getPart(param.getName()), param, false); |
aoqi@0 | 1936 | } |
aoqi@0 | 1937 | } |
aoqi@0 | 1938 | return params; |
aoqi@0 | 1939 | } |
aoqi@0 | 1940 | |
aoqi@0 | 1941 | private List<Parameter> getRequestParameters(Request request, List<String> parameterList) { |
aoqi@0 | 1942 | Message inputMessage = getInputMessage(); |
aoqi@0 | 1943 | //there is no input message, return zero parameters |
aoqi@0 | 1944 | if (inputMessage != null && !inputMessage.parts().hasNext()) { |
aoqi@0 | 1945 | return new ArrayList<Parameter>(); |
aoqi@0 | 1946 | } |
aoqi@0 | 1947 | |
aoqi@0 | 1948 | List<Parameter> inParameters = null; |
aoqi@0 | 1949 | QName reqBodyName; |
aoqi@0 | 1950 | Block reqBlock; |
aoqi@0 | 1951 | JAXBType jaxbReqType; |
aoqi@0 | 1952 | boolean unwrappable = isUnwrappable(); |
aoqi@0 | 1953 | boolean doneSOAPBody = false; |
aoqi@0 | 1954 | //setup request parameters |
aoqi@0 | 1955 | for (String inParamName : parameterList) { |
aoqi@0 | 1956 | MessagePart part = inputMessage.getPart(inParamName); |
aoqi@0 | 1957 | if (part == null) { |
aoqi@0 | 1958 | continue; |
aoqi@0 | 1959 | } |
aoqi@0 | 1960 | reqBodyName = part.getDescriptor(); |
aoqi@0 | 1961 | jaxbReqType = getJAXBType(part); |
aoqi@0 | 1962 | if (unwrappable) { |
aoqi@0 | 1963 | //So build body and header blocks and set to request and response |
aoqi@0 | 1964 | JAXBStructuredType jaxbRequestType = ModelerUtils.createJAXBStructureType(jaxbReqType); |
aoqi@0 | 1965 | reqBlock = new Block(reqBodyName, jaxbRequestType, part); |
aoqi@0 | 1966 | if (ModelerUtils.isBoundToSOAPBody(part)) { |
aoqi@0 | 1967 | request.addBodyBlock(reqBlock); |
aoqi@0 | 1968 | } else if (ModelerUtils.isUnbound(part)) { |
aoqi@0 | 1969 | request.addUnboundBlock(reqBlock); |
aoqi@0 | 1970 | } |
aoqi@0 | 1971 | inParameters = ModelerUtils.createUnwrappedParameters(jaxbRequestType, reqBlock); |
aoqi@0 | 1972 | for (Parameter param : inParameters) { |
aoqi@0 | 1973 | setCustomizedParameterName(info.portTypeOperation, inputMessage, part, param, unwrappable); |
aoqi@0 | 1974 | } |
aoqi@0 | 1975 | } else { |
aoqi@0 | 1976 | reqBlock = new Block(reqBodyName, jaxbReqType, part); |
aoqi@0 | 1977 | if (ModelerUtils.isBoundToSOAPBody(part) && !doneSOAPBody) { |
aoqi@0 | 1978 | doneSOAPBody = true; |
aoqi@0 | 1979 | request.addBodyBlock(reqBlock); |
aoqi@0 | 1980 | } else if (ModelerUtils.isBoundToSOAPHeader(part)) { |
aoqi@0 | 1981 | request.addHeaderBlock(reqBlock); |
aoqi@0 | 1982 | } else if (ModelerUtils.isBoundToMimeContent(part)) { |
aoqi@0 | 1983 | List<MIMEContent> mimeContents = getMimeContents(info.bindingOperation.getInput(), |
aoqi@0 | 1984 | getInputMessage(), part.getName()); |
aoqi@0 | 1985 | jaxbReqType = getAttachmentType(mimeContents, part); |
aoqi@0 | 1986 | //reqBlock = new Block(new QName(part.getName()), jaxbReqType); |
aoqi@0 | 1987 | reqBlock = new Block(jaxbReqType.getName(), jaxbReqType, part); |
aoqi@0 | 1988 | request.addAttachmentBlock(reqBlock); |
aoqi@0 | 1989 | } else if (ModelerUtils.isUnbound(part)) { |
aoqi@0 | 1990 | request.addUnboundBlock(reqBlock); |
aoqi@0 | 1991 | } |
aoqi@0 | 1992 | if (inParameters == null) { |
aoqi@0 | 1993 | inParameters = new ArrayList<Parameter>(); |
aoqi@0 | 1994 | } |
aoqi@0 | 1995 | Parameter param = ModelerUtils.createParameter(part.getName(), jaxbReqType, reqBlock); |
aoqi@0 | 1996 | setCustomizedParameterName(info.portTypeOperation, inputMessage, part, param, false); |
aoqi@0 | 1997 | inParameters.add(param); |
aoqi@0 | 1998 | } |
aoqi@0 | 1999 | } |
aoqi@0 | 2000 | return inParameters; |
aoqi@0 | 2001 | } |
aoqi@0 | 2002 | |
aoqi@0 | 2003 | /** |
aoqi@0 | 2004 | * @param part |
aoqi@0 | 2005 | * @param param |
aoqi@0 | 2006 | * @param wrapperStyle TODO |
aoqi@0 | 2007 | */ |
aoqi@0 | 2008 | private void setCustomizedParameterName(TWSDLExtensible extension, Message msg, MessagePart part, Parameter param, boolean wrapperStyle) { |
aoqi@0 | 2009 | JAXWSBinding jaxwsBinding = (JAXWSBinding) getExtensionOfType(extension, JAXWSBinding.class); |
aoqi@0 | 2010 | if (jaxwsBinding == null) { |
aoqi@0 | 2011 | return; |
aoqi@0 | 2012 | } |
aoqi@0 | 2013 | String paramName = part.getName(); |
aoqi@0 | 2014 | QName elementName = part.getDescriptor(); |
aoqi@0 | 2015 | if (wrapperStyle) { |
aoqi@0 | 2016 | elementName = param.getType().getName(); |
aoqi@0 | 2017 | } |
aoqi@0 | 2018 | String customName = jaxwsBinding.getParameterName(msg.getName(), paramName, elementName, wrapperStyle); |
aoqi@0 | 2019 | if (customName != null && !customName.equals("")) { |
aoqi@0 | 2020 | param.setCustomName(customName); |
aoqi@0 | 2021 | } |
aoqi@0 | 2022 | } |
aoqi@0 | 2023 | |
aoqi@0 | 2024 | @Override |
aoqi@0 | 2025 | protected boolean isConflictingPortClassName(String name) { |
aoqi@0 | 2026 | return false; |
aoqi@0 | 2027 | } |
aoqi@0 | 2028 | |
aoqi@0 | 2029 | protected boolean isUnwrappable() { |
aoqi@0 | 2030 | if (!getWrapperStyleCustomization()) { |
aoqi@0 | 2031 | return false; |
aoqi@0 | 2032 | } |
aoqi@0 | 2033 | |
aoqi@0 | 2034 | com.sun.tools.internal.ws.wsdl.document.Message inputMessage = getInputMessage(); |
aoqi@0 | 2035 | com.sun.tools.internal.ws.wsdl.document.Message outputMessage = getOutputMessage(); |
aoqi@0 | 2036 | |
aoqi@0 | 2037 | // Wrapper style if the operation's input and output messages each contain |
aoqi@0 | 2038 | // only a single part |
aoqi@0 | 2039 | if ((inputMessage != null && inputMessage.numParts() != 1) |
aoqi@0 | 2040 | || (outputMessage != null && outputMessage.numParts() != 1)) { |
aoqi@0 | 2041 | return false; |
aoqi@0 | 2042 | } |
aoqi@0 | 2043 | |
aoqi@0 | 2044 | MessagePart inputPart = inputMessage != null |
aoqi@0 | 2045 | ? inputMessage.parts().next() : null; |
aoqi@0 | 2046 | MessagePart outputPart = outputMessage != null |
aoqi@0 | 2047 | ? outputMessage.parts().next() : null; |
aoqi@0 | 2048 | String operationName = info.portTypeOperation.getName(); |
aoqi@0 | 2049 | |
aoqi@0 | 2050 | // Wrapper style if the input message part refers to a global element declaration whose localname |
aoqi@0 | 2051 | // is equal to the operation name |
aoqi@0 | 2052 | // Wrapper style if the output message part refers to a global element declaration |
aoqi@0 | 2053 | if ((inputPart != null && !inputPart.getDescriptor().getLocalPart().equals(operationName)) || |
aoqi@0 | 2054 | (outputPart != null && outputPart.getDescriptorKind() != SchemaKinds.XSD_ELEMENT)) { |
aoqi@0 | 2055 | return false; |
aoqi@0 | 2056 | } |
aoqi@0 | 2057 | |
aoqi@0 | 2058 | //check to see if either input or output message part not bound to soapbing:body |
aoqi@0 | 2059 | //in that case the operation is not wrapper style |
aoqi@0 | 2060 | if (((inputPart != null) && (inputPart.getBindingExtensibilityElementKind() != MessagePart.SOAP_BODY_BINDING)) || |
aoqi@0 | 2061 | ((outputPart != null) && (outputPart.getBindingExtensibilityElementKind() != MessagePart.SOAP_BODY_BINDING))) { |
aoqi@0 | 2062 | return false; |
aoqi@0 | 2063 | } |
aoqi@0 | 2064 | |
aoqi@0 | 2065 | // Wrapper style if the elements referred to by the input and output message parts |
aoqi@0 | 2066 | // (henceforth referred to as wrapper elements) are both complex types defined |
aoqi@0 | 2067 | // using the xsd:sequence compositor |
aoqi@0 | 2068 | // Wrapper style if the wrapper elements only contain child elements, they must not |
aoqi@0 | 2069 | // contain other structures such as xsd:choice, substitution groups1 or attributes |
aoqi@0 | 2070 | //These checkins are done by jaxb, we just check if jaxb has wrapper children. If there |
aoqi@0 | 2071 | // are then its wrapper style |
aoqi@0 | 2072 | //if(inputPart != null && outputPart != null){ |
aoqi@0 | 2073 | if (inputPart != null) { |
aoqi@0 | 2074 | boolean inputWrappable = false; |
aoqi@0 | 2075 | JAXBType inputType = getJAXBType(inputPart); |
aoqi@0 | 2076 | if (inputType != null) { |
aoqi@0 | 2077 | inputWrappable = inputType.isUnwrappable(); |
aoqi@0 | 2078 | } |
aoqi@0 | 2079 | //if there are no output part (oneway), the operation can still be wrapper style |
aoqi@0 | 2080 | if (outputPart == null) { |
aoqi@0 | 2081 | return inputWrappable; |
aoqi@0 | 2082 | } |
aoqi@0 | 2083 | JAXBType outputType = getJAXBType(outputPart); |
aoqi@0 | 2084 | if ((inputType != null) && (outputType != null)) { |
aoqi@0 | 2085 | return inputType.isUnwrappable() && outputType.isUnwrappable(); |
aoqi@0 | 2086 | } |
aoqi@0 | 2087 | } |
aoqi@0 | 2088 | |
aoqi@0 | 2089 | return false; |
aoqi@0 | 2090 | } |
aoqi@0 | 2091 | |
aoqi@0 | 2092 | private boolean getWrapperStyleCustomization() { |
aoqi@0 | 2093 | //first we look into wsdl:portType/wsdl:operation |
aoqi@0 | 2094 | com.sun.tools.internal.ws.wsdl.document.Operation portTypeOperation = info.portTypeOperation; |
aoqi@0 | 2095 | JAXWSBinding jaxwsBinding = (JAXWSBinding) getExtensionOfType(portTypeOperation, JAXWSBinding.class); |
aoqi@0 | 2096 | if (jaxwsBinding != null) { |
aoqi@0 | 2097 | Boolean isWrappable = jaxwsBinding.isEnableWrapperStyle(); |
aoqi@0 | 2098 | if (isWrappable != null) { |
aoqi@0 | 2099 | return isWrappable; |
aoqi@0 | 2100 | } |
aoqi@0 | 2101 | } |
aoqi@0 | 2102 | |
aoqi@0 | 2103 | //then into wsdl:portType |
aoqi@0 | 2104 | PortType portType = info.port.resolveBinding(document).resolvePortType(document); |
aoqi@0 | 2105 | jaxwsBinding = (JAXWSBinding) getExtensionOfType(portType, JAXWSBinding.class); |
aoqi@0 | 2106 | if (jaxwsBinding != null) { |
aoqi@0 | 2107 | Boolean isWrappable = jaxwsBinding.isEnableWrapperStyle(); |
aoqi@0 | 2108 | if (isWrappable != null) { |
aoqi@0 | 2109 | return isWrappable; |
aoqi@0 | 2110 | } |
aoqi@0 | 2111 | } |
aoqi@0 | 2112 | |
aoqi@0 | 2113 | //then wsdl:definitions |
aoqi@0 | 2114 | jaxwsBinding = (JAXWSBinding) getExtensionOfType(document.getDefinitions(), JAXWSBinding.class); |
aoqi@0 | 2115 | if (jaxwsBinding != null) { |
aoqi@0 | 2116 | Boolean isWrappable = jaxwsBinding.isEnableWrapperStyle(); |
aoqi@0 | 2117 | if (isWrappable != null) { |
aoqi@0 | 2118 | return isWrappable; |
aoqi@0 | 2119 | } |
aoqi@0 | 2120 | } |
aoqi@0 | 2121 | return true; |
aoqi@0 | 2122 | } |
aoqi@0 | 2123 | |
aoqi@0 | 2124 | /* (non-Javadoc) |
aoqi@0 | 2125 | * @see WSDLModelerBase#isSingleInOutPart(Set, MessagePart) |
aoqi@0 | 2126 | */ |
aoqi@0 | 2127 | protected boolean isSingleInOutPart(Set inputParameterNames, |
aoqi@0 | 2128 | MessagePart outputPart) { |
aoqi@0 | 2129 | // As of now, we dont have support for in/out in doc-lit. So return false. |
aoqi@0 | 2130 | SOAPOperation soapOperation = |
aoqi@0 | 2131 | (SOAPOperation) getExtensionOfType(info.bindingOperation, |
aoqi@0 | 2132 | SOAPOperation.class); |
aoqi@0 | 2133 | if ((soapOperation != null) && (soapOperation.isDocument() || info.soapBinding.isDocument())) { |
aoqi@0 | 2134 | Iterator iter = getInputMessage().parts(); |
aoqi@0 | 2135 | while (iter.hasNext()) { |
aoqi@0 | 2136 | MessagePart part = (MessagePart) iter.next(); |
aoqi@0 | 2137 | if (outputPart.getName().equals(part.getName()) && outputPart.getDescriptor().equals(part.getDescriptor())) { |
aoqi@0 | 2138 | return true; |
aoqi@0 | 2139 | } |
aoqi@0 | 2140 | } |
aoqi@0 | 2141 | } else if (soapOperation != null && soapOperation.isRPC() || info.soapBinding.isRPC()) { |
aoqi@0 | 2142 | com.sun.tools.internal.ws.wsdl.document.Message inputMessage = getInputMessage(); |
aoqi@0 | 2143 | if (inputParameterNames.contains(outputPart.getName())) { |
aoqi@0 | 2144 | if (inputMessage.getPart(outputPart.getName()).getDescriptor().equals(outputPart.getDescriptor())) { |
aoqi@0 | 2145 | return true; |
aoqi@0 | 2146 | } |
aoqi@0 | 2147 | } |
aoqi@0 | 2148 | } |
aoqi@0 | 2149 | return false; |
aoqi@0 | 2150 | } |
aoqi@0 | 2151 | |
aoqi@0 | 2152 | private List<Parameter> createRpcLitRequestParameters(Request request, List<String> parameterList, Block block) { |
aoqi@0 | 2153 | Message message = getInputMessage(); |
aoqi@0 | 2154 | S2JJAXBModel jaxbModel = ((RpcLitStructure) block.getType()).getJaxbModel().getS2JJAXBModel(); |
aoqi@0 | 2155 | List<Parameter> parameters = ModelerUtils.createRpcLitParameters(message, block, jaxbModel, errReceiver); |
aoqi@0 | 2156 | |
aoqi@0 | 2157 | //create parameters for header and mime parts |
aoqi@0 | 2158 | for (String paramName : parameterList) { |
aoqi@0 | 2159 | MessagePart part = message.getPart(paramName); |
aoqi@0 | 2160 | if (part == null) { |
aoqi@0 | 2161 | continue; |
aoqi@0 | 2162 | } |
aoqi@0 | 2163 | if (ModelerUtils.isBoundToSOAPHeader(part)) { |
aoqi@0 | 2164 | if (parameters == null) { |
aoqi@0 | 2165 | parameters = new ArrayList<Parameter>(); |
aoqi@0 | 2166 | } |
aoqi@0 | 2167 | QName headerName = part.getDescriptor(); |
aoqi@0 | 2168 | JAXBType jaxbType = getJAXBType(part); |
aoqi@0 | 2169 | Block headerBlock = new Block(headerName, jaxbType, part); |
aoqi@0 | 2170 | request.addHeaderBlock(headerBlock); |
aoqi@0 | 2171 | Parameter param = ModelerUtils.createParameter(part.getName(), jaxbType, headerBlock); |
aoqi@0 | 2172 | if (param != null) { |
aoqi@0 | 2173 | parameters.add(param); |
aoqi@0 | 2174 | } |
aoqi@0 | 2175 | } else if (ModelerUtils.isBoundToMimeContent(part)) { |
aoqi@0 | 2176 | if (parameters == null) { |
aoqi@0 | 2177 | parameters = new ArrayList<Parameter>(); |
aoqi@0 | 2178 | } |
aoqi@0 | 2179 | List<MIMEContent> mimeContents = getMimeContents(info.bindingOperation.getInput(), |
aoqi@0 | 2180 | getInputMessage(), paramName); |
aoqi@0 | 2181 | |
aoqi@0 | 2182 | JAXBType type = getAttachmentType(mimeContents, part); |
aoqi@0 | 2183 | //create Parameters in request or response |
aoqi@0 | 2184 | //Block mimeBlock = new Block(new QName(part.getName()), type); |
aoqi@0 | 2185 | Block mimeBlock = new Block(type.getName(), type, part); |
aoqi@0 | 2186 | request.addAttachmentBlock(mimeBlock); |
aoqi@0 | 2187 | Parameter param = ModelerUtils.createParameter(part.getName(), type, mimeBlock); |
aoqi@0 | 2188 | if (param != null) { |
aoqi@0 | 2189 | parameters.add(param); |
aoqi@0 | 2190 | } |
aoqi@0 | 2191 | } else if (ModelerUtils.isUnbound(part)) { |
aoqi@0 | 2192 | if (parameters == null) { |
aoqi@0 | 2193 | parameters = new ArrayList<Parameter>(); |
aoqi@0 | 2194 | } |
aoqi@0 | 2195 | QName name = part.getDescriptor(); |
aoqi@0 | 2196 | JAXBType type = getJAXBType(part); |
aoqi@0 | 2197 | Block unboundBlock = new Block(name, type, part); |
aoqi@0 | 2198 | request.addUnboundBlock(unboundBlock); |
aoqi@0 | 2199 | Parameter param = ModelerUtils.createParameter(part.getName(), type, unboundBlock); |
aoqi@0 | 2200 | if (param != null) { |
aoqi@0 | 2201 | parameters.add(param); |
aoqi@0 | 2202 | } |
aoqi@0 | 2203 | } |
aoqi@0 | 2204 | } |
aoqi@0 | 2205 | for (Parameter param : parameters) { |
aoqi@0 | 2206 | setCustomizedParameterName(info.portTypeOperation, message, message.getPart(param.getName()), param, false); |
aoqi@0 | 2207 | } |
aoqi@0 | 2208 | return parameters; |
aoqi@0 | 2209 | } |
aoqi@0 | 2210 | |
aoqi@0 | 2211 | private String getJavaTypeForMimeType(String mimeType) { |
aoqi@0 | 2212 | if (mimeType.equals("image/jpeg") || mimeType.equals("image/gif")) { |
aoqi@0 | 2213 | return "java.awt.Image"; |
aoqi@0 | 2214 | } else if (mimeType.equals("text/xml") || mimeType.equals("application/xml")) { |
aoqi@0 | 2215 | return "javax.xml.transform.Source"; |
aoqi@0 | 2216 | } |
aoqi@0 | 2217 | return "javax.activation.DataHandler"; |
aoqi@0 | 2218 | } |
aoqi@0 | 2219 | |
aoqi@0 | 2220 | private JAXBType getAttachmentType(List<MIMEContent> mimeContents, MessagePart part) { |
aoqi@0 | 2221 | if (!enableMimeContent()) { |
aoqi@0 | 2222 | return getJAXBType(part); |
aoqi@0 | 2223 | } |
aoqi@0 | 2224 | String javaType; |
aoqi@0 | 2225 | List<String> mimeTypes = getAlternateMimeTypes(mimeContents); |
aoqi@0 | 2226 | if (mimeTypes.size() > 1) { |
aoqi@0 | 2227 | javaType = "javax.activation.DataHandler"; |
aoqi@0 | 2228 | } else { |
aoqi@0 | 2229 | javaType = getJavaTypeForMimeType(mimeTypes.get(0)); |
aoqi@0 | 2230 | } |
aoqi@0 | 2231 | |
aoqi@0 | 2232 | S2JJAXBModel jaxbModel = getJAXBModelBuilder().getJAXBModel().getS2JJAXBModel(); |
aoqi@0 | 2233 | JType jt = options.getCodeModel().ref(javaType); |
aoqi@0 | 2234 | QName desc = part.getDescriptor(); |
aoqi@0 | 2235 | TypeAndAnnotation typeAnno = null; |
aoqi@0 | 2236 | |
aoqi@0 | 2237 | if (part.getDescriptorKind() == SchemaKinds.XSD_TYPE) { |
aoqi@0 | 2238 | typeAnno = jaxbModel.getJavaType(desc); |
aoqi@0 | 2239 | desc = new QName("", part.getName()); |
aoqi@0 | 2240 | } else if (part.getDescriptorKind() == SchemaKinds.XSD_ELEMENT) { |
aoqi@0 | 2241 | typeAnno = getJAXBModelBuilder().getElementTypeAndAnn(desc); |
aoqi@0 | 2242 | if(typeAnno == null){ |
aoqi@0 | 2243 | error(part, ModelerMessages.WSDLMODELER_JAXB_JAVATYPE_NOTFOUND(part.getDescriptor(), part.getName())); |
aoqi@0 | 2244 | } |
aoqi@0 | 2245 | for (String mimeType : mimeTypes) { |
aoqi@0 | 2246 | if ((!mimeType.equals("text/xml") && !mimeType.equals("application/xml"))) { |
aoqi@0 | 2247 | //According to AP 1.0, |
aoqi@0 | 2248 | //RZZZZ: In a DESCRIPTION, if a wsdl:part element refers to a |
aoqi@0 | 2249 | //global element declaration (via the element attribute of the wsdl:part |
aoqi@0 | 2250 | //element) then the value of the type attribute of a mime:content element |
aoqi@0 | 2251 | //that binds that part MUST be a content type suitable for carrying an |
aoqi@0 | 2252 | //XML serialization. |
aoqi@0 | 2253 | //should we throw warning? |
aoqi@0 | 2254 | //type = MimeHelper.javaType.DATA_HANDLER_JAVATYPE; |
aoqi@0 | 2255 | warning(part, ModelerMessages.MIMEMODELER_ELEMENT_PART_INVALID_ELEMENT_MIME_TYPE(part.getName(), mimeType)); |
aoqi@0 | 2256 | } |
aoqi@0 | 2257 | } |
aoqi@0 | 2258 | } |
aoqi@0 | 2259 | if (typeAnno == null) { |
aoqi@0 | 2260 | error(part, ModelerMessages.WSDLMODELER_JAXB_JAVATYPE_NOTFOUND(desc, part.getName())); |
aoqi@0 | 2261 | } |
aoqi@0 | 2262 | return new JAXBType(desc, new JavaSimpleType(new JAXBTypeAndAnnotation(typeAnno, jt)), |
aoqi@0 | 2263 | null, getJAXBModelBuilder().getJAXBModel()); |
aoqi@0 | 2264 | } |
aoqi@0 | 2265 | |
aoqi@0 | 2266 | protected void buildJAXBModel(WSDLDocument wsdlDocument) { |
aoqi@0 | 2267 | JAXBModelBuilder tempJaxbModelBuilder = new JAXBModelBuilder(options, classNameCollector, forest, errReceiver); |
aoqi@0 | 2268 | //set the java package where wsdl artifacts will be generated |
aoqi@0 | 2269 | //if user provided package name using -p switch (or package property on wsimport ant task) |
aoqi@0 | 2270 | //ignore the package customization in the wsdl and schema bidnings |
aoqi@0 | 2271 | //formce the -p option only in the first pass |
aoqi@0 | 2272 | if (explicitDefaultPackage != null) { |
aoqi@0 | 2273 | tempJaxbModelBuilder.getJAXBSchemaCompiler().forcePackageName(options.defaultPackage); |
aoqi@0 | 2274 | } else { |
aoqi@0 | 2275 | options.defaultPackage = getJavaPackage(); |
aoqi@0 | 2276 | } |
aoqi@0 | 2277 | |
aoqi@0 | 2278 | //create pseudo schema for async operations(if any) response bean |
aoqi@0 | 2279 | List<InputSource> schemas = PseudoSchemaBuilder.build(this, options, errReceiver); |
aoqi@0 | 2280 | for (InputSource schema : schemas) { |
aoqi@0 | 2281 | tempJaxbModelBuilder.getJAXBSchemaCompiler().parseSchema(schema); |
aoqi@0 | 2282 | } |
aoqi@0 | 2283 | tempJaxbModelBuilder.bind(); |
aoqi@0 | 2284 | this.jaxbModelBuilder = tempJaxbModelBuilder; |
aoqi@0 | 2285 | } |
aoqi@0 | 2286 | |
aoqi@0 | 2287 | protected String getJavaPackage() { |
aoqi@0 | 2288 | String jaxwsPackage = null; |
aoqi@0 | 2289 | JAXWSBinding jaxwsCustomization = (JAXWSBinding) getExtensionOfType(document.getDefinitions(), JAXWSBinding.class); |
aoqi@0 | 2290 | if (jaxwsCustomization != null && jaxwsCustomization.getJaxwsPackage() != null) { |
aoqi@0 | 2291 | jaxwsPackage = jaxwsCustomization.getJaxwsPackage().getName(); |
aoqi@0 | 2292 | } |
aoqi@0 | 2293 | if (jaxwsPackage != null) { |
aoqi@0 | 2294 | return jaxwsPackage; |
aoqi@0 | 2295 | } |
aoqi@0 | 2296 | String wsdlUri = document.getDefinitions().getTargetNamespaceURI(); |
aoqi@0 | 2297 | return XJC.getDefaultPackageName(wsdlUri); |
aoqi@0 | 2298 | |
aoqi@0 | 2299 | } |
aoqi@0 | 2300 | |
aoqi@0 | 2301 | protected void createJavaInterfaceForProviderPort(Port port) { |
aoqi@0 | 2302 | String interfaceName = "javax.xml.ws.Provider"; |
aoqi@0 | 2303 | JavaInterface intf = new JavaInterface(interfaceName); |
aoqi@0 | 2304 | port.setJavaInterface(intf); |
aoqi@0 | 2305 | } |
aoqi@0 | 2306 | |
aoqi@0 | 2307 | protected void createJavaInterfaceForPort(Port port, boolean isProvider) { |
aoqi@0 | 2308 | if (isProvider) { |
aoqi@0 | 2309 | createJavaInterfaceForProviderPort(port); |
aoqi@0 | 2310 | return; |
aoqi@0 | 2311 | } |
aoqi@0 | 2312 | String interfaceName = getJavaNameOfSEI(port); |
aoqi@0 | 2313 | |
aoqi@0 | 2314 | if (isConflictingPortClassName(interfaceName)) { |
aoqi@0 | 2315 | interfaceName += "_PortType"; |
aoqi@0 | 2316 | } |
aoqi@0 | 2317 | |
aoqi@0 | 2318 | JavaInterface intf = new JavaInterface(interfaceName); |
aoqi@0 | 2319 | for (Operation operation : port.getOperations()) { |
aoqi@0 | 2320 | createJavaMethodForOperation( |
aoqi@0 | 2321 | port, |
aoqi@0 | 2322 | operation, |
aoqi@0 | 2323 | intf); |
aoqi@0 | 2324 | |
aoqi@0 | 2325 | for (JavaParameter jParam : operation.getJavaMethod().getParametersList()) { |
aoqi@0 | 2326 | Parameter param = jParam.getParameter(); |
aoqi@0 | 2327 | if (param.getCustomName() != null) { |
aoqi@0 | 2328 | jParam.setName(param.getCustomName()); |
aoqi@0 | 2329 | } |
aoqi@0 | 2330 | } |
aoqi@0 | 2331 | } |
aoqi@0 | 2332 | |
aoqi@0 | 2333 | port.setJavaInterface(intf); |
aoqi@0 | 2334 | } |
aoqi@0 | 2335 | |
aoqi@0 | 2336 | protected String getServiceInterfaceName(QName serviceQName, com.sun.tools.internal.ws.wsdl.document.Service wsdlService) { |
aoqi@0 | 2337 | String serviceName = wsdlService.getName(); |
aoqi@0 | 2338 | JAXWSBinding jaxwsCust = (JAXWSBinding) getExtensionOfType(wsdlService, JAXWSBinding.class); |
aoqi@0 | 2339 | if (jaxwsCust != null && jaxwsCust.getClassName() != null) { |
aoqi@0 | 2340 | CustomName name = jaxwsCust.getClassName(); |
aoqi@0 | 2341 | if (name != null && !name.getName().equals("")) { |
aoqi@0 | 2342 | return makePackageQualified(name.getName()); |
aoqi@0 | 2343 | } |
aoqi@0 | 2344 | } |
aoqi@0 | 2345 | return makePackageQualified(BindingHelper.mangleNameToClassName(serviceName)); |
aoqi@0 | 2346 | } |
aoqi@0 | 2347 | |
aoqi@0 | 2348 | protected String getJavaNameOfSEI(Port port) { |
aoqi@0 | 2349 | QName portTypeName = |
aoqi@0 | 2350 | (QName) port.getProperty( |
aoqi@0 | 2351 | ModelProperties.PROPERTY_WSDL_PORT_TYPE_NAME); |
aoqi@0 | 2352 | PortType pt = (PortType) document.find(Kinds.PORT_TYPE, portTypeName); |
aoqi@0 | 2353 | //populate the portType map here. We should get rid of all these properties |
aoqi@0 | 2354 | // lets not do it as it may break NB |
aoqi@0 | 2355 | //TODO: clean all these stuff part of NB RFE |
aoqi@0 | 2356 | port.portTypes.put(portTypeName, pt); |
aoqi@0 | 2357 | JAXWSBinding jaxwsCust = (JAXWSBinding) getExtensionOfType(pt, JAXWSBinding.class); |
aoqi@0 | 2358 | if (jaxwsCust != null && jaxwsCust.getClassName() != null) { |
aoqi@0 | 2359 | CustomName name = jaxwsCust.getClassName(); |
aoqi@0 | 2360 | if (name != null && !name.getName().equals("")) { |
aoqi@0 | 2361 | return makePackageQualified(name.getName()); |
aoqi@0 | 2362 | } |
aoqi@0 | 2363 | } |
aoqi@0 | 2364 | |
aoqi@0 | 2365 | String interfaceName; |
aoqi@0 | 2366 | if (portTypeName != null) { |
aoqi@0 | 2367 | // got portType information from WSDL, use it to name the interface |
aoqi@0 | 2368 | interfaceName = |
aoqi@0 | 2369 | makePackageQualified(BindingHelper.mangleNameToClassName(portTypeName.getLocalPart())); |
aoqi@0 | 2370 | } else { |
aoqi@0 | 2371 | // somehow we only got the port name, so we use that |
aoqi@0 | 2372 | interfaceName = |
aoqi@0 | 2373 | makePackageQualified(BindingHelper.mangleNameToClassName(port.getName().getLocalPart())); |
aoqi@0 | 2374 | } |
aoqi@0 | 2375 | return interfaceName; |
aoqi@0 | 2376 | } |
aoqi@0 | 2377 | |
aoqi@0 | 2378 | private void createJavaMethodForAsyncOperation(Port port, Operation operation, |
aoqi@0 | 2379 | JavaInterface intf) { |
aoqi@0 | 2380 | String candidateName = getJavaNameForOperation(operation); |
aoqi@0 | 2381 | JavaMethod method = new JavaMethod(candidateName, options, errReceiver); |
aoqi@0 | 2382 | |
aoqi@0 | 2383 | assert (operation.getRequest() != null); |
aoqi@0 | 2384 | Response response = operation.getResponse(); |
aoqi@0 | 2385 | |
aoqi@0 | 2386 | // build a signature of the form "opName%arg1type%arg2type%...%argntype so that we |
aoqi@0 | 2387 | // detect overloading conflicts in the generated java interface/classes |
aoqi@0 | 2388 | for (Iterator iter = operation.getRequest().getParameters(); iter.hasNext();) { |
aoqi@0 | 2389 | Parameter parameter = (Parameter) iter.next(); |
aoqi@0 | 2390 | |
aoqi@0 | 2391 | if (parameter.getJavaParameter() != null) { |
aoqi@0 | 2392 | error(operation.getEntity(), ModelerMessages.WSDLMODELER_INVALID_OPERATION(operation.getName().getLocalPart())); |
aoqi@0 | 2393 | } |
aoqi@0 | 2394 | |
aoqi@0 | 2395 | JavaType parameterType = parameter.getType().getJavaType(); |
aoqi@0 | 2396 | JavaParameter javaParameter = |
aoqi@0 | 2397 | new JavaParameter( |
aoqi@0 | 2398 | BindingHelper.mangleNameToVariableName(parameter.getName()), |
aoqi@0 | 2399 | parameterType, |
aoqi@0 | 2400 | parameter, |
aoqi@0 | 2401 | parameter.getLinkedParameter() != null); |
aoqi@0 | 2402 | if (javaParameter.isHolder()) { |
aoqi@0 | 2403 | javaParameter.setHolderName(javax.xml.ws.Holder.class.getName()); |
aoqi@0 | 2404 | } |
aoqi@0 | 2405 | method.addParameter(javaParameter); |
aoqi@0 | 2406 | parameter.setJavaParameter(javaParameter); |
aoqi@0 | 2407 | |
aoqi@0 | 2408 | } |
aoqi@0 | 2409 | |
aoqi@0 | 2410 | if (response != null) { |
aoqi@0 | 2411 | String resultParameterName = |
aoqi@0 | 2412 | (String) operation.getProperty(WSDL_RESULT_PARAMETER); |
aoqi@0 | 2413 | Parameter resultParameter = |
aoqi@0 | 2414 | response.getParameterByName(resultParameterName); |
aoqi@0 | 2415 | JavaType returnType = resultParameter.getType().getJavaType(); |
aoqi@0 | 2416 | method.setReturnType(returnType); |
aoqi@0 | 2417 | |
aoqi@0 | 2418 | } |
aoqi@0 | 2419 | operation.setJavaMethod(method); |
aoqi@0 | 2420 | intf.addMethod(method); |
aoqi@0 | 2421 | } |
aoqi@0 | 2422 | |
aoqi@0 | 2423 | /* (non-Javadoc) |
aoqi@0 | 2424 | * @see WSDLModelerBase#createJavaMethodForOperation(WSDLPort, WSDLOperation, JavaInterface, Set, Set) |
aoqi@0 | 2425 | */ |
aoqi@0 | 2426 | protected void createJavaMethodForOperation(Port port, Operation operation, JavaInterface intf) { |
aoqi@0 | 2427 | if ((operation instanceof AsyncOperation)) { |
aoqi@0 | 2428 | createJavaMethodForAsyncOperation(port, operation, intf); |
aoqi@0 | 2429 | return; |
aoqi@0 | 2430 | } |
aoqi@0 | 2431 | String candidateName = getJavaNameForOperation(operation); |
aoqi@0 | 2432 | JavaMethod method = new JavaMethod(candidateName, options, errReceiver); |
aoqi@0 | 2433 | Parameter returnParam = (Parameter) operation.getProperty(WSDL_RESULT_PARAMETER); |
aoqi@0 | 2434 | if (returnParam != null) { |
aoqi@0 | 2435 | JavaType parameterType = returnParam.getType().getJavaType(); |
aoqi@0 | 2436 | method.setReturnType(parameterType); |
aoqi@0 | 2437 | } else { |
aoqi@0 | 2438 | method.setReturnType(JavaSimpleTypeCreator.VOID_JAVATYPE); |
aoqi@0 | 2439 | } |
aoqi@0 | 2440 | List<Parameter> parameterOrder = (List<Parameter>) operation.getProperty(WSDL_PARAMETER_ORDER); |
aoqi@0 | 2441 | for (Parameter param : parameterOrder) { |
aoqi@0 | 2442 | JavaType parameterType = param.getType().getJavaType(); |
aoqi@0 | 2443 | String name = (param.getCustomName() != null) ? param.getCustomName() : param.getName(); |
aoqi@0 | 2444 | name = BindingHelper.mangleNameToVariableName(name); |
aoqi@0 | 2445 | //if its a java keyword after name mangling, then we simply put underscore as there is no |
aoqi@0 | 2446 | //need to ask user to customize the parameter name if its java keyword |
aoqi@0 | 2447 | if(Names.isJavaReservedWord(name)){ |
aoqi@0 | 2448 | name = "_"+name; |
aoqi@0 | 2449 | } |
aoqi@0 | 2450 | JavaParameter javaParameter = |
aoqi@0 | 2451 | new JavaParameter( |
aoqi@0 | 2452 | name, |
aoqi@0 | 2453 | parameterType, |
aoqi@0 | 2454 | param, |
aoqi@0 | 2455 | param.isINOUT() || param.isOUT()); |
aoqi@0 | 2456 | if (javaParameter.isHolder()) { |
aoqi@0 | 2457 | javaParameter.setHolderName(javax.xml.ws.Holder.class.getName()); |
aoqi@0 | 2458 | } |
aoqi@0 | 2459 | method.addParameter(javaParameter); |
aoqi@0 | 2460 | param.setJavaParameter(javaParameter); |
aoqi@0 | 2461 | } |
aoqi@0 | 2462 | operation.setJavaMethod(method); |
aoqi@0 | 2463 | intf.addMethod(method); |
aoqi@0 | 2464 | |
aoqi@0 | 2465 | String opName = BindingHelper.mangleNameToVariableName(operation.getName().getLocalPart()); |
aoqi@0 | 2466 | for (Iterator iter = operation.getFaults(); |
aoqi@0 | 2467 | iter != null && iter.hasNext(); |
aoqi@0 | 2468 | ) { |
aoqi@0 | 2469 | Fault fault = (Fault) iter.next(); |
aoqi@0 | 2470 | createJavaExceptionFromLiteralType(fault, port, opName); |
aoqi@0 | 2471 | } |
aoqi@0 | 2472 | JavaException javaException; |
aoqi@0 | 2473 | Fault fault; |
aoqi@0 | 2474 | for (Iterator iter = operation.getFaults(); iter.hasNext();) { |
aoqi@0 | 2475 | fault = (Fault) iter.next(); |
aoqi@0 | 2476 | javaException = fault.getJavaException(); |
aoqi@0 | 2477 | method.addException(javaException.getName()); |
aoqi@0 | 2478 | } |
aoqi@0 | 2479 | |
aoqi@0 | 2480 | } |
aoqi@0 | 2481 | |
aoqi@0 | 2482 | protected boolean createJavaExceptionFromLiteralType(Fault fault, com.sun.tools.internal.ws.processor.model.Port port, String operationName) { |
aoqi@0 | 2483 | JAXBType faultType = (JAXBType) fault.getBlock().getType(); |
aoqi@0 | 2484 | |
aoqi@0 | 2485 | String exceptionName = fault.getName(); |
aoqi@0 | 2486 | |
aoqi@0 | 2487 | // use fault namespace attribute |
aoqi@0 | 2488 | JAXBStructuredType jaxbStruct = new JAXBStructuredType(new QName( |
aoqi@0 | 2489 | fault.getBlock().getName().getNamespaceURI(), |
aoqi@0 | 2490 | fault.getName())); |
aoqi@0 | 2491 | |
aoqi@0 | 2492 | QName memberName = fault.getElementName(); |
aoqi@0 | 2493 | JAXBElementMember jaxbMember = |
aoqi@0 | 2494 | new JAXBElementMember(memberName, faultType); |
aoqi@0 | 2495 | //jaxbMember.setNillable(faultType.isNillable()); |
aoqi@0 | 2496 | |
aoqi@0 | 2497 | String javaMemberName = getLiteralJavaMemberName(fault); |
aoqi@0 | 2498 | JavaStructureMember javaMember = new JavaStructureMember( |
aoqi@0 | 2499 | javaMemberName, |
aoqi@0 | 2500 | faultType.getJavaType(), |
aoqi@0 | 2501 | jaxbMember); |
aoqi@0 | 2502 | jaxbMember.setJavaStructureMember(javaMember); |
aoqi@0 | 2503 | javaMember.setReadMethod(Names.getJavaMemberReadMethod(javaMember)); |
aoqi@0 | 2504 | javaMember.setInherited(false); |
aoqi@0 | 2505 | jaxbMember.setJavaStructureMember(javaMember); |
aoqi@0 | 2506 | jaxbStruct.add(jaxbMember); |
aoqi@0 | 2507 | |
aoqi@0 | 2508 | if (isConflictingExceptionClassName(exceptionName)) { |
aoqi@0 | 2509 | exceptionName += "_Exception"; |
aoqi@0 | 2510 | } |
aoqi@0 | 2511 | |
aoqi@0 | 2512 | JavaException existingJavaException = _javaExceptions.get(exceptionName); |
aoqi@0 | 2513 | if (existingJavaException != null) { |
aoqi@0 | 2514 | if (existingJavaException.getName().equals(exceptionName)) { |
aoqi@0 | 2515 | if (((JAXBType) existingJavaException.getOwner()).getName().equals(jaxbStruct.getName()) |
aoqi@0 | 2516 | || ModelerUtils.isEquivalentLiteralStructures(jaxbStruct, (JAXBStructuredType) existingJavaException.getOwner())) { |
aoqi@0 | 2517 | // we have mapped this fault already |
aoqi@0 | 2518 | if (faultType instanceof JAXBStructuredType) { |
aoqi@0 | 2519 | fault.getBlock().setType((JAXBType) existingJavaException.getOwner()); |
aoqi@0 | 2520 | } |
aoqi@0 | 2521 | fault.setJavaException(existingJavaException); |
aoqi@0 | 2522 | return false; |
aoqi@0 | 2523 | } |
aoqi@0 | 2524 | } |
aoqi@0 | 2525 | } |
aoqi@0 | 2526 | |
aoqi@0 | 2527 | JavaException javaException = new JavaException(exceptionName, false, jaxbStruct); |
aoqi@0 | 2528 | javaException.add(javaMember); |
aoqi@0 | 2529 | jaxbStruct.setJavaType(javaException); |
aoqi@0 | 2530 | |
aoqi@0 | 2531 | _javaExceptions.put(javaException.getName(), javaException); |
aoqi@0 | 2532 | |
aoqi@0 | 2533 | fault.setJavaException(javaException); |
aoqi@0 | 2534 | return true; |
aoqi@0 | 2535 | } |
aoqi@0 | 2536 | |
aoqi@0 | 2537 | protected boolean isRequestResponse() { |
aoqi@0 | 2538 | return info.portTypeOperation.getStyle() == OperationStyle.REQUEST_RESPONSE; |
aoqi@0 | 2539 | } |
aoqi@0 | 2540 | |
aoqi@0 | 2541 | protected java.util.List<String> getAsynParameterOrder() { |
aoqi@0 | 2542 | //for async operation ignore the parameterOrder |
aoqi@0 | 2543 | java.util.List<String> parameterList = new ArrayList<String>(); |
aoqi@0 | 2544 | Message inputMessage = getInputMessage(); |
aoqi@0 | 2545 | List<MessagePart> inputParts = inputMessage.getParts(); |
aoqi@0 | 2546 | for (MessagePart part : inputParts) { |
aoqi@0 | 2547 | parameterList.add(part.getName()); |
aoqi@0 | 2548 | } |
aoqi@0 | 2549 | return parameterList; |
aoqi@0 | 2550 | } |
aoqi@0 | 2551 | |
aoqi@0 | 2552 | |
aoqi@0 | 2553 | protected List<MessagePart> getParameterOrder() { |
aoqi@0 | 2554 | List<MessagePart> params = new ArrayList<MessagePart>(); |
aoqi@0 | 2555 | String parameterOrder = info.portTypeOperation.getParameterOrder(); |
aoqi@0 | 2556 | java.util.List<String> parameterList; |
aoqi@0 | 2557 | boolean parameterOrderPresent = false; |
aoqi@0 | 2558 | if ((parameterOrder != null) && !(parameterOrder.trim().equals(""))) { |
aoqi@0 | 2559 | parameterList = XmlUtil.parseTokenList(parameterOrder); |
aoqi@0 | 2560 | parameterOrderPresent = true; |
aoqi@0 | 2561 | } else { |
aoqi@0 | 2562 | parameterList = new ArrayList<String>(); |
aoqi@0 | 2563 | } |
aoqi@0 | 2564 | Message inputMessage = getInputMessage(); |
aoqi@0 | 2565 | Message outputMessage = getOutputMessage(); |
aoqi@0 | 2566 | List<MessagePart> outputParts = null; |
aoqi@0 | 2567 | List<MessagePart> inputParts = inputMessage.getParts(); |
aoqi@0 | 2568 | //reset the mode and ret flag, as MEssagePArts aer shared across ports |
aoqi@0 | 2569 | for (MessagePart part : inputParts) { |
aoqi@0 | 2570 | part.setMode(Mode.IN); |
aoqi@0 | 2571 | part.setReturn(false); |
aoqi@0 | 2572 | } |
aoqi@0 | 2573 | if (isRequestResponse()) { |
aoqi@0 | 2574 | outputParts = outputMessage.getParts(); |
aoqi@0 | 2575 | for (MessagePart part : outputParts) { |
aoqi@0 | 2576 | part.setMode(Mode.OUT); |
aoqi@0 | 2577 | part.setReturn(false); |
aoqi@0 | 2578 | } |
aoqi@0 | 2579 | } |
aoqi@0 | 2580 | |
aoqi@0 | 2581 | if (parameterOrderPresent) { |
aoqi@0 | 2582 | boolean validParameterOrder = true; |
aoqi@0 | 2583 | Iterator<String> paramOrders = parameterList.iterator(); |
aoqi@0 | 2584 | // If any part in the parameterOrder is not present in the request or |
aoqi@0 | 2585 | // response message, we completely ignore the parameterOrder hint |
aoqi@0 | 2586 | while (paramOrders.hasNext()) { |
aoqi@0 | 2587 | String param = paramOrders.next(); |
aoqi@0 | 2588 | boolean partFound = false; |
aoqi@0 | 2589 | for (MessagePart part : inputParts) { |
aoqi@0 | 2590 | if (param.equals(part.getName())) { |
aoqi@0 | 2591 | partFound = true; |
aoqi@0 | 2592 | break; |
aoqi@0 | 2593 | } |
aoqi@0 | 2594 | } |
aoqi@0 | 2595 | // if not found, check in output parts |
aoqi@0 | 2596 | if (!partFound) { |
aoqi@0 | 2597 | for (MessagePart part : outputParts) { |
aoqi@0 | 2598 | if (param.equals(part.getName())) { |
aoqi@0 | 2599 | partFound = true; |
aoqi@0 | 2600 | break; |
aoqi@0 | 2601 | } |
aoqi@0 | 2602 | } |
aoqi@0 | 2603 | } |
aoqi@0 | 2604 | if (!partFound) { |
aoqi@0 | 2605 | warning(info.operation.getEntity(), ModelerMessages.WSDLMODELER_INVALID_PARAMETERORDER_PARAMETER(param, info.operation.getName().getLocalPart())); |
aoqi@0 | 2606 | validParameterOrder = false; |
aoqi@0 | 2607 | } |
aoqi@0 | 2608 | } |
aoqi@0 | 2609 | |
aoqi@0 | 2610 | List<MessagePart> inputUnlistedParts = new ArrayList<MessagePart>(); |
aoqi@0 | 2611 | List<MessagePart> outputUnlistedParts = new ArrayList<MessagePart>(); |
aoqi@0 | 2612 | |
aoqi@0 | 2613 | //gather input Parts |
aoqi@0 | 2614 | if (validParameterOrder) { |
aoqi@0 | 2615 | for (String param : parameterList) { |
aoqi@0 | 2616 | MessagePart part = inputMessage.getPart(param); |
aoqi@0 | 2617 | if (part != null) { |
aoqi@0 | 2618 | params.add(part); |
aoqi@0 | 2619 | continue; |
aoqi@0 | 2620 | } |
aoqi@0 | 2621 | if (isRequestResponse()) { |
aoqi@0 | 2622 | MessagePart outPart = outputMessage.getPart(param); |
aoqi@0 | 2623 | if (outPart != null) { |
aoqi@0 | 2624 | params.add(outPart); |
aoqi@0 | 2625 | } |
aoqi@0 | 2626 | } |
aoqi@0 | 2627 | } |
aoqi@0 | 2628 | |
aoqi@0 | 2629 | for (MessagePart part : inputParts) { |
aoqi@0 | 2630 | if (!parameterList.contains(part.getName())) { |
aoqi@0 | 2631 | inputUnlistedParts.add(part); |
aoqi@0 | 2632 | } |
aoqi@0 | 2633 | } |
aoqi@0 | 2634 | |
aoqi@0 | 2635 | if (isRequestResponse()) { |
aoqi@0 | 2636 | // at most one output part should be unlisted |
aoqi@0 | 2637 | for (MessagePart part : outputParts) { |
aoqi@0 | 2638 | if (!parameterList.contains(part.getName())) { |
aoqi@0 | 2639 | MessagePart inPart = inputMessage.getPart(part.getName()); |
aoqi@0 | 2640 | //dont add inout as unlisted part |
aoqi@0 | 2641 | if ((inPart != null) && inPart.getDescriptor().equals(part.getDescriptor())) { |
aoqi@0 | 2642 | inPart.setMode(Mode.INOUT); |
aoqi@0 | 2643 | } else { |
aoqi@0 | 2644 | outputUnlistedParts.add(part); |
aoqi@0 | 2645 | } |
aoqi@0 | 2646 | } else { |
aoqi@0 | 2647 | //param list may contain it, check if its INOUT |
aoqi@0 | 2648 | MessagePart inPart = inputMessage.getPart(part.getName()); |
aoqi@0 | 2649 | //dont add inout as unlisted part |
aoqi@0 | 2650 | if ((inPart != null) && inPart.getDescriptor().equals(part.getDescriptor())) { |
aoqi@0 | 2651 | inPart.setMode(Mode.INOUT); |
aoqi@0 | 2652 | } else if (!params.contains(part)) { |
aoqi@0 | 2653 | params.add(part); |
aoqi@0 | 2654 | } |
aoqi@0 | 2655 | } |
aoqi@0 | 2656 | } |
aoqi@0 | 2657 | if (outputUnlistedParts.size() == 1) { |
aoqi@0 | 2658 | MessagePart resultPart = outputUnlistedParts.get(0); |
aoqi@0 | 2659 | resultPart.setReturn(true); |
aoqi@0 | 2660 | params.add(resultPart); |
aoqi@0 | 2661 | outputUnlistedParts.clear(); |
aoqi@0 | 2662 | } |
aoqi@0 | 2663 | } |
aoqi@0 | 2664 | |
aoqi@0 | 2665 | //add the input and output unlisted parts |
aoqi@0 | 2666 | for (MessagePart part : inputUnlistedParts) { |
aoqi@0 | 2667 | params.add(part); |
aoqi@0 | 2668 | } |
aoqi@0 | 2669 | |
aoqi@0 | 2670 | for (MessagePart part : outputUnlistedParts) { |
aoqi@0 | 2671 | params.add(part); |
aoqi@0 | 2672 | } |
aoqi@0 | 2673 | return params; |
aoqi@0 | 2674 | |
aoqi@0 | 2675 | } |
aoqi@0 | 2676 | //parameterOrder attribute is not valid, we ignore it |
aoqi@0 | 2677 | warning(info.operation.getEntity(), ModelerMessages.WSDLMODELER_INVALID_PARAMETER_ORDER_INVALID_PARAMETER_ORDER(info.operation.getName().getLocalPart())); |
aoqi@0 | 2678 | parameterList.clear(); |
aoqi@0 | 2679 | } |
aoqi@0 | 2680 | |
aoqi@0 | 2681 | List<MessagePart> outParts = new ArrayList<MessagePart>(); |
aoqi@0 | 2682 | |
aoqi@0 | 2683 | //construct input parameter list with the same order as in input message |
aoqi@0 | 2684 | for (MessagePart part : inputParts) { |
aoqi@0 | 2685 | params.add(part); |
aoqi@0 | 2686 | } |
aoqi@0 | 2687 | |
aoqi@0 | 2688 | if (isRequestResponse()) { |
aoqi@0 | 2689 | for (MessagePart part : outputParts) { |
aoqi@0 | 2690 | MessagePart inPart = inputMessage.getPart(part.getName()); |
aoqi@0 | 2691 | if (inPart != null && part.getDescriptorKind() == inPart.getDescriptorKind() && |
aoqi@0 | 2692 | part.getDescriptor().equals(inPart.getDescriptor())) { |
aoqi@0 | 2693 | inPart.setMode(Mode.INOUT); |
aoqi@0 | 2694 | continue; |
aoqi@0 | 2695 | } |
aoqi@0 | 2696 | outParts.add(part); |
aoqi@0 | 2697 | } |
aoqi@0 | 2698 | |
aoqi@0 | 2699 | //append the out parts to the parameterList |
aoqi@0 | 2700 | for (MessagePart part : outParts) { |
aoqi@0 | 2701 | if (outParts.size() == 1) { |
aoqi@0 | 2702 | part.setReturn(true); |
aoqi@0 | 2703 | } |
aoqi@0 | 2704 | params.add(part); |
aoqi@0 | 2705 | } |
aoqi@0 | 2706 | } |
aoqi@0 | 2707 | return params; |
aoqi@0 | 2708 | } |
aoqi@0 | 2709 | |
aoqi@0 | 2710 | /** |
aoqi@0 | 2711 | * @param port |
aoqi@0 | 2712 | * @param suffix |
aoqi@0 | 2713 | * @return the Java ClassName for a port |
aoqi@0 | 2714 | */ |
aoqi@0 | 2715 | protected String getClassName(Port port, String suffix) { |
aoqi@0 | 2716 | String prefix = BindingHelper.mangleNameToClassName((port.getName().getLocalPart())); |
aoqi@0 | 2717 | return options.defaultPackage + "." + prefix + suffix; |
aoqi@0 | 2718 | } |
aoqi@0 | 2719 | |
aoqi@0 | 2720 | @Override |
aoqi@0 | 2721 | protected boolean isConflictingServiceClassName(String name) { |
aoqi@0 | 2722 | return conflictsWithSEIClass(name) || conflictsWithJAXBClass(name) || conflictsWithExceptionClass(name); |
aoqi@0 | 2723 | } |
aoqi@0 | 2724 | |
aoqi@0 | 2725 | private boolean conflictsWithSEIClass(String name) { |
aoqi@0 | 2726 | Set<String> seiNames = classNameCollector.getSeiClassNames(); |
aoqi@0 | 2727 | return seiNames != null && seiNames.contains(name); |
aoqi@0 | 2728 | } |
aoqi@0 | 2729 | |
aoqi@0 | 2730 | private boolean conflictsWithJAXBClass(String name) { |
aoqi@0 | 2731 | Set<String> jaxbNames = classNameCollector.getJaxbGeneratedClassNames(); |
aoqi@0 | 2732 | return jaxbNames != null && jaxbNames.contains(name); |
aoqi@0 | 2733 | } |
aoqi@0 | 2734 | |
aoqi@0 | 2735 | private boolean conflictsWithExceptionClass(String name) { |
aoqi@0 | 2736 | Set<String> exceptionNames = classNameCollector.getExceptionClassNames(); |
aoqi@0 | 2737 | return exceptionNames != null && exceptionNames.contains(name); |
aoqi@0 | 2738 | } |
aoqi@0 | 2739 | |
aoqi@0 | 2740 | @Override |
aoqi@0 | 2741 | protected boolean isConflictingExceptionClassName(String name) { |
aoqi@0 | 2742 | return conflictsWithSEIClass(name) || conflictsWithJAXBClass(name); |
aoqi@0 | 2743 | } |
aoqi@0 | 2744 | |
aoqi@0 | 2745 | protected JAXBModelBuilder getJAXBModelBuilder() { |
aoqi@0 | 2746 | return jaxbModelBuilder; |
aoqi@0 | 2747 | } |
aoqi@0 | 2748 | |
aoqi@0 | 2749 | protected boolean validateWSDLBindingStyle(Binding binding) { |
aoqi@0 | 2750 | SOAPBinding soapBinding = |
aoqi@0 | 2751 | (SOAPBinding) getExtensionOfType(binding, SOAPBinding.class); |
aoqi@0 | 2752 | |
aoqi@0 | 2753 | //dont process the binding |
aoqi@0 | 2754 | if (soapBinding == null) { |
aoqi@0 | 2755 | soapBinding = (SOAPBinding) getExtensionOfType(binding, SOAP12Binding.class); |
aoqi@0 | 2756 | } |
aoqi@0 | 2757 | if (soapBinding == null) { |
aoqi@0 | 2758 | return false; |
aoqi@0 | 2759 | } |
aoqi@0 | 2760 | |
aoqi@0 | 2761 | //if soapbind:binding has no style attribute, the default is DOCUMENT |
aoqi@0 | 2762 | if (soapBinding.getStyle() == null) { |
aoqi@0 | 2763 | soapBinding.setStyle(SOAPStyle.DOCUMENT); |
aoqi@0 | 2764 | } |
aoqi@0 | 2765 | |
aoqi@0 | 2766 | SOAPStyle opStyle = soapBinding.getStyle(); |
aoqi@0 | 2767 | for (Iterator iter = binding.operations(); iter.hasNext();) { |
aoqi@0 | 2768 | BindingOperation bindingOperation = |
aoqi@0 | 2769 | (BindingOperation) iter.next(); |
aoqi@0 | 2770 | SOAPOperation soapOperation = |
aoqi@0 | 2771 | (SOAPOperation) getExtensionOfType(bindingOperation, |
aoqi@0 | 2772 | SOAPOperation.class); |
aoqi@0 | 2773 | if (soapOperation != null) { |
aoqi@0 | 2774 | SOAPStyle currOpStyle = (soapOperation.getStyle() != null) ? soapOperation.getStyle() : soapBinding.getStyle(); |
aoqi@0 | 2775 | //dont check for the first operation |
aoqi@0 | 2776 | if (!currOpStyle.equals(opStyle)) { |
aoqi@0 | 2777 | return false; |
aoqi@0 | 2778 | } |
aoqi@0 | 2779 | } |
aoqi@0 | 2780 | } |
aoqi@0 | 2781 | return true; |
aoqi@0 | 2782 | } |
aoqi@0 | 2783 | |
aoqi@0 | 2784 | /** |
aoqi@0 | 2785 | * @param port |
aoqi@0 | 2786 | */ |
aoqi@0 | 2787 | private void applyWrapperStyleCustomization(Port port, PortType portType) { |
aoqi@0 | 2788 | JAXWSBinding jaxwsBinding = (JAXWSBinding) getExtensionOfType(portType, JAXWSBinding.class); |
aoqi@0 | 2789 | Boolean wrapperStyle = (jaxwsBinding != null) ? jaxwsBinding.isEnableWrapperStyle() : null; |
aoqi@0 | 2790 | if (wrapperStyle != null) { |
aoqi@0 | 2791 | port.setWrapped(wrapperStyle); |
aoqi@0 | 2792 | } |
aoqi@0 | 2793 | } |
aoqi@0 | 2794 | |
aoqi@0 | 2795 | protected static void setDocumentationIfPresent( |
aoqi@0 | 2796 | ModelObject obj, |
aoqi@0 | 2797 | Documentation documentation) { |
aoqi@0 | 2798 | if (documentation != null && documentation.getContent() != null) { |
aoqi@0 | 2799 | obj.setJavaDoc(documentation.getContent()); |
aoqi@0 | 2800 | } |
aoqi@0 | 2801 | } |
aoqi@0 | 2802 | |
aoqi@0 | 2803 | protected String getJavaNameForOperation(Operation operation) { |
aoqi@0 | 2804 | String name = operation.getJavaMethodName(); |
aoqi@0 | 2805 | if (Names.isJavaReservedWord(name)) { |
aoqi@0 | 2806 | name = "_" + name; |
aoqi@0 | 2807 | } |
aoqi@0 | 2808 | return name; |
aoqi@0 | 2809 | } |
aoqi@0 | 2810 | |
aoqi@0 | 2811 | private void reportError(Entity entity, |
aoqi@0 | 2812 | String formattedMsg, Exception nestedException ) { |
aoqi@0 | 2813 | Locator locator = (entity == null)?null:entity.getLocator(); |
aoqi@0 | 2814 | |
aoqi@0 | 2815 | SAXParseException e = new SAXParseException2( formattedMsg, |
aoqi@0 | 2816 | locator, |
aoqi@0 | 2817 | nestedException ); |
aoqi@0 | 2818 | errReceiver.error(e); |
aoqi@0 | 2819 | } |
aoqi@0 | 2820 | |
aoqi@0 | 2821 | } |