Source Code Cross Referenced for WSDL11ToAxisServiceBuilder.java in  » Web-Services-AXIS2 » kernal » org » apache » axis2 » description » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Services AXIS2 » kernal » org.apache.axis2.description 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Licensed to the Apache Software Foundation (ASF) under one
0003:         * or more contributor license agreements. See the NOTICE file
0004:         * distributed with this work for additional information
0005:         * regarding copyright ownership. The ASF licenses this file
0006:         * to you under the Apache License, Version 2.0 (the
0007:         * "License"); you may not use this file except in compliance
0008:         * with the License. You may obtain a copy of the License at
0009:         *
0010:         * http://www.apache.org/licenses/LICENSE-2.0
0011:         *
0012:         * Unless required by applicable law or agreed to in writing,
0013:         * software distributed under the License is distributed on an
0014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
0015:         * KIND, either express or implied. See the License for the
0016:         * specific language governing permissions and limitations
0017:         * under the License.
0018:         */
0019:        package org.apache.axis2.description;
0020:
0021:        import com.ibm.wsdl.util.xml.DOM2Writer;
0022:        import org.apache.axis2.AxisFault;
0023:        import org.apache.axis2.addressing.AddressingConstants;
0024:        import org.apache.axis2.addressing.AddressingHelper;
0025:        import org.apache.axis2.addressing.wsdl.WSDL11ActionHelper;
0026:        import org.apache.axis2.transport.http.HTTPConstants;
0027:        import org.apache.axis2.transport.http.util.RESTUtil;
0028:        import org.apache.axis2.util.PolicyUtil;
0029:        import org.apache.axis2.util.XMLUtils;
0030:        import org.apache.axis2.wsdl.SOAPHeaderMessage;
0031:        import org.apache.axis2.wsdl.WSDLConstants;
0032:        import org.apache.axis2.wsdl.WSDLUtil;
0033:        import org.apache.commons.logging.Log;
0034:        import org.apache.commons.logging.LogFactory;
0035:        import org.apache.neethi.Constants;
0036:        import org.apache.neethi.Policy;
0037:        import org.apache.neethi.PolicyReference;
0038:        import org.apache.ws.commons.schema.utils.NamespaceMap;
0039:        import org.apache.axiom.soap.SOAP12Constants;
0040:        import org.apache.axiom.soap.SOAP11Constants;
0041:        import org.w3c.dom.Document;
0042:        import org.w3c.dom.Element;
0043:        import org.w3c.dom.Node;
0044:        import org.xml.sax.SAXException;
0045:
0046:        import javax.wsdl.*;
0047:        import javax.wsdl.extensions.ExtensibilityElement;
0048:        import javax.wsdl.extensions.UnknownExtensibilityElement;
0049:        import javax.wsdl.extensions.mime.MIMEMultipartRelated;
0050:        import javax.wsdl.extensions.mime.MIMEPart;
0051:        import javax.wsdl.extensions.http.HTTPAddress;
0052:        import javax.wsdl.extensions.http.HTTPBinding;
0053:        import javax.wsdl.extensions.http.HTTPOperation;
0054:        import javax.wsdl.extensions.schema.Schema;
0055:        import javax.wsdl.extensions.soap.SOAPAddress;
0056:        import javax.wsdl.extensions.soap.SOAPBinding;
0057:        import javax.wsdl.extensions.soap.SOAPBody;
0058:        import javax.wsdl.extensions.soap.SOAPHeader;
0059:        import javax.wsdl.extensions.soap.SOAPOperation;
0060:        import javax.wsdl.extensions.soap12.SOAP12Address;
0061:        import javax.wsdl.extensions.soap12.SOAP12Binding;
0062:        import javax.wsdl.extensions.soap12.SOAP12Body;
0063:        import javax.wsdl.extensions.soap12.SOAP12Header;
0064:        import javax.wsdl.extensions.soap12.SOAP12Operation;
0065:        import javax.wsdl.factory.WSDLFactory;
0066:        import javax.wsdl.xml.WSDLLocator;
0067:        import javax.wsdl.xml.WSDLReader;
0068:        import javax.xml.namespace.QName;
0069:        import javax.xml.parsers.ParserConfigurationException;
0070:        import java.io.IOException;
0071:        import java.io.InputStream;
0072:        import java.util.*;
0073:
0074:        public class WSDL11ToAxisServiceBuilder extends
0075:                WSDLToAxisServiceBuilder {
0076:
0077:            protected static final Log log = LogFactory
0078:                    .getLog(WSDL11ToAxisServiceBuilder.class);
0079:            private static final boolean isTraceEnabled = log.isTraceEnabled();
0080:
0081:            protected String portName;
0082:
0083:            private static final String BINDING = "Binding";
0084:
0085:            private static final String SERVICE = "Service";
0086:
0087:            private static final String PORT = "Port";
0088:
0089:            private static final String PORT_TYPE = "PortType";
0090:
0091:            private static final String PORT_TYPE_OPERATION = "PortType.Operation";
0092:
0093:            private static final String PORT_TYPE_OPERATION_INPUT = "PortType.Operation.Input";
0094:
0095:            private static final String PORT_TYPE_OPERATION_OUTPUT = "PortType.Operation.Output";
0096:
0097:            private static final String PORT_TYPE_OPERATION_FAULT = "PortType.Operation.Fault";
0098:
0099:            private static final String BINDING_OPERATION = "Binding.Operation";
0100:
0101:            private static final String BINDING_OPERATION_INPUT = "Binding.Operation.Input";
0102:
0103:            private static final String BINDING_OPERATION_OUTPUT = "Binding.Operation.Output";
0104:
0105:            protected Definition wsdl4jDefinition = null;
0106:
0107:            private WSDLLocator customWSLD4JResolver;
0108:
0109:            public static final String RPC_STYLE = "rpc";
0110:
0111:            public static final String DOCUMENT_STYLE = "document";
0112:
0113:            public static final String ENCODED_USE = "encoded";
0114:
0115:            /**
0116:             * Keeps a list of processable operations initiate to an empty list
0117:             */
0118:            private List wrappableOperations = new ArrayList();
0119:            // used to keep the binding type of the selected binding
0120:            private String bindingType;
0121:
0122:            public static final String WRAPPED_OUTPUTNAME_SUFFIX = "Response";
0123:
0124:            public static final String XML_NAMESPACE_URI = "http://www.w3.org/2000/xmlns/";
0125:
0126:            public static final String NAMESPACE_DECLARATION_PREFIX = "xmlns:";
0127:
0128:            private static int prefixCounter = 0;
0129:
0130:            public static final String NAMESPACE_URI = "namespace";
0131:
0132:            public static final String TRAGET_NAMESPACE = "targetNamespace";
0133:
0134:            public static final String BINDING_TYPE_SOAP = "soap";
0135:            public static final String BINDING_TYPE_HTTP = "http";
0136:
0137:            /**
0138:             * keep track of whether setup code related to the entire wsdl is complete.
0139:             * Note that WSDL11ToAllAxisServices will call setup multiple times, so this
0140:             * field is used to make subsequent calls no-ops.
0141:             */
0142:            private boolean setupComplete = false;
0143:
0144:            private Map schemaMap = null;
0145:
0146:            private static final String JAVAX_WSDL_VERBOSE_MODE_KEY = "javax.wsdl.verbose";
0147:
0148:            // As bindings are processed add it to this array so that we dont process the same binding twice
0149:            private Map processedBindings;
0150:
0151:            private boolean isAllPorts;
0152:
0153:            /**
0154:             * constructor taking in the service name and the port name
0155:             *
0156:             * @param in
0157:             * @param serviceName
0158:             * @param portName
0159:             */
0160:            public WSDL11ToAxisServiceBuilder(InputStream in,
0161:                    QName serviceName, String portName) {
0162:                super (in, serviceName);
0163:                this .portName = portName;
0164:            }
0165:
0166:            /**
0167:             * @param def
0168:             * @param serviceName
0169:             * @param portName
0170:             */
0171:            public WSDL11ToAxisServiceBuilder(Definition def,
0172:                    QName serviceName, String portName) {
0173:                super (null, serviceName);
0174:                this .wsdl4jDefinition = def;
0175:                this .portName = portName;
0176:                this .isAllPorts = false;
0177:            }
0178:
0179:            /**
0180:             * @param def
0181:             * @param serviceName
0182:             * @param portName
0183:             */
0184:            public WSDL11ToAxisServiceBuilder(Definition def,
0185:                    QName serviceName, String portName, boolean isAllPorts) {
0186:                this (def, serviceName, portName);
0187:                this .isAllPorts = isAllPorts;
0188:            }
0189:
0190:            /**
0191:             * @param in
0192:             * @param service
0193:             */
0194:            public WSDL11ToAxisServiceBuilder(InputStream in,
0195:                    AxisService service) {
0196:                super (in, service);
0197:            }
0198:
0199:            /**
0200:             * @param in
0201:             */
0202:            public WSDL11ToAxisServiceBuilder(InputStream in) {
0203:                this (in, null, null);
0204:            }
0205:
0206:            /**
0207:             * sets a custem WSDL4J locator
0208:             *
0209:             * @param customWSLD4JResolver
0210:             */
0211:            public void setCustomWSLD4JResolver(WSDLLocator customWSLD4JResolver) {
0212:                this .customWSLD4JResolver = customWSLD4JResolver;
0213:            }
0214:
0215:            /**
0216:             * populates a given service This is the only publicly accessible method in
0217:             * this class
0218:             *
0219:             * @throws AxisFault
0220:             */
0221:            public AxisService populateService() throws AxisFault {
0222:                try {
0223:                    setup();
0224:                    // Setting wsdl4jdefintion to axisService , so if some one want
0225:                    // to play with it he can do that by getting the parameter
0226:                    Parameter wsdlDefinitionParameter = new Parameter();
0227:                    wsdlDefinitionParameter
0228:                            .setName(WSDLConstants.WSDL_4_J_DEFINITION);
0229:                    wsdlDefinitionParameter.setValue(wsdl4jDefinition);
0230:                    axisService.addParameter(wsdlDefinitionParameter);
0231:                    axisService.setWsdlFound(true);
0232:                    axisService.setCustomWsdl(true);
0233:
0234:                    if (wsdl4jDefinition == null) {
0235:                        return null;
0236:                    }
0237:
0238:                    // setting target name space
0239:                    axisService.setTargetNamespace(wsdl4jDefinition
0240:                            .getTargetNamespace());
0241:                    axisService.setNameSpacesMap(new NamespaceMap(
0242:                            wsdl4jDefinition.getNamespaces()));
0243:
0244:                    Service wsdl4jService = findService(wsdl4jDefinition);
0245:                    Binding binding = findBinding(wsdl4jDefinition,
0246:                            wsdl4jService);
0247:
0248:                    PortType portType = getPortType(binding.getPortType()
0249:                            .getQName(), wsdl4jDefinition);
0250:
0251:                    if (portType == null) {
0252:                        throw new AxisFault(
0253:                                "There is no port type associated with the binding");
0254:                    }
0255:
0256:                    // create new Schema extensions element for wrapping
0257:                    // (if its present)
0258:                    Element[] schemaElements = generateWrapperSchema(schemaMap,
0259:                            binding, portType);
0260:
0261:                    // we might have modified the schemas by now so the addition should
0262:                    // happen here
0263:                    //            Types wsdl4jTypes = wsdl4jDefinition.getTypes();
0264:                    //            if (null != wsdl4jTypes) {
0265:                    //                this.copyExtensibleElements(wsdl4jTypes
0266:                    //                        .getExtensibilityElements(), wsdl4jDefinition,
0267:                    //                                                     axisService, TYPES);
0268:                    //            }
0269:                    processTypes(wsdl4jDefinition, axisService);
0270:
0271:                    // add the newly created schemas
0272:                    if (schemaElements != null && schemaElements.length > 0) {
0273:                        for (int i = 0; i < schemaElements.length; i++) {
0274:                            Element schemaElement = schemaElements[i];
0275:                            if (schemaElement != null) {
0276:                                axisService.addSchema(getXMLSchema(
0277:                                        schemaElement, null));
0278:                            }
0279:                        }
0280:                    }
0281:                    // copy the documentation element content to the description
0282:                    Element documentationElement = wsdl4jDefinition
0283:                            .getDocumentationElement();
0284:                    addDocumentation(axisService, documentationElement);
0285:
0286:                    axisService
0287:                            .setName(wsdl4jService.getQName().getLocalPart());
0288:                    populateEndpoints(binding, wsdl4jService, portType);
0289:                    processPoliciesInDefintion(wsdl4jDefinition);
0290:                    axisService.getPolicyInclude().setPolicyRegistry(registry);
0291:                    return axisService;
0292:
0293:                } catch (WSDLException e) {
0294:                    log.error(e.getMessage(), e);
0295:                    throw AxisFault.makeFault(e);
0296:                } catch (Exception e) {
0297:                    log.error(e.getMessage(), e);
0298:                    throw AxisFault.makeFault(e);
0299:                }
0300:            }
0301:
0302:            private void processTypes(Definition wsdlDefinition,
0303:                    AxisService axisService) throws AxisFault {
0304:                processTypes(wsdlDefinition, axisService, new Stack());
0305:            }
0306:
0307:            private void processTypes(Definition wsdlDefinition,
0308:                    AxisService axisService, Stack stack) throws AxisFault {
0309:                stack.push(wsdlDefinition);
0310:                // process all the types in all the wsdls
0311:                Types types = wsdlDefinition.getTypes();
0312:                if (types != null) {
0313:                    copyExtensibleElements(types.getExtensibilityElements(),
0314:                            wsdlDefinition, axisService, TYPES);
0315:                }
0316:
0317:                // process the types in other wsdls
0318:                Iterator iter = wsdlDefinition.getImports().values().iterator();
0319:                Vector values = null;
0320:                Import wsdlImport = null;
0321:                for (; iter.hasNext();) {
0322:                    values = (Vector) iter.next();
0323:                    for (Iterator valuesIter = values.iterator(); valuesIter
0324:                            .hasNext();) {
0325:                        wsdlImport = (Import) valuesIter.next();
0326:                        // process the types recuresiveilt
0327:                        Definition innerDefinition = wsdlImport.getDefinition();
0328:                        if (!stack.contains(innerDefinition)) {
0329:                            processTypes(innerDefinition, axisService, stack);
0330:                        }
0331:                    }
0332:                }
0333:                stack.pop();
0334:            }
0335:
0336:            private void addDocumentation(AxisDescription axisDescription,
0337:                    Element documentationElement) {
0338:                if ((documentationElement != null)
0339:                        && (documentationElement.getFirstChild() != null)) {
0340:                    Node firstChild = documentationElement.getFirstChild();
0341:                    String documentation = DOM2Writer.nodeToString(firstChild);
0342:                    if (!"".equals(documentation)) {
0343:                        axisDescription.setDocumentation(documentation);
0344:                    }
0345:                }
0346:            }
0347:
0348:            /**
0349:             * @param binding
0350:             * @param wsdl4jService must have atlease one port
0351:             * @throws AxisFault
0352:             */
0353:            private void populateEndpoints(Binding binding,
0354:                    Service wsdl4jService, PortType portType) throws AxisFault {
0355:
0356:                Map wsdl4jPorts = wsdl4jService.getPorts();
0357:                QName bindingName = binding.getQName();
0358:
0359:                Port port;
0360:                AxisEndpoint axisEndpoint = null;
0361:
0362:                processedBindings = new HashMap();
0363:
0364:                // process the port type for this binding
0365:                // although we support multiports they must be belongs to same port type and should have the
0366:                // same soap style
0367:                populatePortType(portType);
0368:
0369:                Binding currentBinding;
0370:
0371:                for (Iterator iterator = wsdl4jPorts.values().iterator(); iterator
0372:                        .hasNext();) {
0373:                    port = (Port) iterator.next();
0374:                    // if the user has picked a port then we have to process only that port
0375:                    if ((this .portName == null)
0376:                            || (this .portName.equals(port.getName()))) {
0377:                        // we process the port only if it has the same port type as the selected binding
0378:                        currentBinding = getBinding(port.getBinding()
0379:                                .getQName(), wsdl4jDefinition);
0380:
0381:                        if (currentBinding.getPortType().getQName().equals(
0382:                                binding.getPortType().getQName())) {
0383:                            axisEndpoint = new AxisEndpoint();
0384:                            axisEndpoint.setName(port.getName());
0385:
0386:                            if (axisService.getEndpointName() == null
0387:                                    && bindingName.equals(port.getBinding()
0388:                                            .getQName())) {
0389:                                populateEndpoint(axisEndpoint, port, true);
0390:                                axisService.setEndpointName(axisEndpoint
0391:                                        .getName());
0392:                                axisService.setBindingName(axisEndpoint
0393:                                        .getBinding().getName().getLocalPart());
0394:                            } else {
0395:                                populateEndpoint(axisEndpoint, port, false);
0396:                            }
0397:
0398:                            axisEndpoint.setParent(axisService);
0399:                            axisService.addEndpoint(port.getName(),
0400:                                    axisEndpoint);
0401:                        }
0402:                    }
0403:                }
0404:            }
0405:
0406:            /**
0407:             * setting message qname is a binding dependent process for an example message element depends on the
0408:             * soap style (rpc or document) and parts elememet of the soap body
0409:             * On the otherhand we keep only one set of axis operations belongs to a selected port type in axis service
0410:             * So setting qname refetences done only with the selected binding processing
0411:             *
0412:             * @param axisEndpoint
0413:             * @param wsdl4jPort
0414:             * @param isSetMessageQNames
0415:             * @throws AxisFault
0416:             */
0417:            private void populateEndpoint(AxisEndpoint axisEndpoint,
0418:                    Port wsdl4jPort, boolean isSetMessageQNames)
0419:                    throws AxisFault {
0420:
0421:                copyExtensibleElements(wsdl4jPort.getExtensibilityElements(),
0422:                        wsdl4jDefinition, axisEndpoint, BINDING);
0423:
0424:                Binding wsdl4jBinding = getBinding(wsdl4jPort.getBinding()
0425:                        .getQName(), wsdl4jDefinition);
0426:
0427:                addDocumentation(axisEndpoint, wsdl4jPort
0428:                        .getDocumentationElement());
0429:                if (processedBindings.containsKey(wsdl4jBinding.getQName())) {
0430:                    axisEndpoint.setBinding((AxisBinding) processedBindings
0431:                            .get(wsdl4jBinding.getQName()));
0432:                } else {
0433:                    AxisBinding axisBinding = new AxisBinding();
0434:                    axisBinding.setName(wsdl4jBinding.getQName());
0435:                    axisBinding.setParent(axisEndpoint);
0436:                    axisEndpoint.setBinding(axisBinding);
0437:                    axisBinding.setParent(axisEndpoint);
0438:                    populateBinding(axisBinding, wsdl4jBinding,
0439:                            isSetMessageQNames);
0440:                    processedBindings
0441:                            .put(wsdl4jBinding.getQName(), axisBinding);
0442:                }
0443:
0444:            }
0445:
0446:            private void populatePortType(PortType wsdl4jPortType)
0447:                    throws AxisFault {
0448:                List wsdl4jOperations = wsdl4jPortType.getOperations();
0449:
0450:                // Added to use in ?wsdl2 as the interface name
0451:                axisService.addParameter(new Parameter(
0452:                        WSDL2Constants.INTERFACE_LOCAL_NAME, wsdl4jPortType
0453:                                .getQName().getLocalPart()));
0454:                if (wsdl4jOperations.size() < 1) {
0455:                    throw new AxisFault(
0456:                            "No operation found in the portType element");
0457:                }
0458:
0459:                AxisOperation axisOperation;
0460:                List operationNames = new ArrayList();
0461:
0462:                QName opName;
0463:                Operation wsdl4jOperation;
0464:
0465:                for (Iterator iterator = wsdl4jOperations.iterator(); iterator
0466:                        .hasNext();) {
0467:                    wsdl4jOperation = (Operation) iterator.next();
0468:
0469:                    axisOperation = populateOperations(wsdl4jOperation,
0470:                            wsdl4jPortType, wsdl4jDefinition);
0471:                    addDocumentation(axisOperation, wsdl4jOperation
0472:                            .getDocumentationElement());
0473:                    axisOperation.setParent(axisService);
0474:                    axisService.addChild(axisOperation);
0475:                    operationNames.add(axisOperation.getName());
0476:                }
0477:
0478:                // this is used only in codegen to preserve operation order
0479:                if (isCodegen) {
0480:                    axisService.setOperationsNameList(operationNames);
0481:                }
0482:
0483:            }
0484:
0485:            private void populateBinding(AxisBinding axisBinding,
0486:                    Binding wsdl4jBinding, boolean isSetMessageQNames)
0487:                    throws AxisFault {
0488:
0489:                copyExtensibleElements(
0490:                        wsdl4jBinding.getExtensibilityElements(),
0491:                        wsdl4jDefinition, axisBinding, BINDING);
0492:
0493:                List wsdl4jBidingOperations = wsdl4jBinding
0494:                        .getBindingOperations();
0495:
0496:                if (wsdl4jBidingOperations.size() < 1) {
0497:                    throw new AxisFault("No operation found for the binding");
0498:                }
0499:
0500:                addDocumentation(axisBinding, wsdl4jBinding
0501:                        .getDocumentationElement());
0502:
0503:                AxisOperation axisOperation;
0504:                Operation wsdl4jOperation;
0505:
0506:                AxisBindingOperation axisBindingOperation;
0507:                BindingOperation wsdl4jBindingOperation;
0508:
0509:                Map httpLocationMap = new TreeMap();
0510:                String httpLocation = null;
0511:
0512:                PortType portType = getPortType(wsdl4jBinding.getPortType()
0513:                        .getQName(), wsdl4jDefinition);
0514:
0515:                String targetNamespace = wsdl4jDefinition.getTargetNamespace();
0516:
0517:                for (Iterator iterator = wsdl4jBidingOperations.iterator(); iterator
0518:                        .hasNext();) {
0519:
0520:                    axisBindingOperation = new AxisBindingOperation();
0521:                    wsdl4jBindingOperation = (BindingOperation) iterator.next();
0522:                    wsdl4jOperation = findOperation(portType,
0523:                            wsdl4jBindingOperation);
0524:
0525:                    axisBindingOperation.setName(new QName(targetNamespace,
0526:                            wsdl4jBindingOperation.getName()));
0527:                    addDocumentation(axisBindingOperation,
0528:                            wsdl4jBindingOperation.getDocumentationElement());
0529:
0530:                    axisOperation = axisService.getOperation(new QName(
0531:                            targetNamespace, wsdl4jOperation.getName()));
0532:                    axisBindingOperation.setAxisOperation(axisOperation);
0533:
0534:                    // process ExtensibilityElements of the wsdl4jBinding
0535:                    copyExtensibleElements(wsdl4jBindingOperation
0536:                            .getExtensibilityElements(), wsdl4jDefinition,
0537:                            axisBindingOperation, BINDING_OPERATION);
0538:
0539:                    httpLocation = (String) axisBindingOperation
0540:                            .getProperty(WSDL2Constants.ATTR_WHTTP_LOCATION);
0541:                    if (httpLocation != null) {
0542:                        httpLocationMap.put(RESTUtil
0543:                                .getConstantFromHTTPLocation(httpLocation),
0544:                                axisBindingOperation.getAxisOperation());
0545:                    }
0546:
0547:                    BindingInput wsdl4jBindingInput = wsdl4jBindingOperation
0548:                            .getBindingInput();
0549:
0550:                    if (wsdl4jBindingInput != null
0551:                            && WSDLUtil.isInputPresentForMEP(axisOperation
0552:                                    .getMessageExchangePattern())) {
0553:                        AxisBindingMessage axisBindingInMessage = new AxisBindingMessage();
0554:                        addDocumentation(axisBindingInMessage,
0555:                                wsdl4jBindingInput.getDocumentationElement());
0556:                        copyExtensibleElements(wsdl4jBindingInput
0557:                                .getExtensibilityElements(), wsdl4jDefinition,
0558:                                axisBindingInMessage, BINDING_OPERATION_INPUT);
0559:
0560:                        AxisMessage axisInMessage = axisOperation
0561:                                .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
0562:                        //This is a hack to get AXIS2-2771 working , I had to copy soap headers
0563:                        //  from binding message to AxisMessage
0564:                        List soapHeaders = (List) axisBindingInMessage
0565:                                .getProperty(WSDL2Constants.ATTR_WSOAP_HEADER);
0566:                        if (soapHeaders != null) {
0567:                            for (int i = 0; i < soapHeaders.size(); i++) {
0568:                                SOAPHeaderMessage headerMessage = (SOAPHeaderMessage) soapHeaders
0569:                                        .get(i);
0570:                                axisInMessage.addSoapHeader(headerMessage);
0571:                            }
0572:                        }
0573:
0574:                        if (isSetMessageQNames) {
0575:                            addQNameReference(axisInMessage, wsdl4jOperation,
0576:                                    wsdl4jBindingInput, wrappableOperations
0577:                                            .contains(wsdl4jBindingOperation));
0578:                        }
0579:
0580:                        axisBindingInMessage.setAxisMessage(axisInMessage);
0581:                        axisBindingInMessage.setDirection(axisInMessage
0582:                                .getDirection());
0583:
0584:                        axisBindingInMessage.setParent(axisBindingOperation);
0585:                        axisBindingOperation.addChild(axisBindingInMessage
0586:                                .getDirection(), axisBindingInMessage);
0587:                    }
0588:
0589:                    BindingOutput wsdl4jBindingOutput = wsdl4jBindingOperation
0590:                            .getBindingOutput();
0591:
0592:                    if (wsdl4jBindingOutput != null
0593:                            && WSDLUtil.isOutputPresentForMEP(axisOperation
0594:                                    .getMessageExchangePattern())) {
0595:                        AxisBindingMessage axisBindingOutMessage = new AxisBindingMessage();
0596:                        addDocumentation(axisBindingOutMessage,
0597:                                wsdl4jBindingOutput.getDocumentationElement());
0598:                        AxisMessage axisOutMessage = axisOperation
0599:                                .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
0600:
0601:                        copyExtensibleElements(wsdl4jBindingOutput
0602:                                .getExtensibilityElements(), wsdl4jDefinition,
0603:                                axisBindingOutMessage, BINDING_OPERATION_OUTPUT);
0604:
0605:                        //This is a hack to get AXIS2-2771 working , I had to copy soap headers
0606:                        //  from binding message to AxisMessage
0607:                        List soapHeaders = (List) axisBindingOutMessage
0608:                                .getProperty(WSDL2Constants.ATTR_WSOAP_HEADER);
0609:                        if (soapHeaders != null) {
0610:                            for (int i = 0; i < soapHeaders.size(); i++) {
0611:                                SOAPHeaderMessage headerMessage = (SOAPHeaderMessage) soapHeaders
0612:                                        .get(i);
0613:                                axisOutMessage.addSoapHeader(headerMessage);
0614:                            }
0615:                        }
0616:
0617:                        if (isSetMessageQNames) {
0618:                            addQNameReference(axisOutMessage, wsdl4jOperation,
0619:                                    wsdl4jBindingOutput, wrappableOperations
0620:                                            .contains(wsdl4jBindingOperation));
0621:                        }
0622:
0623:                        axisBindingOutMessage.setAxisMessage(axisOutMessage);
0624:                        axisBindingOutMessage.setDirection(axisOutMessage
0625:                                .getDirection());
0626:
0627:                        axisBindingOutMessage.setParent(axisBindingOperation);
0628:                        axisBindingOperation.addChild(axisBindingOutMessage
0629:                                .getDirection(), axisBindingOutMessage);
0630:                    }
0631:
0632:                    Map bindingFaultsMap = wsdl4jBindingOperation
0633:                            .getBindingFaults();
0634:
0635:                    /* process the binding faults */
0636:                    for (Iterator bindingFaults = bindingFaultsMap.values()
0637:                            .iterator(); bindingFaults.hasNext();) {
0638:
0639:                        BindingFault bindingFault = (BindingFault) bindingFaults
0640:                                .next();
0641:                        Fault wsdl4jFault = wsdl4jOperation
0642:                                .getFault(bindingFault.getName());
0643:                        Message wsdl4jFaultMessge = wsdl4jFault.getMessage();
0644:
0645:                        AxisMessage faultMessage = findFaultMessage(
0646:                                wsdl4jFaultMessge.getQName().getLocalPart(),
0647:                                axisOperation.getFaultMessages());
0648:
0649:                        AxisBindingMessage axisBindingFaultMessage = new AxisBindingMessage();
0650:                        addDocumentation(axisBindingFaultMessage,
0651:                                wsdl4jFaultMessge.getDocumentationElement());
0652:                        axisBindingFaultMessage.setFault(true);
0653:                        axisBindingFaultMessage.setAxisMessage(faultMessage);
0654:                        axisBindingFaultMessage.setParent(axisBindingOperation);
0655:
0656:                        axisBindingOperation.addFault(axisBindingFaultMessage);
0657:                        if (isSetMessageQNames) {
0658:                            addQNameReference(faultMessage, wsdl4jFault
0659:                                    .getMessage());
0660:                        }
0661:                    }
0662:
0663:                    axisBindingOperation.setParent(axisBinding);
0664:                    axisBinding.addChild(axisBindingOperation.getName(),
0665:                            axisBindingOperation);
0666:                }
0667:                axisBinding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE,
0668:                        httpLocationMap);
0669:            }
0670:
0671:            /**
0672:             * contains all code which gathers non-service specific information from the
0673:             * wsdl. <p/> After all the setup completes successfully, the setupComplete
0674:             * field is set so that any subsequent calls to setup() will result in a
0675:             * no-op. Note that subclass WSDL11ToAllAxisServicesBuilder will call
0676:             * populateService for each port in the WSDL. Separating the non-service
0677:             * specific information here allows WSDL11ToAllAxisServicesBuilder to only
0678:             * do this work 1 time per WSDL, instead of for each port on each service.
0679:             *
0680:             * @throws WSDLException if readInTheWSDLFile fails
0681:             */
0682:            protected void setup() throws WSDLException {
0683:                if (setupComplete) { // already setup, just do nothing and return
0684:                    return;
0685:                }
0686:                if (wsdl4jDefinition == null) {
0687:                    wsdl4jDefinition = readInTheWSDLFile(in);
0688:                }
0689:                if (wsdl4jDefinition == null) {
0690:                    return; // can't continue without wsdl
0691:                }
0692:
0693:                // process the imports
0694:                //        WSDL4JImportedWSDLHelper.processImports(wsdl4jDefinition, new ArrayList());
0695:
0696:                // setup the schemaMap
0697:                this .schemaMap = new HashMap();
0698:                populateSchemaMap(wsdl4jDefinition, new Stack());
0699:
0700:                setPolicyRegistryFromService(axisService);
0701:
0702:                setupComplete = true; // if any part of setup fails, don't mark
0703:                // setupComplete        
0704:            }
0705:
0706:            /**
0707:             * Populate a map of targetNamespace vs DOM schema element This is used to
0708:             * grab the correct schema element when adding a new element
0709:             *
0710:             * @param definition
0711:             */
0712:
0713:            private void populateSchemaMap(Definition definition, Stack stack) {
0714:                stack.push(definition);
0715:                Types types = definition.getTypes();
0716:                Object extensibilityElement;
0717:                if (types != null) {
0718:                    for (Iterator iterator = types.getExtensibilityElements()
0719:                            .iterator(); iterator.hasNext();) {
0720:                        extensibilityElement = iterator.next();
0721:                        if (extensibilityElement instanceof  Schema) {
0722:                            Element schemaElement = ((Schema) extensibilityElement)
0723:                                    .getElement();
0724:                            schemaMap.put(schemaElement
0725:                                    .getAttribute(XSD_TARGETNAMESPACE),
0726:                                    schemaElement);
0727:                        }
0728:                    }
0729:                }
0730:
0731:                // popualte the imports as well
0732:                Iterator iter = definition.getImports().values().iterator();
0733:                Vector values = null;
0734:                Import wsdlImport = null;
0735:                for (; iter.hasNext();) {
0736:                    values = (Vector) iter.next();
0737:                    for (Iterator valuesIter = values.iterator(); valuesIter
0738:                            .hasNext();) {
0739:                        wsdlImport = (Import) valuesIter.next();
0740:                        Definition innerDefinition = wsdlImport.getDefinition();
0741:                        if (!stack.contains(innerDefinition)) {
0742:                            populateSchemaMap(innerDefinition, stack);
0743:                        }
0744:                    }
0745:                }
0746:                stack.pop();
0747:            }
0748:
0749:            /**
0750:             * return the service to process
0751:             * if user has specified we check whether it exists
0752:             * else pick a random service and throws an exception if not found any thing
0753:             *
0754:             * @param definition
0755:             * @return service to process
0756:             * @throws AxisFault
0757:             */
0758:
0759:            private Service findService(Definition definition) throws AxisFault {
0760:                Map services = definition.getServices();
0761:                Service service = null;
0762:                if (serviceName != null) {
0763:                    // i.e if a user has specified a pirticular port
0764:                    service = (Service) services.get(serviceName);
0765:                    if (service == null) {
0766:                        throw new AxisFault("Service " + serviceName
0767:                                + " was not found in the WSDL");
0768:                    }
0769:                } else {
0770:                    if (services.size() > 0) {
0771:                        for (Iterator iter = services.values().iterator(); iter
0772:                                .hasNext();) {
0773:                            service = (Service) iter.next();
0774:                            if (service.getPorts().size() > 0) {
0775:                                //i.e we have found a service with ports
0776:                                break;
0777:                            }
0778:                        }
0779:                        if ((service == null)
0780:                                || (service.getPorts().size() == 0)) {
0781:                            throw new AxisFault(
0782:                                    "there is no service with ports to pick");
0783:                        }
0784:
0785:                    } else {
0786:                        throw new AxisFault(
0787:                                "No service was not found in the WSDL at "
0788:                                        + definition.getDocumentBaseURI()
0789:                                        + " with targetnamespace "
0790:                                        + definition.getTargetNamespace());
0791:                    }
0792:                }
0793:                return service;
0794:            }
0795:
0796:            /**
0797:             * Look for the relevant binding!
0798:             * if user has spcifed a port get it
0799:             * otherwise find first soap port or pick random one if there is no soap port
0800:             *
0801:             * @param dif
0802:             * @param service service can not be null
0803:             * @throws AxisFault
0804:             */
0805:            private Binding findBinding(Definition dif, Service service)
0806:                    throws AxisFault {
0807:
0808:                Binding binding = null;
0809:                Port port = null;
0810:                copyExtensibleElements(service.getExtensibilityElements(), dif,
0811:                        axisService, SERVICE);
0812:                if (portName != null) {
0813:                    // i.e if user has specified a service
0814:                    port = service.getPort(portName);
0815:                    if (port == null) {
0816:                        throw new AxisFault(
0817:                                "No port found for the given name :" + portName);
0818:                    }
0819:                } else {
0820:                    Map ports = service.getPorts();
0821:                    if (ports != null && ports.size() > 0) {
0822:                        // pick the port with the SOAP address as the default port
0823:                        port = findPort(ports);
0824:                        if (port == null) {
0825:                            // a SOAP port was not found - log a warning
0826:                            // and use the first port in the list
0827:                            log.info("A SOAP port was not found - "
0828:                                    + "picking a random port!");
0829:                            port = (Port) ports.values().toArray()[0];
0830:                        }
0831:
0832:                        if (port != null) {
0833:                            // i.e we have find a correct port
0834:                            if (!this .isAllPorts) {
0835:                                // if user has not set all option
0836:                                // we have to generate code only for that option.
0837:                                this .portName = port.getName();
0838:                            }
0839:                        }
0840:                    }
0841:                }
0842:
0843:                axisService.setName(service.getQName().getLocalPart());
0844:
0845:                if (port != null) {
0846:                    copyExtensibleElements(port.getExtensibilityElements(),
0847:                            dif, axisService, PORT);
0848:                    //            binding = dif.getBinding(port.getBinding().getQName());
0849:                    binding = getBinding(port.getBinding().getQName(), dif);
0850:                    if (binding == null) {
0851:                        binding = port.getBinding();
0852:                    }
0853:                }
0854:
0855:                return binding;
0856:            }
0857:
0858:            /**
0859:             * find the message from imported wsdls
0860:             *
0861:             * @param messageQName
0862:             * @param definition
0863:             * @return message
0864:             */
0865:            private Message getMessage(QName messageQName, Definition definition) {
0866:                Message message = null;
0867:                // this can be in a imported wsdl
0868:                Iterator iter = definition.getImports().values().iterator();
0869:                Vector values = null;
0870:                Import wsdlImport = null;
0871:                for (; iter.hasNext();) {
0872:                    values = (Vector) iter.next();
0873:                    for (Iterator valuesIter = values.iterator(); valuesIter
0874:                            .hasNext();) {
0875:                        wsdlImport = (Import) valuesIter.next();
0876:                        // find the binding recursively
0877:                        message = getMessage(messageQName, wsdlImport
0878:                                .getDefinition());
0879:                        if (message != null) {
0880:                            break;
0881:                        }
0882:                    }
0883:                    if (message != null) {
0884:                        break;
0885:                    }
0886:                }
0887:
0888:                if (message == null) {
0889:                    message = definition.getMessage(messageQName);
0890:                }
0891:                return message;
0892:            }
0893:
0894:            /**
0895:             * get the port type form all the imported documents
0896:             *
0897:             * @param portTypeQName
0898:             * @param definition
0899:             * @return portType
0900:             */
0901:
0902:            private PortType getPortType(QName portTypeQName,
0903:                    Definition definition) {
0904:                return getPortType(portTypeQName, definition, new Stack());
0905:            }
0906:
0907:            /**
0908:             * get the port type form all the imported documents
0909:             *
0910:             * @param portTypeQName
0911:             * @param definition
0912:             * @return portType
0913:             */
0914:
0915:            private PortType getPortType(QName portTypeQName,
0916:                    Definition definition, Stack stack) {
0917:                stack.push(definition);
0918:                PortType portType = null;
0919:                Iterator iter = definition.getImports().values().iterator();
0920:                Vector values = null;
0921:                Import wsdlImport = null;
0922:                for (; iter.hasNext();) {
0923:                    values = (Vector) iter.next();
0924:                    for (Iterator valuesIter = values.iterator(); valuesIter
0925:                            .hasNext();) {
0926:                        wsdlImport = (Import) valuesIter.next();
0927:                        Definition innerDefinition = wsdlImport.getDefinition();
0928:                        if (stack.contains(innerDefinition)) {
0929:                            // find the binding recursively
0930:                            portType = getPortType(portTypeQName,
0931:                                    innerDefinition, stack);
0932:                            if (portType != null) {
0933:                                break;
0934:                            }
0935:                        }
0936:                    }
0937:                    if (portType != null) {
0938:                        break;
0939:                    }
0940:                }
0941:
0942:                if (portType == null) {
0943:                    // this can be in a imported wsdl
0944:                    portType = definition.getPortType(portTypeQName);
0945:                }
0946:                stack.pop();
0947:                return portType;
0948:            }
0949:
0950:            private Binding getBinding(QName bindingQName, Definition definition) {
0951:                ArrayList list = new ArrayList();
0952:                Binding binding = getBinding(bindingQName, definition, list);
0953:                if (binding == null) {
0954:                    for (int i = 0; i < list.size(); i++) {
0955:                        Binding binding2 = definition.getBinding(bindingQName);
0956:                        if (binding2 != null && binding2.getPortType() != null) {
0957:                            binding = binding2;
0958:                            break;
0959:                        }
0960:                    }
0961:                }
0962:                return binding;
0963:            }
0964:
0965:            /**
0966:             * first find the binding in the given definition
0967:             * if not found serch in the imported doucuments
0968:             *
0969:             * @param bindingQName
0970:             * @param definition
0971:             * @return binding
0972:             */
0973:
0974:            private Binding getBinding(QName bindingQName,
0975:                    Definition definition, ArrayList list) {
0976:                list.add(definition);
0977:                Binding binding = null;
0978:                //first try to find a binding in the upper inmport
0979:                Iterator iter = definition.getImports().values().iterator();
0980:                Vector values = null;
0981:                Import wsdlImport = null;
0982:                for (; iter.hasNext();) {
0983:                    values = (Vector) iter.next();
0984:                    for (Iterator valuesIter = values.iterator(); valuesIter
0985:                            .hasNext();) {
0986:                        wsdlImport = (Import) valuesIter.next();
0987:                        Definition innerDefinition = wsdlImport.getDefinition();
0988:                        if (!list.contains(innerDefinition)) {
0989:                            // find the binding recursively
0990:                            binding = getBinding(bindingQName, innerDefinition,
0991:                                    list);
0992:                            if (binding != null) {
0993:                                break;
0994:                            }
0995:                        }
0996:                    }
0997:                    if (binding != null) {
0998:                        break;
0999:                    }
1000:                }
1001:                return binding;
1002:            }
1003:
1004:            /**
1005:             * Finds a SOAP port given the port map
1006:             */
1007:            private Port findPort(Map ports) {
1008:                Port port;
1009:                for (Iterator portsIterator = ports.values().iterator(); portsIterator
1010:                        .hasNext();) {
1011:                    port = (Port) portsIterator.next();
1012:                    List extensibilityElements = port
1013:                            .getExtensibilityElements();
1014:                    for (int i = 0; i < extensibilityElements.size(); i++) {
1015:                        Object extElement = extensibilityElements.get(i);
1016:                        if (extElement instanceof  SOAP12Address) {
1017:                            // SOAP 1.2 address found - return that port and we are done
1018:                            return port;
1019:                        }
1020:                    }
1021:                }
1022:
1023:                for (Iterator portsIterator = ports.values().iterator(); portsIterator
1024:                        .hasNext();) {
1025:                    port = (Port) portsIterator.next();
1026:                    List extensibilityElements = port
1027:                            .getExtensibilityElements();
1028:                    for (int i = 0; i < extensibilityElements.size(); i++) {
1029:                        Object extElement = extensibilityElements.get(i);
1030:                        if (extElement instanceof  SOAPAddress) {
1031:                            // SOAP 1.1 address found - return that port and we are done
1032:                            return port;
1033:                        }
1034:                    }
1035:                }
1036:
1037:                for (Iterator portsIterator = ports.values().iterator(); portsIterator
1038:                        .hasNext();) {
1039:                    port = (Port) portsIterator.next();
1040:                    List extensibilityElements = port
1041:                            .getExtensibilityElements();
1042:                    for (int i = 0; i < extensibilityElements.size(); i++) {
1043:                        Object extElement = extensibilityElements.get(i);
1044:                        if (extElement instanceof  HTTPAddress) {
1045:                            // SOAP 1.1 address found - return that port and we are done
1046:                            return port;
1047:                        }
1048:                    }
1049:                }
1050:                // None found - just return null.
1051:                return null;
1052:            }
1053:
1054:            private Operation findOperation(PortType portType,
1055:                    BindingOperation wsdl4jBindingOperation) {
1056:                Operation op = wsdl4jBindingOperation.getOperation();
1057:                String input = null;
1058:                if (op != null && op.getInput() != null) {
1059:                    input = op.getInput().getName();
1060:                    if (":none".equals(input)) {
1061:                        input = null;
1062:                    }
1063:                }
1064:                String output = null;
1065:                if (op != null && op.getOutput() != null) {
1066:                    output = op.getOutput().getName();
1067:                    if (":none".equals(output)) {
1068:                        output = null;
1069:                    }
1070:                }
1071:                Operation op2 = portType.getOperation(op.getName(), input,
1072:                        output);
1073:                return ((op2 == null) ? op : op2);
1074:            }
1075:
1076:            /**
1077:             * Find the fault message relevant to a given name from the fault message
1078:             * list
1079:             *
1080:             * @param name
1081:             * @param faultMessages
1082:             */
1083:            private AxisMessage findFaultMessage(String name,
1084:                    ArrayList faultMessages) {
1085:                AxisMessage tempMessage;
1086:                for (int i = 0; i < faultMessages.size(); i++) {
1087:                    tempMessage = (AxisMessage) faultMessages.get(i);
1088:                    if (name.equals(tempMessage.getName())) {
1089:                        return tempMessage;
1090:                    }
1091:
1092:                }
1093:                return null;
1094:            }
1095:
1096:            /**
1097:             * Add the QName for the binding input
1098:             *
1099:             * @param inMessage
1100:             * @param wsdl4jOperation
1101:             * @param bindingInput
1102:             * @param isWrapped       - basically whether the operation is soap/rpc or not
1103:             */
1104:            private void addQNameReference(AxisMessage inMessage,
1105:                    Operation wsdl4jOperation, BindingInput bindingInput,
1106:                    boolean isWrapped) {
1107:
1108:                List extensibilityElements = bindingInput
1109:                        .getExtensibilityElements();
1110:                Message wsdl4jMessage = wsdl4jOperation.getInput().getMessage();
1111:
1112:                addQNameReference(inMessage, wsdl4jOperation, isWrapped,
1113:                        extensibilityElements, wsdl4jMessage, wsdl4jOperation
1114:                                .getName());
1115:            }
1116:
1117:            /**
1118:             * Add the QName for the binding output
1119:             *
1120:             * @param outMessage
1121:             * @param wsdl4jOperation
1122:             * @param isWrapped
1123:             */
1124:            private void addQNameReference(AxisMessage outMessage,
1125:                    Operation wsdl4jOperation, BindingOutput bindingOutput,
1126:                    boolean isWrapped) {
1127:
1128:                if (bindingOutput != null) {
1129:                    List extensibilityElements = bindingOutput
1130:                            .getExtensibilityElements();
1131:                    if (wsdl4jOperation.getOutput() == null) {
1132:                        return;
1133:                    }
1134:                    Message wsdl4jMessage = wsdl4jOperation.getOutput()
1135:                            .getMessage();
1136:
1137:                    addQNameReference(outMessage, wsdl4jOperation, isWrapped,
1138:                            extensibilityElements, wsdl4jMessage,
1139:                            wsdl4jOperation.getName()
1140:                                    + WRAPPED_OUTPUTNAME_SUFFIX);
1141:                }
1142:            }
1143:
1144:            private void addQNameReference(AxisMessage message,
1145:                    Operation wsdl4jOperation, boolean isWrapped,
1146:                    List extensibilityElements, Message wsdl4jMessage,
1147:                    String rpcOperationName) {
1148:                if (isWrapped) {
1149:                    // we have already validated and process the qname references
1150:                    // so set it here
1151:                    // The schema for this should be already made ! Find the
1152:                    // QName from
1153:                    // the list and add it - the name for this is just the
1154:                    message
1155:                            .setElementQName((QName) resolvedRpcWrappedElementMap
1156:                                    .get(rpcOperationName));
1157:                    message.getAxisOperation().getAxisService()
1158:                            .addMessageElementQNameToOperationMapping(
1159:                                    (QName) resolvedRpcWrappedElementMap
1160:                                            .get(rpcOperationName),
1161:                                    message.getAxisOperation());
1162:                } else {
1163:                    // now we are sure this is an document literal type element
1164:                    List bindingPartsList = getPartsListFromSoapBody(extensibilityElements);
1165:                    if (bindingPartsList == null) {
1166:                        // i.e user has not given any part list so we go to message and pick the firest part if
1167:                        // available
1168:                        if ((wsdl4jMessage.getParts() != null)
1169:                                && (wsdl4jMessage.getParts().size() > 0)) {
1170:                            if (wsdl4jMessage.getParts().size() == 1) {
1171:                                Part part = (Part) wsdl4jMessage.getParts()
1172:                                        .values().iterator().next();
1173:                                QName elementName = part.getElementName();
1174:                                if (elementName != null) {
1175:                                    message.setElementQName(elementName);
1176:                                    message.setMessagePartName(part.getName());
1177:                                    AxisOperation operation = message
1178:                                            .getAxisOperation();
1179:                                    AxisService service = operation
1180:                                            .getAxisService();
1181:                                    service
1182:                                            .addMessageElementQNameToOperationMapping(
1183:                                                    elementName, operation);
1184:                                } else {
1185:                                    throw new WSDLProcessingException(
1186:                                            "No element type is defined for message "
1187:                                                    + wsdl4jMessage.getQName()
1188:                                                            .getLocalPart());
1189:                                }
1190:                            } else {
1191:                                // user has specified more than one parts with out specifing a part in
1192:                                // soap body
1193:                                throw new WSDLProcessingException(
1194:                                        "More than one part for message "
1195:                                                + wsdl4jMessage.getQName()
1196:                                                        .getLocalPart());
1197:                            }
1198:                        } else {
1199:                            // this is allowed in the spec in this case element qname is null and nothing is send
1200:                            // in the soap body
1201:                            message.setElementQName(null);
1202:                        }
1203:                    } else {
1204:                        if (bindingPartsList.size() == 0) {
1205:                            // we donot have to set the element qname
1206:                            message.setElementQName(null);
1207:                        } else if (bindingPartsList.size() == 1) {
1208:                            Part part = wsdl4jMessage
1209:                                    .getPart((String) bindingPartsList.get(0));
1210:                            if (part != null) {
1211:                                QName elementName = part.getElementName();
1212:                                if (elementName != null) {
1213:                                    message.setElementQName(elementName);
1214:                                    message.setMessagePartName(part.getName());
1215:                                    AxisOperation operation = message
1216:                                            .getAxisOperation();
1217:                                    AxisService service = operation
1218:                                            .getAxisService();
1219:                                    service
1220:                                            .addMessageElementQNameToOperationMapping(
1221:                                                    elementName, operation);
1222:                                } else {
1223:                                    throw new WSDLProcessingException(
1224:                                            "No element type is defined for message"
1225:                                                    + wsdl4jMessage.getQName()
1226:                                                            .getLocalPart());
1227:                                }
1228:                            } else {
1229:                                throw new WSDLProcessingException(
1230:                                        "Missing part named "
1231:                                                + bindingPartsList.get(0) + " ");
1232:                            }
1233:
1234:                        } else {
1235:                            // i.e more than one part specified in this case we have
1236:                            // to send an exception
1237:                            throw new WSDLProcessingException(
1238:                                    "More than one element part is not allwed in document literal "
1239:                                            + " type binding operation "
1240:                                            + wsdl4jOperation.getName());
1241:                        }
1242:                    }
1243:
1244:                }
1245:
1246:            }
1247:
1248:            /**
1249:             * Add the QName for the binding output
1250:             */
1251:            private void addQNameReference(AxisMessage faultMessage,
1252:                    Message wsdl4jMessage) throws AxisFault {
1253:
1254:                // for a fault this is trivial - All faults are related directly to a
1255:                // message by the name and are supposed to have a single part. So it is
1256:                // a matter of copying the right QName from the message part
1257:
1258:                // get the part
1259:                Map parts = wsdl4jMessage.getParts();
1260:                if (parts == null || parts.size() == 0) {
1261:                    String message = "There are no parts"
1262:                            + " for fault message : "
1263:                            + wsdl4jMessage.getQName();
1264:                    log.error(message);
1265:                    throw new WSDLProcessingException(message);
1266:                }
1267:                Part wsdl4jMessagePart = (Part) parts.values().toArray()[0];
1268:                if (wsdl4jMessagePart == null) {
1269:                    throw new WSDLProcessingException();
1270:                }
1271:                QName name = wsdl4jMessagePart.getElementName();
1272:                if (name == null) {
1273:                    String message = "Part '"
1274:                            + wsdl4jMessagePart.getName()
1275:                            + "' of fault message '"
1276:                            + wsdl4jMessage.getQName()
1277:                            + "' must be defined with 'element=QName' and not 'type=QName'";
1278:                    log.error(message);
1279:                    throw new AxisFault(message);
1280:                }
1281:
1282:                faultMessage.setMessagePartName(wsdl4jMessagePart.getName());
1283:                faultMessage.setElementQName(name);
1284:            }
1285:
1286:            /**
1287:             * A util method that returns the SOAP style included in the binding
1288:             * operation
1289:             *
1290:             * @param bindingOp
1291:             */
1292:            private String getSOAPStyle(BindingOperation bindingOp) {
1293:                List extensibilityElements = bindingOp
1294:                        .getExtensibilityElements();
1295:                for (int i = 0; i < extensibilityElements.size(); i++) {
1296:                    Object extElement = extensibilityElements.get(i);
1297:                    if (extElement instanceof  SOAPOperation) {
1298:                        return ((SOAPOperation) extElement).getStyle();
1299:                    } else if (extElement instanceof  SOAP12Operation) {
1300:                        return ((SOAP12Operation) extElement).getStyle();
1301:                    }
1302:
1303:                }
1304:                return null;
1305:            }
1306:
1307:            /**
1308:             * Copy the component from the operation
1309:             *
1310:             * @param wsdl4jOperation
1311:             * @param dif
1312:             * @throws AxisFault
1313:             */
1314:            private AxisOperation populateOperations(Operation wsdl4jOperation,
1315:                    PortType wsdl4jPortType, Definition dif) throws AxisFault {
1316:                QName opName = new QName(dif.getTargetNamespace(),
1317:                        wsdl4jOperation.getName());
1318:                // Copy Name Attribute
1319:                AxisOperation axisOperation = axisService.getOperation(opName);
1320:                if (axisOperation == null) {
1321:                    String MEP = getMEP(wsdl4jOperation);
1322:                    axisOperation = AxisOperationFactory
1323:                            .getOperationDescription(MEP);
1324:                    axisOperation.setName(opName);
1325:
1326:                    // setting the PolicyInclude property of the AxisOperation
1327:                    PolicyInclude policyInclude = new PolicyInclude(
1328:                            axisOperation);
1329:                    axisOperation.setPolicyInclude(policyInclude);
1330:                }
1331:
1332:                copyExtensibleElements(wsdl4jOperation
1333:                        .getExtensibilityElements(), dif, axisOperation,
1334:                        PORT_TYPE_OPERATION);
1335:
1336:                Input wsdl4jInputMessage = wsdl4jOperation.getInput();
1337:
1338:                if (isServerSide) {
1339:                    if (null != wsdl4jInputMessage) {
1340:                        AxisMessage inMessage = axisOperation
1341:                                .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
1342:                        Message message = wsdl4jInputMessage.getMessage();
1343:                        if (null != message) {
1344:                            inMessage
1345:                                    .setName(message.getQName().getLocalPart());
1346:                            copyExtensibleElements(message
1347:                                    .getExtensibilityElements(), dif,
1348:                                    inMessage, PORT_TYPE_OPERATION_INPUT);
1349:
1350:                        }
1351:                        // Check if the action is already set as we don't want to
1352:                        // override it
1353:                        // with the Default Action Pattern
1354:                        ArrayList inputActions = axisOperation
1355:                                .getWSAMappingList();
1356:                        String action = null;
1357:                        if (inputActions == null || inputActions.size() == 0) {
1358:                            action = WSDL11ActionHelper
1359:                                    .getActionFromInputElement(dif,
1360:                                            wsdl4jPortType, wsdl4jOperation,
1361:                                            wsdl4jInputMessage);
1362:                        }
1363:                        if (action != null) {
1364:                            if (inputActions == null) {
1365:                                inputActions = new ArrayList();
1366:                                axisOperation.setWsamappingList(inputActions);
1367:                            }
1368:                            inputActions.add(action);
1369:                            axisService.mapActionToOperation(action,
1370:                                    axisOperation);
1371:                        }
1372:                    }
1373:                    // Create an output message and add
1374:                    Output wsdl4jOutputMessage = wsdl4jOperation.getOutput();
1375:                    if (null != wsdl4jOutputMessage) {
1376:                        AxisMessage outMessage = axisOperation
1377:                                .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
1378:                        Message message = wsdl4jOutputMessage.getMessage();
1379:                        if (null != message) {
1380:
1381:                            outMessage.setName(message.getQName()
1382:                                    .getLocalPart());
1383:                            copyExtensibleElements(message
1384:                                    .getExtensibilityElements(), dif,
1385:                                    outMessage, PORT_TYPE_OPERATION_OUTPUT);
1386:
1387:                            // wsdl:portType -> wsdl:operation -> wsdl:output
1388:                        }
1389:                        // Check if the action is already set as we don't want to
1390:                        // override it
1391:                        // with the Default Action Pattern
1392:                        String action = axisOperation.getOutputAction();
1393:                        if (action == null) {
1394:                            action = WSDL11ActionHelper
1395:                                    .getActionFromOutputElement(dif,
1396:                                            wsdl4jPortType, wsdl4jOperation,
1397:                                            wsdl4jOutputMessage);
1398:                        }
1399:                        if (action != null) {
1400:                            axisOperation.setOutputAction(action);
1401:                        }
1402:                    }
1403:                } else {
1404:
1405:                    // for the client side we have to do something that is a bit
1406:                    // weird. The in message is actually taken from the output
1407:                    // and the output is taken from the in
1408:
1409:                    if (null != wsdl4jInputMessage) {
1410:                        AxisMessage inMessage = axisOperation
1411:                                .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
1412:                        Message message = wsdl4jInputMessage.getMessage();
1413:                        if (null != message) {
1414:
1415:                            inMessage
1416:                                    .setName(message.getQName().getLocalPart());
1417:                            copyExtensibleElements(message
1418:                                    .getExtensibilityElements(), dif,
1419:                                    inMessage, PORT_TYPE_OPERATION_OUTPUT);
1420:
1421:                        }
1422:                        // Check if the action is already set as we don't want to
1423:                        // override it
1424:                        // with the Default Action Pattern
1425:                        String action = axisOperation.getOutputAction();
1426:                        if (action == null) {
1427:                            action = WSDL11ActionHelper
1428:                                    .getActionFromInputElement(dif,
1429:                                            wsdl4jPortType, wsdl4jOperation,
1430:                                            wsdl4jInputMessage);
1431:                        }
1432:                        if (action != null) {
1433:                            axisOperation.setOutputAction(action);
1434:                        }
1435:                    }
1436:                    // Create an output message and add
1437:                    Output wsdl4jOutputMessage = wsdl4jOperation.getOutput();
1438:                    if (null != wsdl4jOutputMessage) {
1439:                        AxisMessage outMessage = axisOperation
1440:                                .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
1441:                        Message message = wsdl4jOutputMessage.getMessage();
1442:                        if (null != message) {
1443:
1444:                            outMessage.setName(message.getQName()
1445:                                    .getLocalPart());
1446:                            copyExtensibleElements(message
1447:                                    .getExtensibilityElements(), dif,
1448:                                    outMessage, PORT_TYPE_OPERATION_INPUT);
1449:
1450:                            // wsdl:portType -> wsdl:operation -> wsdl:output
1451:                        }
1452:                        // Check if the action is already set as we don't want to
1453:                        // override it
1454:                        // with the Default Action Pattern
1455:                        ArrayList inputActions = axisOperation
1456:                                .getWSAMappingList();
1457:                        String action = null;
1458:                        if (inputActions == null || inputActions.size() == 0) {
1459:                            action = WSDL11ActionHelper
1460:                                    .getActionFromOutputElement(dif,
1461:                                            wsdl4jPortType, wsdl4jOperation,
1462:                                            wsdl4jOutputMessage);
1463:                        }
1464:                        if (action != null) {
1465:                            if (inputActions == null) {
1466:                                inputActions = new ArrayList();
1467:                                axisOperation.setWsamappingList(inputActions);
1468:                            }
1469:                            inputActions.add(action);
1470:                        }
1471:                    }
1472:                }
1473:
1474:                Map faults = wsdl4jOperation.getFaults();
1475:                Iterator faultKeyIterator = faults.keySet().iterator();
1476:
1477:                while (faultKeyIterator.hasNext()) {
1478:                    Fault fault = (Fault) faults.get(faultKeyIterator.next());
1479:                    AxisMessage axisFaultMessage = new AxisMessage();
1480:                    Message faultMessage = fault.getMessage();
1481:                    if (null != faultMessage) {
1482:                        axisFaultMessage.setName(faultMessage.getQName()
1483:                                .getLocalPart());
1484:
1485:                        copyExtensibleElements(faultMessage
1486:                                .getExtensibilityElements(), dif,
1487:                                axisFaultMessage, PORT_TYPE_OPERATION_FAULT);
1488:
1489:                    }
1490:
1491:                    // Check if the action is already set as we don't want to override
1492:                    // it
1493:                    // with the Default Action Pattern
1494:                    String action = axisOperation.getFaultAction(fault
1495:                            .getName());
1496:                    if (action == null) {
1497:                        action = WSDL11ActionHelper.getActionFromFaultElement(
1498:                                dif, wsdl4jPortType, wsdl4jOperation, fault);
1499:                    }
1500:                    if (action != null) {
1501:                        axisOperation.addFaultAction(fault.getName(), action);
1502:                    }
1503:                    axisOperation.setFaultMessages(axisFaultMessage);
1504:                }
1505:                return axisOperation;
1506:            }
1507:
1508:            /**
1509:             * Generates a list of wrapper schemas
1510:             *
1511:             * @param wsdl4jBinding
1512:             */
1513:            private Element[] generateWrapperSchema(Map schemaMap,
1514:                    Binding wsdl4jBinding, PortType portType) {
1515:
1516:                List schemaElementList = new ArrayList();
1517:                // target namespace for this should be the namespace URI for
1518:                // the porttype
1519:                String porttypeNamespaceURI = portType.getQName()
1520:                        .getNamespaceURI();
1521:
1522:                // //////////////////////////////////////////////////////////////////////
1523:                // if there are any bindings present then we have to process them. we
1524:                // have to generate a schema per wsdl4jBinding (that is the safest
1525:                // option).
1526:                // if not we just resolve to
1527:                // the good old port type
1528:                // list, in which case we'll generate a schema per porttype
1529:                // //////////////////////////////////////////////////////////////////////
1530:
1531:                // findwrappable operations return either the rpc soap operations or
1532:                // Http binding operations
1533:
1534:                List wrappableBindingOperationsList = findWrappableBindingOperations(wsdl4jBinding);
1535:
1536:                // this method returns all the new schemas created when processing the rpc messages
1537:                Map newSchemaMap = createSchemaForPorttype(
1538:                        porttypeNamespaceURI, wrappableBindingOperationsList,
1539:                        schemaMap);
1540:
1541:                schemaElementList.addAll(newSchemaMap.values());
1542:                return (Element[]) schemaElementList
1543:                        .toArray(new Element[schemaElementList.size()]);
1544:            }
1545:
1546:            /**
1547:             * Create a schema by looking at the port type
1548:             *
1549:             * @param namespaceURI - namespace of the porttype uri we use this only if a user has not specified
1550:             *                     a namespace in soap:body
1551:             * @return null if there is no element
1552:             */
1553:            private Map createSchemaForPorttype(String namespaceURI,
1554:                    List operationListToProcess, Map existingSchemaMap) {
1555:
1556:                // this map is used to keep the newly added schemas
1557:                Map newSchemaMap = new HashMap();
1558:                // first of all look at the operations list
1559:                // we can return immediately if we get the operations list
1560:                // as empty
1561:                if (operationListToProcess.isEmpty()) {
1562:                    return newSchemaMap;
1563:                }
1564:
1565:                // loop through the messages. We'll populate thins map with the relevant
1566:                // messages
1567:                // from the operations
1568:                Map messageQnameToMessageMap = new HashMap();
1569:                Map operationToInputMessageMap = new HashMap();
1570:                Map operationToOutputMessageMap = new HashMap();
1571:
1572:                // this contains the required namespace imports. the key in this
1573:                // map would be the namaspace URI
1574:                Map namespaceImportsMap = null;
1575:                // list namespace prefix map. This map will include uri -> prefix
1576:                Map namespacePrefixMap = null;
1577:
1578:                // //////////////////////////////////////////////////////////////////////////////////////////////////
1579:                // First thing is to populate the message map with the messages to
1580:                // process.
1581:                // //////////////////////////////////////////////////////////////////////////////////////////////////
1582:
1583:                // we really need to do this for a single porttype!
1584:                BindingOperation op;
1585:                for (int k = 0; k < operationListToProcess.size(); k++) {
1586:                    op = (BindingOperation) operationListToProcess.get(k);
1587:                    Input input = op.getOperation().getInput();
1588:                    Message message;
1589:                    if (input != null) {
1590:                        message = input.getMessage();
1591:                        messageQnameToMessageMap.put(message.getQName(),
1592:                                message);
1593:                        operationToInputMessageMap.put(op, message);
1594:                    }
1595:
1596:                    Output output = op.getOperation().getOutput();
1597:                    if (output != null) {
1598:                        message = output.getMessage();
1599:                        messageQnameToMessageMap.put(message.getQName(),
1600:                                message);
1601:                        operationToOutputMessageMap.put(op, message);
1602:                    }
1603:
1604:                    // we do not want to process fault messages since they can only be used as document type
1605:                    // see basic profile 4.4.2
1606:                }
1607:
1608:                // find the xsd prefix
1609:                String xsdPrefix = findSchemaPrefix();
1610:                // DOM document that will be the ultimate creator
1611:                Document document = getDOMDocumentBuilder().newDocument();
1612:
1613:                Element elementDeclaration;
1614:
1615:                //loop through the input op map and generate the elements
1616:                BindingOperation operation;
1617:                for (Iterator operationsIter = operationToInputMessageMap
1618:                        .keySet().iterator(); operationsIter.hasNext();) {
1619:
1620:                    operation = (BindingOperation) operationsIter.next();
1621:                    elementDeclaration = document.createElementNS(
1622:                            XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
1623:                                    + XML_SCHEMA_ELEMENT_LOCAL_NAME);
1624:                    elementDeclaration.setAttribute(XSD_NAME, operation
1625:                            .getName());
1626:
1627:                    //when creating the inner complex type we have to find the parts list from the binding input
1628:                    BindingInput bindingInput = operation.getBindingInput();
1629:                    Message message = (Message) operationToInputMessageMap
1630:                            .get(operation);
1631:
1632:                    if (bindingInput != null) {
1633:
1634:                        Collection partsCollection = null;
1635:                        if (BINDING_TYPE_SOAP.equals(this .bindingType)) {
1636:                            // first see the body parts list
1637:                            List bodyPartsList = getPartsListFromSoapBody(bindingInput
1638:                                    .getExtensibilityElements());
1639:                            if (bodyPartsList != null) {
1640:                                partsCollection = message
1641:                                        .getOrderedParts(bodyPartsList);
1642:                            } else {
1643:                                partsCollection = message.getParts().values();
1644:                            }
1645:                        } else {
1646:                            // i.e http binding
1647:                            partsCollection = message.getParts().values();
1648:                        }
1649:
1650:                        List parameterOrder = operation.getOperation()
1651:                                .getParameterOrdering();
1652:                        namespaceImportsMap = new HashMap();
1653:                        namespacePrefixMap = new HashMap();
1654:
1655:                        Node newComplexType = getNewComplextType(document,
1656:                                xsdPrefix, partsCollection, parameterOrder,
1657:                                false, namespaceImportsMap, namespacePrefixMap);
1658:
1659:                        elementDeclaration.appendChild(newComplexType);
1660:                        String namespaceToUse = namespaceURI;
1661:
1662:                        if (BINDING_TYPE_SOAP.equals(this .bindingType)) {
1663:                            String bodyNamespace = getNamespaceFromSoapBody(bindingInput
1664:                                    .getExtensibilityElements());
1665:                            namespaceToUse = bodyNamespace != null ? bodyNamespace
1666:                                    : namespaceURI;
1667:                        }
1668:
1669:                        if (existingSchemaMap.containsKey(namespaceToUse)) {
1670:                            // i.e this namespace is already exists with the original wsdl schemas
1671:                            addElementToAnExistingSchema(
1672:                                    (Element) existingSchemaMap
1673:                                            .get(namespaceToUse),
1674:                                    elementDeclaration, namespacePrefixMap,
1675:                                    namespaceImportsMap, namespaceToUse);
1676:                        } else if (newSchemaMap.containsKey(namespaceToUse)) {
1677:                            // i.e this namespace is with a newly created scheam
1678:                            addElementToAnExistingSchema((Element) newSchemaMap
1679:                                    .get(namespaceToUse), elementDeclaration,
1680:                                    namespacePrefixMap, namespaceImportsMap,
1681:                                    namespaceToUse);
1682:                        } else {
1683:                            // i.e this element namespace has not found yet so
1684:                            // we have to create new schema for it
1685:                            Element newSchema = createNewSchemaWithElement(
1686:                                    elementDeclaration, namespacePrefixMap,
1687:                                    namespaceImportsMap, namespaceToUse,
1688:                                    document, xsdPrefix);
1689:                            newSchemaMap.put(namespaceToUse, newSchema);
1690:                        }
1691:                        resolvedRpcWrappedElementMap.put(operation.getName(),
1692:                                new QName(namespaceToUse, operation.getName(),
1693:                                        AXIS2WRAPPED));
1694:
1695:                    } else {
1696:                        throw new WSDLProcessingException(
1697:                                "No binding input is defiend for binding operation ==> "
1698:                                        + operation.getName());
1699:                    }
1700:
1701:                }
1702:
1703:                // loop through the output to map and generate the elements
1704:                for (Iterator operationsIterator = operationToOutputMessageMap
1705:                        .keySet().iterator(); operationsIterator.hasNext();) {
1706:                    operation = (BindingOperation) operationsIterator.next();
1707:                    String baseoutputOpName = operation.getName();
1708:                    // see basic profile 4.7.19
1709:                    String outputOpName = baseoutputOpName
1710:                            + WRAPPED_OUTPUTNAME_SUFFIX;
1711:                    elementDeclaration = document.createElementNS(
1712:                            XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
1713:                                    + XML_SCHEMA_ELEMENT_LOCAL_NAME);
1714:                    elementDeclaration.setAttribute(XSD_NAME, outputOpName);
1715:
1716:                    BindingOutput bindingOutput = operation.getBindingOutput();
1717:                    Message message = (Message) operationToOutputMessageMap
1718:                            .get(operation);
1719:
1720:                    if (bindingOutput != null) {
1721:                        Collection partsCollection = null;
1722:                        if (BINDING_TYPE_SOAP.equals(this .bindingType)) {
1723:                            // first see the body parts list
1724:                            List bodyPartsList = getPartsListFromSoapBody(bindingOutput
1725:                                    .getExtensibilityElements());
1726:                            if (bodyPartsList != null) {
1727:                                partsCollection = message
1728:                                        .getOrderedParts(bodyPartsList);
1729:                            } else {
1730:                                // then see the parameter order
1731:                                partsCollection = message.getParts().values();
1732:                            }
1733:                        } else {
1734:                            // i.e if http binding
1735:                            partsCollection = message.getParts().values();
1736:                        }
1737:
1738:                        List parameterOrder = operation.getOperation()
1739:                                .getParameterOrdering();
1740:
1741:                        // we have to initialize the hash maps always since we add the elements onece we
1742:                        // generate it
1743:                        namespacePrefixMap = new HashMap();
1744:                        namespaceImportsMap = new HashMap();
1745:
1746:                        Node newComplexType = getNewComplextType(document,
1747:                                xsdPrefix, partsCollection, parameterOrder,
1748:                                true, namespaceImportsMap, namespacePrefixMap);
1749:                        elementDeclaration.appendChild(newComplexType);
1750:
1751:                        String namespaceToUse = namespaceURI;
1752:
1753:                        if (BINDING_TYPE_SOAP.equals(this .bindingType)) {
1754:                            String bodyNamespace = getNamespaceFromSoapBody(bindingOutput
1755:                                    .getExtensibilityElements());
1756:                            namespaceToUse = bodyNamespace != null ? bodyNamespace
1757:                                    : namespaceURI;
1758:                        }
1759:
1760:                        if (existingSchemaMap.containsKey(namespaceToUse)) {
1761:                            // i.e this namespace is already exists with the original wsdl schemas
1762:                            addElementToAnExistingSchema(
1763:                                    (Element) existingSchemaMap
1764:                                            .get(namespaceToUse),
1765:                                    elementDeclaration, namespacePrefixMap,
1766:                                    namespaceImportsMap, namespaceToUse);
1767:                        } else if (newSchemaMap.containsKey(namespaceToUse)) {
1768:                            // i.e this namespace is with a newly created scheam
1769:                            addElementToAnExistingSchema((Element) newSchemaMap
1770:                                    .get(namespaceToUse), elementDeclaration,
1771:                                    namespacePrefixMap, namespaceImportsMap,
1772:                                    namespaceToUse);
1773:                        } else {
1774:                            // i.e this element namespace has not found yet so
1775:                            // we have to create new schema for it
1776:                            Element newSchema = createNewSchemaWithElement(
1777:                                    elementDeclaration, namespacePrefixMap,
1778:                                    namespaceImportsMap, namespaceToUse,
1779:                                    document, xsdPrefix);
1780:                            newSchemaMap.put(namespaceToUse, newSchema);
1781:                        }
1782:                        resolvedRpcWrappedElementMap.put(outputOpName,
1783:                                new QName(namespaceToUse, outputOpName,
1784:                                        AXIS2WRAPPED));
1785:
1786:                    } else {
1787:                        throw new WSDLProcessingException(
1788:                                "No binding out put is defined for binding operation ==>"
1789:                                        + operation.getName());
1790:                    }
1791:                }
1792:
1793:                return newSchemaMap;
1794:            }
1795:
1796:            private void addElementToAnExistingSchema(Element schemaElement,
1797:                    Element newElement, Map namespacePrefixMap,
1798:                    Map namespaceImportsMap, String targetNamespace) {
1799:
1800:                Document ownerDocument = schemaElement.getOwnerDocument();
1801:
1802:                // loop through the namespace declarations first and add them
1803:                String[] nameSpaceDeclarationArray = (String[]) namespacePrefixMap
1804:                        .keySet()
1805:                        .toArray(new String[namespacePrefixMap.size()]);
1806:                for (int i = 0; i < nameSpaceDeclarationArray.length; i++) {
1807:                    String s = nameSpaceDeclarationArray[i];
1808:                    checkAndAddNamespaceDeclarations(s, namespacePrefixMap,
1809:                            schemaElement);
1810:                }
1811:
1812:                // add imports - check whether it is the targetnamespace before
1813:                // adding
1814:                Element[] namespaceImports = (Element[]) namespaceImportsMap
1815:                        .values().toArray(
1816:                                new Element[namespaceImportsMap.size()]);
1817:                for (int i = 0; i < namespaceImports.length; i++) {
1818:                    if (!targetNamespace.equals(namespaceImports[i]
1819:                            .getAttribute(NAMESPACE_URI))) {
1820:                        schemaElement.appendChild(ownerDocument.importNode(
1821:                                namespaceImports[i], true));
1822:                    }
1823:                }
1824:
1825:                schemaElement.appendChild(ownerDocument.importNode(newElement,
1826:                        true));
1827:
1828:            }
1829:
1830:            private Element createNewSchemaWithElement(Element newElement,
1831:                    Map namespacePrefixMap, Map namespaceImportsMap,
1832:                    String targetNamespace, Document document, String xsdPrefix) {
1833:
1834:                Element schemaElement = document.createElementNS(
1835:                        XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
1836:                                + XML_SCHEMA_LOCAL_NAME);
1837:
1838:                // loop through the namespace declarations first
1839:                String[] nameSpaceDeclarationArray = (String[]) namespacePrefixMap
1840:                        .keySet()
1841:                        .toArray(new String[namespacePrefixMap.size()]);
1842:                for (int i = 0; i < nameSpaceDeclarationArray.length; i++) {
1843:                    String s = nameSpaceDeclarationArray[i];
1844:                    schemaElement.setAttributeNS(XML_NAMESPACE_URI,
1845:                            NAMESPACE_DECLARATION_PREFIX
1846:                                    + namespacePrefixMap.get(s).toString(), s);
1847:                }
1848:
1849:                if (schemaElement.getAttributeNS(XML_NAMESPACE_URI, xsdPrefix)
1850:                        .length() == 0) {
1851:                    schemaElement.setAttributeNS(XML_NAMESPACE_URI,
1852:                            NAMESPACE_DECLARATION_PREFIX + xsdPrefix,
1853:                            XMLSCHEMA_NAMESPACE_URI);
1854:                }
1855:
1856:                // add the targetNamespace
1857:                schemaElement.setAttributeNS(XML_NAMESPACE_URI,
1858:                        XMLNS_AXIS2WRAPPED, targetNamespace);
1859:                schemaElement
1860:                        .setAttribute(XSD_TARGETNAMESPACE, targetNamespace);
1861:                schemaElement.setAttribute(XSD_ELEMENT_FORM_DEFAULT,
1862:                        XSD_UNQUALIFIED);
1863:
1864:                // add imports
1865:                Element[] namespaceImports = (Element[]) namespaceImportsMap
1866:                        .values().toArray(
1867:                                new Element[namespaceImportsMap.size()]);
1868:                for (int i = 0; i < namespaceImports.length; i++) {
1869:                    schemaElement.appendChild(namespaceImports[i]);
1870:
1871:                }
1872:
1873:                schemaElement.appendChild(newElement);
1874:                return schemaElement;
1875:            }
1876:
1877:            private List getPartsListFromSoapBody(List extensibilityElements) {
1878:                List partsList = null;
1879:                ExtensibilityElement extElement;
1880:                for (Iterator iter = extensibilityElements.iterator(); iter
1881:                        .hasNext();) {
1882:                    extElement = (ExtensibilityElement) iter.next();
1883:                    // SOAP 1.1 body element found!
1884:                    if (extElement instanceof  SOAPBody) {
1885:                        SOAPBody soapBody = (SOAPBody) extElement;
1886:                        if ((soapBody.getUse() != null)
1887:                                && (soapBody.getUse().equals(ENCODED_USE))) {
1888:                            throw new WSDLProcessingException(
1889:                                    "Encoded use is not supported");
1890:                        }
1891:                        partsList = soapBody.getParts();
1892:                    } else if (extElement instanceof  SOAP12Body) {
1893:                        SOAP12Body soapBody = (SOAP12Body) extElement;
1894:                        if ((soapBody.getUse() != null)
1895:                                && (soapBody.getUse().equals(ENCODED_USE))) {
1896:                            throw new WSDLProcessingException(
1897:                                    "Encoded use is not supported");
1898:                        }
1899:                        partsList = soapBody.getParts();
1900:                    } else if (extElement instanceof  MIMEMultipartRelated) {
1901:                        MIMEMultipartRelated minMimeMultipartRelated = (MIMEMultipartRelated) extElement;
1902:                        List mimePartsList = minMimeMultipartRelated
1903:                                .getMIMEParts();
1904:                        MIMEPart mimePart = null;
1905:                        Object object;
1906:                        List mimePartElements;
1907:                        ExtensibilityElement mimePartExtensibilityElement;
1908:                        for (Iterator mimePartsIter = mimePartsList.iterator(); mimePartsIter
1909:                                .hasNext();) {
1910:                            object = mimePartsIter.next();
1911:                            if (object instanceof  MIMEPart) {
1912:                                mimePart = (MIMEPart) object;
1913:                                mimePartElements = mimePart
1914:                                        .getExtensibilityElements();
1915:                                for (Iterator mimePartElementsIter = mimePartElements
1916:                                        .iterator(); mimePartElementsIter
1917:                                        .hasNext();) {
1918:                                    mimePartExtensibilityElement = (ExtensibilityElement) mimePartElementsIter
1919:                                            .next();
1920:                                    if (mimePartExtensibilityElement instanceof  SOAPBody) {
1921:                                        SOAPBody soapBody = (SOAPBody) mimePartExtensibilityElement;
1922:                                        if ((soapBody.getUse() != null)
1923:                                                && (soapBody.getUse()
1924:                                                        .equals(ENCODED_USE))) {
1925:                                            throw new WSDLProcessingException(
1926:                                                    "Encoded use is not supported");
1927:                                        }
1928:                                        partsList = soapBody.getParts();
1929:                                    } else if (mimePartExtensibilityElement instanceof  SOAP12Body) {
1930:                                        SOAP12Body soapBody = (SOAP12Body) mimePartExtensibilityElement;
1931:                                        if ((soapBody.getUse() != null)
1932:                                                && (soapBody.getUse()
1933:                                                        .equals(ENCODED_USE))) {
1934:                                            throw new WSDLProcessingException(
1935:                                                    "Encoded use is not supported");
1936:                                        }
1937:                                        partsList = soapBody.getParts();
1938:                                    }
1939:                                }
1940:                            }
1941:                        }
1942:                    }
1943:                }
1944:                if (partsList == null) {
1945:                    log
1946:                            .debug("SOAP body parts have not been set. All the parts in the message were added to the message.");
1947:                }
1948:                return partsList;
1949:            }
1950:
1951:            private String getNamespaceFromSoapBody(List extensibilityElements) {
1952:
1953:                ExtensibilityElement extElement;
1954:                String namespace = null;
1955:                for (Iterator iter = extensibilityElements.iterator(); iter
1956:                        .hasNext();) {
1957:                    extElement = (ExtensibilityElement) iter.next();
1958:                    // SOAP 1.1 body element found!
1959:                    if (extElement instanceof  SOAPBody) {
1960:                        SOAPBody soapBody = (SOAPBody) extElement;
1961:                        namespace = soapBody.getNamespaceURI();
1962:                    } else if (extElement instanceof  SOAP12Body) {
1963:                        SOAP12Body soapBody = (SOAP12Body) extElement;
1964:                        namespace = soapBody.getNamespaceURI();
1965:                    }
1966:                }
1967:                return namespace;
1968:            }
1969:
1970:            /**
1971:             * creates a new shema complex element according to the elements sequence difined
1972:             * this parts list is always for a message refering from the
1973:             * soap rpc type operation
1974:             *
1975:             * @param document
1976:             * @param xsdPrefix
1977:             * @param partsCollection     - parts to be added
1978:             * @param parameterOrder      - param Order list if it is given
1979:             * @param isOutMessage
1980:             * @param namespaceImportsMap
1981:             * @param namespacePrefixMap
1982:             * @return new element
1983:             */
1984:            private Element getNewComplextType(Document document,
1985:                    String xsdPrefix, Collection partsCollection,
1986:                    List parameterOrder, boolean isOutMessage,
1987:                    Map namespaceImportsMap, Map namespacePrefixMap) {
1988:                // add the complex type
1989:                Element newComplexType = document.createElementNS(
1990:                        XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
1991:                                + XML_SCHEMA_COMPLEX_TYPE_LOCAL_NAME);
1992:
1993:                Element cmplxTypeSequence = document.createElementNS(
1994:                        XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
1995:                                + XML_SCHEMA_SEQUENCE_LOCAL_NAME);
1996:
1997:                Part part;
1998:                if ((parameterOrder == null) || (parameterOrder.size() == 0)) {
1999:                    // no parameter order then just add the elements in the parts collection
2000:                    for (Iterator partsIter = partsCollection.iterator(); partsIter
2001:                            .hasNext();) {
2002:                        part = (Part) partsIter.next();
2003:                        // the part name
2004:                        addPartToElement(part, document, xsdPrefix,
2005:                                namespaceImportsMap, namespacePrefixMap,
2006:                                cmplxTypeSequence);
2007:
2008:                    }
2009:                } else {
2010:                    // i.e an parts order is given
2011:                    // first populate all the parts to a map
2012:                    Map partsMap = new HashMap();
2013:                    for (Iterator partsIter = partsCollection.iterator(); partsIter
2014:                            .hasNext();) {
2015:                        part = (Part) partsIter.next();
2016:                        partsMap.put(part.getName(), part);
2017:                    }
2018:
2019:                    String partName;
2020:                    for (Iterator paramOrderIter = parameterOrder.iterator(); paramOrderIter
2021:                            .hasNext();) {
2022:                        partName = (String) paramOrderIter.next();
2023:                        part = (Part) partsMap.get(partName);
2024:                        if (part != null) {
2025:                            addPartToElement(part, document, xsdPrefix,
2026:                                    namespaceImportsMap, namespacePrefixMap,
2027:                                    cmplxTypeSequence);
2028:                            partsMap.remove(partName);
2029:                        }
2030:                    }
2031:                    // if this is an out put message then we have to set the
2032:                    // return type if exists
2033:                    if (isOutMessage) {
2034:                        if (partsMap.size() > 0) {
2035:                            if (partsMap.size() == 1) {
2036:                                part = (Part) partsMap.values().iterator()
2037:                                        .next();
2038:                                // change the name of this part
2039:                                // this is the return type and its name should be result
2040:                                //                        part.setName("result");
2041:                                addPartToElement(part, document, xsdPrefix,
2042:                                        namespaceImportsMap,
2043:                                        namespacePrefixMap, cmplxTypeSequence);
2044:                            } else {
2045:                                throw new WSDLProcessingException(
2046:                                        "the parameter order can left atmost"
2047:                                                + " one part");
2048:                            }
2049:                        }
2050:                    }
2051:                }
2052:
2053:                newComplexType.appendChild(cmplxTypeSequence);
2054:                return newComplexType;
2055:            }
2056:
2057:            private void addPartToElement(Part part, Document document,
2058:                    String xsdPrefix, Map namespaceImportsMap,
2059:                    Map namespacePrefixMap, Element cmplxTypeSequence) {
2060:                Element child;
2061:                String elementName = part.getName();
2062:
2063:                // the type name
2064:                QName schemaTypeName = part.getTypeName();
2065:
2066:                if (schemaTypeName != null) {
2067:
2068:                    child = document.createElementNS(XMLSCHEMA_NAMESPACE_URI,
2069:                            xsdPrefix + ":" + XML_SCHEMA_ELEMENT_LOCAL_NAME);
2070:                    // always child attribute should be in no namespace
2071:                    child.setAttribute("form", "unqualified");
2072:
2073:                    String prefix;
2074:                    if (XMLSCHEMA_NAMESPACE_URI.equals(schemaTypeName
2075:                            .getNamespaceURI())) {
2076:                        prefix = xsdPrefix;
2077:                    } else {
2078:                        // this schema is a third party one. So we need to have
2079:                        // an import statement in our generated schema
2080:                        String uri = schemaTypeName.getNamespaceURI();
2081:                        if (!namespaceImportsMap.containsKey(uri)) {
2082:                            // create Element for namespace import
2083:                            Element namespaceImport = document.createElementNS(
2084:                                    XMLSCHEMA_NAMESPACE_URI, xsdPrefix + ":"
2085:                                            + XML_SCHEMA_IMPORT_LOCAL_NAME);
2086:                            namespaceImport.setAttribute(NAMESPACE_URI, uri);
2087:                            // add this to the map
2088:                            namespaceImportsMap.put(uri, namespaceImport);
2089:                            // we also need to associate this uri with a prefix
2090:                            // and include that prefix
2091:                            // in the schema's namspace declarations. So add
2092:                            // theis particular namespace to the
2093:                            // prefix map as well
2094:                            prefix = getTemporaryNamespacePrefix();
2095:                            namespacePrefixMap.put(uri, prefix);
2096:                        } else {
2097:                            // this URI should be already in the namspace prefix
2098:                            // map
2099:                            prefix = (String) namespacePrefixMap.get(uri);
2100:                        }
2101:
2102:                    }
2103:
2104:                    child.setAttribute(XSD_NAME, elementName);
2105:                    child.setAttribute(XSD_TYPE, prefix + ":"
2106:                            + schemaTypeName.getLocalPart());
2107:                    cmplxTypeSequence.appendChild(child);
2108:
2109:                } else {
2110:                    // see the basic profile 4.4.1 for rpc-literal messages parts can have only types
2111:                    throw new WSDLProcessingException(
2112:                            "RPC-literal type message part " + part.getName()
2113:                                    + " should have a type attribute ");
2114:                }
2115:            }
2116:
2117:            /**
2118:             * @param prefixMap
2119:             */
2120:            private void checkAndAddNamespaceDeclarations(String namespace,
2121:                    Map prefixMap, Element schemaElement) {
2122:                // get the attribute for the current namespace
2123:                String prefix = (String) prefixMap.get(namespace);
2124:                // A prefix must be found at this point!
2125:                String existingURL = schemaElement.getAttributeNS(
2126:                        XML_NAMESPACE_URI, NAMESPACE_DECLARATION_PREFIX
2127:                                + prefix);
2128:                if (existingURL == null || existingURL.length() == 0) {
2129:                    // there is no existing URL by that prefix - declare a new namespace
2130:                    schemaElement.setAttributeNS(XML_NAMESPACE_URI,
2131:                            NAMESPACE_DECLARATION_PREFIX + prefix, namespace);
2132:                } else if (existingURL.equals(namespace)) {
2133:                    // this namespace declaration is already there with the same prefix
2134:                    // ignore it
2135:                } else {
2136:                    // there is a different namespace declared in the given prefix
2137:                    // change the prefix in the prefix map to a new one and declare it
2138:
2139:                    // create a prefix
2140:                    String generatedPrefix = "ns" + prefixCounter++;
2141:                    while (prefixMap.containsKey(generatedPrefix)) {
2142:                        generatedPrefix = "ns" + prefixCounter++;
2143:                    }
2144:                    schemaElement.setAttributeNS(XML_NAMESPACE_URI,
2145:                            NAMESPACE_DECLARATION_PREFIX + generatedPrefix,
2146:                            namespace);
2147:                    // add to the map
2148:                    prefixMap.put(namespace, generatedPrefix);
2149:                }
2150:
2151:            }
2152:
2153:            /**
2154:             * Read the WSDL file given the inputstream for the WSDL source
2155:             *
2156:             * @param in
2157:             * @throws WSDLException
2158:             */
2159:            private Definition readInTheWSDLFile(InputStream in)
2160:                    throws WSDLException {
2161:
2162:                WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
2163:
2164:                // switch off the verbose mode for all usecases
2165:                reader.setFeature(JAVAX_WSDL_VERBOSE_MODE_KEY, false);
2166:
2167:                // if the custem resolver is present then use it
2168:                if (customWSLD4JResolver != null) {
2169:                    return reader.readWSDL(customWSLD4JResolver);
2170:                } else {
2171:                    Document doc;
2172:                    try {
2173:                        doc = XMLUtils.newDocument(in);
2174:                    } catch (ParserConfigurationException e) {
2175:                        throw new WSDLException(WSDLException.PARSER_ERROR,
2176:                                "Parser Configuration Error", e);
2177:                    } catch (SAXException e) {
2178:                        throw new WSDLException(WSDLException.PARSER_ERROR,
2179:                                "Parser SAX Error", e);
2180:
2181:                    } catch (IOException e) {
2182:                        throw new WSDLException(WSDLException.INVALID_WSDL,
2183:                                "IO Error", e);
2184:                    }
2185:                    return reader.readWSDL(getBaseUri(), doc);
2186:                }
2187:            }
2188:
2189:            /**
2190:             * Get the Extensible elements form wsdl4jExtensibleElements
2191:             * <code>Vector</code> if any and copy them to <code>Component</code>
2192:             * <p/> Note - SOAP body extensible element will be processed differently
2193:             *
2194:             * @param wsdl4jExtensibleElements
2195:             * @param description                   where is the ext element (port , portype , biding)
2196:             * @param wsdl4jDefinition
2197:             * @param originOfExtensibilityElements -
2198:             *                                      this will indicate the place this extensibility element came
2199:             *                                      from.
2200:             */
2201:            private void copyExtensibleElements(List wsdl4jExtensibleElements,
2202:                    Definition wsdl4jDefinition, AxisDescription description,
2203:                    String originOfExtensibilityElements) throws AxisFault {
2204:
2205:                ExtensibilityElement wsdl4jExtensibilityElement;
2206:
2207:                for (Iterator iterator = wsdl4jExtensibleElements.iterator(); iterator
2208:                        .hasNext();) {
2209:
2210:                    wsdl4jExtensibilityElement = (ExtensibilityElement) iterator
2211:                            .next();
2212:
2213:                    if (wsdl4jExtensibilityElement instanceof  UnknownExtensibilityElement) {
2214:
2215:                        UnknownExtensibilityElement unknown = (UnknownExtensibilityElement) (wsdl4jExtensibilityElement);
2216:                        QName type = unknown.getElementType();
2217:
2218:                        // <wsp:Policy>
2219:                        if (WSDLConstants.WSDL11Constants.POLICY.equals(type)) {
2220:                            if (isTraceEnabled) {
2221:                                log
2222:                                        .trace("copyExtensibleElements:: PolicyElement found "
2223:                                                + unknown);
2224:                            }
2225:                            Policy policy = (Policy) PolicyUtil
2226:                                    .getPolicyComponent(unknown.getElement());
2227:                            int attachmentScope = getPolicyAttachmentPoint(
2228:                                    description, originOfExtensibilityElements);
2229:                            if (attachmentScope > -1) {
2230:                                description.getPolicyInclude()
2231:                                        .addPolicyElement(attachmentScope,
2232:                                                policy);
2233:                            }
2234:                            // <wsp:PolicyReference>
2235:                        } else if (WSDLConstants.WSDL11Constants.POLICY_REFERENCE
2236:                                .equals(type)) {
2237:                            if (isTraceEnabled) {
2238:                                log
2239:                                        .trace("copyExtensibleElements:: PolicyReference found "
2240:                                                + unknown);
2241:                            }
2242:                            PolicyReference policyReference = (PolicyReference) PolicyUtil
2243:                                    .getPolicyComponent(unknown.getElement());
2244:                            int attachmentScope = getPolicyAttachmentPoint(
2245:                                    description, originOfExtensibilityElements);
2246:                            if (attachmentScope > -1) {
2247:                                description.getPolicyInclude()
2248:                                        .addPolicyRefElement(attachmentScope,
2249:                                                policyReference);
2250:                            }
2251:                        } else if (AddressingConstants.Final.WSAW_USING_ADDRESSING
2252:                                .equals(type)
2253:                                || AddressingConstants.Submission.WSAW_USING_ADDRESSING
2254:                                        .equals(unknown.getElementType())) {
2255:                            if (isTraceEnabled) {
2256:                                log
2257:                                        .trace("copyExtensibleElements:: wsaw:UsingAddressing found "
2258:                                                + unknown);
2259:                            }
2260:                            // FIXME We need to set this the appropriate Axis Description AxisEndpoint or
2261:                            // AxisBinding .
2262:                            if (originOfExtensibilityElements.equals(PORT)
2263:                                    || originOfExtensibilityElements
2264:                                            .equals(BINDING)) {
2265:                                if (Boolean.TRUE.equals(unknown.getRequired())) {
2266:                                    axisService
2267:                                            .setWSAddressingFlag(AddressingConstants.ADDRESSING_REQUIRED);
2268:                                } else {
2269:                                    axisService
2270:                                            .setWSAddressingFlag(AddressingConstants.ADDRESSING_OPTIONAL);
2271:                                }
2272:                            }
2273:
2274:                        } else if (AddressingConstants.Final.WSAW_ANONYMOUS
2275:                                .equals(unknown.getElementType())) {
2276:                            if (originOfExtensibilityElements
2277:                                    .equals(BINDING_OPERATION)) {
2278:                                AxisOperation axisOperation = (AxisOperation) description;
2279:                                if (unknown.getElement().getFirstChild() != null
2280:                                        && unknown.getElement().getFirstChild()
2281:                                                .getNodeType() == Node.TEXT_NODE) {
2282:                                    String anonymousValue = unknown
2283:                                            .getElement().getFirstChild()
2284:                                            .getNodeValue();
2285:                                    AddressingHelper
2286:                                            .setAnonymousParameterValue(
2287:                                                    axisOperation,
2288:                                                    anonymousValue);
2289:                                }
2290:                            }
2291:
2292:                        } else {
2293:                            // Ignore this element - it is a totally unknown element
2294:                            if (isTraceEnabled) {
2295:                                log
2296:                                        .trace("copyExtensibleElements:: Unknown Extensibility Element found "
2297:                                                + unknown);
2298:                            }
2299:                        }
2300:
2301:                    } else if (wsdl4jExtensibilityElement instanceof  SOAP12Address) {
2302:                        SOAP12Address soapAddress = (SOAP12Address) wsdl4jExtensibilityElement;
2303:                        if (description instanceof  AxisEndpoint) {
2304:                            ((AxisEndpoint) description)
2305:                                    .setEndpointURL(soapAddress
2306:                                            .getLocationURI());
2307:                        }
2308:
2309:                    } else if (wsdl4jExtensibilityElement instanceof  SOAPAddress) {
2310:                        SOAPAddress soapAddress = (SOAPAddress) wsdl4jExtensibilityElement;
2311:                        if (description instanceof  AxisEndpoint) {
2312:                            ((AxisEndpoint) description)
2313:                                    .setEndpointURL(soapAddress
2314:                                            .getLocationURI());
2315:                        }
2316:                    } else if (wsdl4jExtensibilityElement instanceof  HTTPAddress) {
2317:                        HTTPAddress httpAddress = (HTTPAddress) wsdl4jExtensibilityElement;
2318:                        if (description instanceof  AxisEndpoint) {
2319:                            ((AxisEndpoint) description)
2320:                                    .setEndpointURL(httpAddress
2321:                                            .getLocationURI());
2322:                        }
2323:
2324:                    } else if (wsdl4jExtensibilityElement instanceof  Schema) {
2325:                        Schema schema = (Schema) wsdl4jExtensibilityElement;
2326:                        // just add this schema - no need to worry about the imported
2327:                        // ones
2328:                        axisService.addSchema(getXMLSchema(schema.getElement(),
2329:                                schema.getDocumentBaseURI()));
2330:
2331:                    } else if (wsdl4jExtensibilityElement instanceof  SOAP12Operation) {
2332:                        SOAP12Operation soapOperation = (SOAP12Operation) wsdl4jExtensibilityElement;
2333:                        AxisBindingOperation axisBindingOperation = (AxisBindingOperation) description;
2334:
2335:                        String style = soapOperation.getStyle();
2336:                        if (style != null) {
2337:                            axisBindingOperation.setProperty(
2338:                                    WSDLConstants.WSDL_1_1_STYLE, style);
2339:                        }
2340:
2341:                        String soapActionURI = soapOperation.getSoapActionURI();
2342:                        if (soapActionURI != null) {
2343:                            axisBindingOperation.setProperty(
2344:                                    WSDL2Constants.ATTR_WSOAP_ACTION,
2345:                                    soapActionURI);
2346:                            axisBindingOperation.getAxisOperation()
2347:                                    .setSoapAction(soapActionURI);
2348:                            axisService.mapActionToOperation(soapActionURI,
2349:                                    axisBindingOperation.getAxisOperation());
2350:                        }
2351:
2352:                    } else if (wsdl4jExtensibilityElement instanceof  SOAPOperation) {
2353:                        SOAPOperation soapOperation = (SOAPOperation) wsdl4jExtensibilityElement;
2354:                        AxisBindingOperation axisBindingOperation = (AxisBindingOperation) description;
2355:
2356:                        String style = soapOperation.getStyle();
2357:                        if (style != null) {
2358:                            axisBindingOperation.setProperty(
2359:                                    WSDLConstants.WSDL_1_1_STYLE, style);
2360:                        }
2361:
2362:                        String soapAction = soapOperation.getSoapActionURI();
2363:                        if ((soapAction != null) && (!soapAction.equals(""))) {
2364:                            axisBindingOperation.setProperty(
2365:                                    WSDL2Constants.ATTR_WSOAP_ACTION,
2366:                                    soapAction);
2367:                            if (isServerSide) {
2368:                                axisBindingOperation.getAxisOperation()
2369:                                        .setSoapAction(soapAction);
2370:                            } else {
2371:                                axisBindingOperation.getAxisOperation()
2372:                                        .setOutputAction(soapAction);
2373:                            }
2374:
2375:                            axisService.mapActionToOperation(soapAction,
2376:                                    axisBindingOperation.getAxisOperation());
2377:                        }
2378:                    } else if (wsdl4jExtensibilityElement instanceof  HTTPOperation) {
2379:                        HTTPOperation httpOperation = (HTTPOperation) wsdl4jExtensibilityElement;
2380:                        AxisBindingOperation axisBindingOperation = (AxisBindingOperation) description;
2381:
2382:                        String httpLocation = httpOperation.getLocationURI();
2383:                        if (httpLocation != null) {
2384:                            // change the template to make it same as WSDL 2 template
2385:                            httpLocation = httpLocation.replaceAll("\\(", "{");
2386:                            httpLocation = httpLocation.replaceAll("\\)", "}");
2387:                            axisBindingOperation.setProperty(
2388:                                    WSDL2Constants.ATTR_WHTTP_LOCATION,
2389:                                    httpLocation);
2390:
2391:                        }
2392:                        axisBindingOperation.setProperty(
2393:                                WSDL2Constants.ATTR_WHTTP_INPUT_SERIALIZATION,
2394:                                HTTPConstants.MEDIA_TYPE_X_WWW_FORM);
2395:
2396:                    } else if (wsdl4jExtensibilityElement instanceof  SOAP12Header) {
2397:
2398:                        SOAP12Header soapHeader = (SOAP12Header) wsdl4jExtensibilityElement;
2399:                        SOAPHeaderMessage headerMessage = new SOAPHeaderMessage();
2400:
2401:                        headerMessage.setNamespaceURI(soapHeader
2402:                                .getNamespaceURI());
2403:                        headerMessage.setUse(soapHeader.getUse());
2404:
2405:                        Boolean required = soapHeader.getRequired();
2406:
2407:                        if (required != null) {
2408:                            headerMessage.setRequired(required.booleanValue());
2409:                        }
2410:
2411:                        if (wsdl4jDefinition != null) {
2412:                            // find the relevant schema part from the messages
2413:                            Message msg = wsdl4jDefinition
2414:                                    .getMessage(soapHeader.getMessage());
2415:
2416:                            if (msg == null) {
2417:                                // TODO i18n this
2418:                                throw new AxisFault("message "
2419:                                        + soapHeader.getMessage()
2420:                                        + " not found in the WSDL ");
2421:                            }
2422:                            Part msgPart = msg.getPart(soapHeader.getPart());
2423:
2424:                            if (msgPart == null) {
2425:                                // TODO i18n this
2426:                                throw new AxisFault("message part "
2427:                                        + soapHeader.getPart()
2428:                                        + " not found in the WSDL ");
2429:                            }
2430:                            // see basic profile 4.4.2 Bindings and Faults header, fault and headerfaults
2431:                            // can only have elements
2432:                            headerMessage.setElement(msgPart.getElementName());
2433:                        }
2434:
2435:                        headerMessage.setMessage(soapHeader.getMessage());
2436:                        headerMessage.setPart(soapHeader.getPart());
2437:
2438:                        if (description instanceof  AxisBindingMessage) {
2439:                            AxisBindingMessage bindingMessage = (AxisBindingMessage) description;
2440:                            List soapHeaders = (List) bindingMessage
2441:                                    .getProperty(WSDL2Constants.ATTR_WSOAP_HEADER);
2442:                            if (soapHeaders == null) {
2443:                                soapHeaders = new ArrayList();
2444:                                bindingMessage.setProperty(
2445:                                        WSDL2Constants.ATTR_WSOAP_HEADER,
2446:                                        soapHeaders);
2447:                            }
2448:                            soapHeaders.add(headerMessage);
2449:                        }
2450:
2451:                    } else if (wsdl4jExtensibilityElement instanceof  SOAPHeader) {
2452:
2453:                        SOAPHeader soapHeader = (SOAPHeader) wsdl4jExtensibilityElement;
2454:                        SOAPHeaderMessage headerMessage = new SOAPHeaderMessage();
2455:                        headerMessage.setNamespaceURI(soapHeader
2456:                                .getNamespaceURI());
2457:                        headerMessage.setUse(soapHeader.getUse());
2458:                        Boolean required = soapHeader.getRequired();
2459:                        if (null != required) {
2460:                            headerMessage.setRequired(required.booleanValue());
2461:                        }
2462:                        if (null != wsdl4jDefinition) {
2463:                            // find the relevant schema part from the messages
2464:                            Message msg = wsdl4jDefinition
2465:                                    .getMessage(soapHeader.getMessage());
2466:                            if (msg == null) {
2467:                                // todo i18n this
2468:                                throw new AxisFault("message "
2469:                                        + soapHeader.getMessage()
2470:                                        + " not found in the WSDL ");
2471:                            }
2472:                            Part msgPart = msg.getPart(soapHeader.getPart());
2473:                            if (msgPart == null) {
2474:                                // todo i18n this
2475:                                throw new AxisFault("message part "
2476:                                        + soapHeader.getPart()
2477:                                        + " not found in the WSDL ");
2478:                            }
2479:                            headerMessage.setElement(msgPart.getElementName());
2480:                        }
2481:                        headerMessage.setMessage(soapHeader.getMessage());
2482:
2483:                        headerMessage.setPart(soapHeader.getPart());
2484:
2485:                        if (description instanceof  AxisBindingMessage) {
2486:                            AxisBindingMessage bindingMessage = (AxisBindingMessage) description;
2487:                            List soapHeaders = (List) bindingMessage
2488:                                    .getProperty(WSDL2Constants.ATTR_WSOAP_HEADER);
2489:                            if (soapHeaders == null) {
2490:                                soapHeaders = new ArrayList();
2491:                                bindingMessage.setProperty(
2492:                                        WSDL2Constants.ATTR_WSOAP_HEADER,
2493:                                        soapHeaders);
2494:                            }
2495:                            soapHeaders.add(headerMessage);
2496:                        }
2497:                    } else if (wsdl4jExtensibilityElement instanceof  SOAPBinding) {
2498:
2499:                        SOAPBinding soapBinding = (SOAPBinding) wsdl4jExtensibilityElement;
2500:                        AxisBinding axisBinding = (AxisBinding) description;
2501:
2502:                        axisBinding.setType(soapBinding.getTransportURI());
2503:
2504:                        axisBinding.setProperty(
2505:                                WSDL2Constants.ATTR_WSOAP_VERSION,
2506:                                SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
2507:
2508:                        String style = soapBinding.getStyle();
2509:                        if (style != null) {
2510:                            axisBinding.setProperty(
2511:                                    WSDLConstants.WSDL_1_1_STYLE, style);
2512:                        }
2513:
2514:                    } else if (wsdl4jExtensibilityElement instanceof  SOAP12Binding) {
2515:
2516:                        SOAP12Binding soapBinding = (SOAP12Binding) wsdl4jExtensibilityElement;
2517:                        AxisBinding axisBinding = (AxisBinding) description;
2518:
2519:                        axisBinding.setProperty(
2520:                                WSDL2Constants.ATTR_WSOAP_VERSION,
2521:                                SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
2522:
2523:                        String style = soapBinding.getStyle();
2524:                        if (style != null) {
2525:                            axisBinding.setProperty(
2526:                                    WSDLConstants.WSDL_1_1_STYLE, style);
2527:                        }
2528:
2529:                        String transportURI = soapBinding.getTransportURI();
2530:                        axisBinding.setType(transportURI);
2531:
2532:                    } else if (wsdl4jExtensibilityElement instanceof  HTTPBinding) {
2533:                        HTTPBinding httpBinding = (HTTPBinding) wsdl4jExtensibilityElement;
2534:                        AxisBinding axisBinding = (AxisBinding) description;
2535:                        // set the binding style same as the wsd2 to process smoothly
2536:                        axisBinding.setType(WSDL2Constants.URI_WSDL2_HTTP);
2537:                        axisBinding.setProperty(
2538:                                WSDL2Constants.ATTR_WHTTP_METHOD, httpBinding
2539:                                        .getVerb());
2540:                    }
2541:                }
2542:            }
2543:
2544:            private int getPolicyAttachmentPoint(AxisDescription description,
2545:                    String originOfExtensibilityElements) {
2546:                int result = -1; // Attachment Point Not Identified
2547:
2548:                if (SERVICE.equals(originOfExtensibilityElements)) {
2549:                    result = PolicyInclude.SERVICE_POLICY;
2550:                } else if (PORT.equals(originOfExtensibilityElements)) {
2551:                    result = PolicyInclude.PORT_POLICY;
2552:                } else if (BINDING.equals(originOfExtensibilityElements)) {
2553:                    result = PolicyInclude.BINDING_POLICY;
2554:                } else if (BINDING_OPERATION
2555:                        .equals(originOfExtensibilityElements)) {
2556:                    result = PolicyInclude.BINDING_OPERATION_POLICY;
2557:                } else if (BINDING_OPERATION_INPUT
2558:                        .equals(originOfExtensibilityElements)) {
2559:                    result = PolicyInclude.BINDING_INPUT_POLICY;
2560:                } else if (BINDING_OPERATION_OUTPUT
2561:                        .equals(originOfExtensibilityElements)) {
2562:                    result = PolicyInclude.BINDING_OUTPUT_POLICY;
2563:                } else if (PORT_TYPE.equals(originOfExtensibilityElements)) {
2564:                    result = PolicyInclude.PORT_TYPE_POLICY;
2565:                } else if (PORT_TYPE_OPERATION
2566:                        .equals(originOfExtensibilityElements)) {
2567:                    result = PolicyInclude.OPERATION_POLICY;
2568:                } else if (PORT_TYPE_OPERATION_INPUT
2569:                        .equals(originOfExtensibilityElements)) {
2570:                    result = PolicyInclude.INPUT_POLICY;
2571:                } else if (PORT_TYPE_OPERATION_OUTPUT
2572:                        .equals(originOfExtensibilityElements)) {
2573:                    result = PolicyInclude.OUTPUT_POLICY;
2574:                }
2575:
2576:                if (isTraceEnabled) {
2577:                    log.trace("getPolicyAttachmentPoint:: axisDescription="
2578:                            + description + " extensibilityPoint="
2579:                            + originOfExtensibilityElements + " result="
2580:                            + result);
2581:                }
2582:
2583:                return result;
2584:            }
2585:
2586:            /**
2587:             * Look for the wrappable operations depending on the style
2588:             *
2589:             * @param binding
2590:             */
2591:            private List findWrappableBindingOperations(Binding binding) {
2592:                // first find the global style declaration.
2593:                // for a SOAP binding this can be only rpc or document
2594:                // as per the WSDL spec (section 3.4) the default style is document
2595:
2596:                // now we have to handle the http bindings case as well
2597:                //
2598:
2599:                boolean isRPC = false;
2600:                boolean isSOAPBinding = false;
2601:                boolean isHttpBinding = false;
2602:
2603:                List extElements = binding.getExtensibilityElements();
2604:                for (int i = 0; i < extElements.size(); i++) {
2605:                    if (extElements.get(i) instanceof  SOAPBinding) {
2606:                        // we have a global SOAP binding!
2607:                        isSOAPBinding = true;
2608:                        SOAPBinding soapBinding = (SOAPBinding) extElements
2609:                                .get(i);
2610:                        if (RPC_STYLE.equals(soapBinding.getStyle())) {
2611:                            // set the global style to rpc
2612:                            isRPC = true;
2613:                        }
2614:                        this .bindingType = BINDING_TYPE_SOAP;
2615:                        break;
2616:                    } else if (extElements.get(i) instanceof  SOAP12Binding) {
2617:                        // we have a global SOAP binding!
2618:                        isSOAPBinding = true;
2619:                        SOAP12Binding soapBinding = (SOAP12Binding) extElements
2620:                                .get(i);
2621:                        if (RPC_STYLE.equals(soapBinding.getStyle())) {
2622:                            // set the global style to rpc
2623:                            isRPC = true;
2624:                        }
2625:                        this .bindingType = BINDING_TYPE_SOAP;
2626:                        break;
2627:                    } else if (extElements.get(i) instanceof  HTTPBinding) {
2628:                        isHttpBinding = true;
2629:                        this .bindingType = BINDING_TYPE_HTTP;
2630:                    }
2631:                }
2632:
2633:                // go through every operation and get their styles.
2634:                // each one can have a style override from the global
2635:                // styles. Depending on the style add the relevant operations
2636:                // to the return list
2637:                List returnList = new ArrayList();
2638:
2639:                if (isHttpBinding || isSOAPBinding) {
2640:                    BindingOperation bindingOp;
2641:                    for (Iterator bindingOperationsIterator = binding
2642:                            .getBindingOperations().iterator(); bindingOperationsIterator
2643:                            .hasNext();) {
2644:                        bindingOp = (BindingOperation) bindingOperationsIterator
2645:                                .next();
2646:                        if (isSOAPBinding) {
2647:                            String style = getSOAPStyle(bindingOp);
2648:                            if (style == null) {
2649:                                // no style specified
2650:                                // use the global style to determine whether to put this one or
2651:                                // not
2652:                                if (isRPC) {
2653:                                    returnList.add(bindingOp);
2654:                                }
2655:                            } else if (RPC_STYLE.equals(style)) {
2656:                                // add to the list
2657:                                returnList.add(bindingOp);
2658:                            }
2659:                            // if not RPC we just leave it - default is doc
2660:                        } else {
2661:                            // i.e an http binding then we have to add the operation any way
2662:                            returnList.add(bindingOp);
2663:                        }
2664:                    }
2665:                }
2666:
2667:                // if the binding is not either soap or http binding then we return and empty list
2668:
2669:                // set this to the global list
2670:                wrappableOperations = returnList;
2671:                return returnList;
2672:            }
2673:
2674:            /**
2675:             * Guess the MEP based on the order of messages
2676:             *
2677:             * @param operation
2678:             * @throws AxisFault
2679:             */
2680:            private String getMEP(Operation operation) throws AxisFault {
2681:                OperationType operationType = operation.getStyle();
2682:                if (isServerSide) {
2683:                    if (operationType != null) {
2684:                        if (operationType
2685:                                .equals(OperationType.REQUEST_RESPONSE)) {
2686:                            return WSDL2Constants.MEP_URI_IN_OUT;
2687:                        }
2688:
2689:                        if (operationType.equals(OperationType.ONE_WAY)) {
2690:                            if (operation.getFaults().size() > 0) {
2691:                                return WSDL2Constants.MEP_URI_ROBUST_IN_ONLY;
2692:                            }
2693:                            return WSDL2Constants.MEP_URI_IN_ONLY;
2694:                        }
2695:
2696:                        if (operationType.equals(OperationType.NOTIFICATION)) {
2697:                            return WSDL2Constants.MEP_URI_OUT_ONLY;
2698:                        }
2699:
2700:                        if (operationType
2701:                                .equals(OperationType.SOLICIT_RESPONSE)) {
2702:                            return WSDL2Constants.MEP_URI_OUT_IN;
2703:                        }
2704:                        throw new AxisFault("Cannot Determine the MEP");
2705:                    }
2706:                } else {
2707:                    if (operationType != null) {
2708:                        if (operationType
2709:                                .equals(OperationType.REQUEST_RESPONSE)) {
2710:                            return WSDL2Constants.MEP_URI_OUT_IN;
2711:                        }
2712:
2713:                        if (operationType.equals(OperationType.ONE_WAY)) {
2714:                            return WSDL2Constants.MEP_URI_OUT_ONLY;
2715:                        }
2716:
2717:                        if (operationType.equals(OperationType.NOTIFICATION)) {
2718:                            return WSDL2Constants.MEP_URI_IN_ONLY;
2719:                        }
2720:
2721:                        if (operationType
2722:                                .equals(OperationType.SOLICIT_RESPONSE)) {
2723:                            return WSDL2Constants.MEP_URI_IN_OUT;
2724:                        }
2725:                        throw new AxisFault("Cannot Determine the MEP");
2726:                    }
2727:                }
2728:                throw new AxisFault("Cannot Determine the MEP");
2729:            }
2730:
2731:            /**
2732:             * Copies the extension attributes
2733:             *
2734:             * @param extAttributes
2735:             * @param description
2736:             * @param origin
2737:             */
2738:            private void copyExtensionAttributes(Map extAttributes,
2739:                    AxisDescription description, String origin) {
2740:
2741:                QName key;
2742:                QName value;
2743:
2744:                for (Iterator iterator = extAttributes.keySet().iterator(); iterator
2745:                        .hasNext();) {
2746:                    key = (QName) iterator.next();
2747:
2748:                    if (Constants.URI_POLICY_NS.equals(key.getNamespaceURI())
2749:                            && "PolicyURIs".equals(key.getLocalPart())) {
2750:
2751:                        value = (QName) extAttributes.get(key);
2752:                        String policyURIs = value.getLocalPart();
2753:
2754:                        if (policyURIs.length() != 0) {
2755:                            String[] uris = policyURIs.split(" ");
2756:
2757:                            PolicyReference ref;
2758:                            for (int i = 0; i < uris.length; i++) {
2759:                                ref = new PolicyReference();
2760:                                ref.setURI(uris[i]);
2761:
2762:                                if (PORT_TYPE.equals(origin)) {
2763:                                    PolicyInclude include = description
2764:                                            .getPolicyInclude();
2765:                                    include
2766:                                            .addPolicyRefElement(
2767:                                                    PolicyInclude.PORT_TYPE_POLICY,
2768:                                                    ref);
2769:                                }
2770:                            }
2771:                        }
2772:                    }
2773:                }
2774:            }
2775:
2776:            /**
2777:             * Process the policy definitions
2778:             *
2779:             * @param definition
2780:             */
2781:            private void processPoliciesInDefintion(Definition definition) {
2782:                processPoliciesInDefintion(definition, new Stack());
2783:            }
2784:
2785:            /**
2786:             * Process the policy definitions
2787:             *
2788:             * @param definition
2789:             */
2790:            private void processPoliciesInDefintion(Definition definition,
2791:                    Stack stack) {
2792:                stack.push(definition);
2793:                List extElements = definition.getExtensibilityElements();
2794:                ExtensibilityElement extElement;
2795:                UnknownExtensibilityElement unknown = null;
2796:                Policy policy = null;
2797:
2798:                for (Iterator iterator = extElements.iterator(); iterator
2799:                        .hasNext();) {
2800:                    extElement = (ExtensibilityElement) iterator.next();
2801:
2802:                    if (extElement instanceof  UnknownExtensibilityElement) {
2803:                        unknown = (UnknownExtensibilityElement) extElement;
2804:                        if (WSDLConstants.WSDL11Constants.POLICY.equals(unknown
2805:                                .getElementType())) {
2806:
2807:                            policy = (Policy) PolicyUtil
2808:                                    .getPolicyComponent(unknown.getElement());
2809:                            String key;
2810:                            if ((key = policy.getName()) != null
2811:                                    || (key = policy.getId()) != null) {
2812:                                registry.register(key, policy);
2813:                                registry.register("#" + key, policy);
2814:                            }
2815:
2816:                        }
2817:                    }
2818:                }
2819:                // include policices in other imported wsdls
2820:                Iterator iter = definition.getImports().values().iterator();
2821:                Vector values = null;
2822:                Import wsdlImport = null;
2823:                for (; iter.hasNext();) {
2824:                    values = (Vector) iter.next();
2825:                    for (Iterator valuesIter = values.iterator(); valuesIter
2826:                            .hasNext();) {
2827:                        wsdlImport = (Import) valuesIter.next();
2828:                        Definition innerDefinition = wsdlImport.getDefinition();
2829:                        // find the binding recursively
2830:                        if (!stack.contains(innerDefinition)) {
2831:                            processPoliciesInDefintion(innerDefinition, stack);
2832:                        }
2833:                    }
2834:                }
2835:                stack.pop();
2836:            }
2837:
2838:            /**
2839:             * Inner class declaration for the processing exceptions
2840:             */
2841:            public static class WSDLProcessingException extends
2842:                    RuntimeException {
2843:                public WSDLProcessingException() {
2844:                }
2845:
2846:                public WSDLProcessingException(String message) {
2847:                    super (message);
2848:                }
2849:
2850:                public WSDLProcessingException(Throwable cause) {
2851:                    super (cause);
2852:                }
2853:
2854:                public WSDLProcessingException(String message, Throwable cause) {
2855:                    super (message, cause);
2856:                }
2857:
2858:            }
2859:
2860:            public boolean isAllPorts() {
2861:                return isAllPorts;
2862:            }
2863:
2864:            public void setAllPorts(boolean allPorts) {
2865:                isAllPorts = allPorts;
2866:            }
2867:
2868:            //    private void processPoliciesInDefinition() {
2869:            //        
2870:            //        Object obj;
2871:            //        for (Iterator iterator = wsdl4jDefinition.getExtensibilityElements().iterator(); iterator.hasNext();) {
2872:            //            obj = iterator.next();
2873:            //            
2874:            //            if (obj instanceof UnknownExtensibilityElement) {
2875:            //                Element e = ((UnknownExtensibilityElement) obj).getElement();
2876:            //                if (WSDLConstants.WSDL11Constants.POLICY.getNamespaceURI().equals(e.getNamespaceURI()) &&
2877:            //                        WSDLConstants.WSDL11Constants.POLICY.getLocalPart().equals(e.getLocalName())) {
2878:            //                    Policy p = (Policy) PolicyUtil.getPolicyComponent(e);
2879:            //                    reg.register(p.getId(), p);
2880:            //                }
2881:            //            }
2882:            //        }
2883:            //    }
2884:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.