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