Source Code Cross Referenced for WSDL20ToAxisServiceBuilder.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 org.apache.axiom.soap.SOAP11Constants;
0022:        import org.apache.axiom.soap.SOAP12Constants;
0023:        import org.apache.axiom.om.OMAbstractFactory;
0024:        import org.apache.axiom.om.OMFactory;
0025:        import org.apache.axiom.om.OMNamespace;
0026:        import org.apache.axis2.AxisFault;
0027:        import org.apache.axis2.namespace.Constants;
0028:        import org.apache.axis2.transport.http.util.RESTUtil;
0029:        import org.apache.axis2.wsdl.HTTPHeaderMessage;
0030:        import org.apache.axis2.wsdl.SOAPHeaderMessage;
0031:        import org.apache.axis2.wsdl.SOAPModuleMessage;
0032:        import org.apache.axis2.wsdl.WSDLConstants;
0033:        import org.apache.woden.WSDLException;
0034:        import org.apache.woden.WSDLFactory;
0035:        import org.apache.woden.WSDLReader;
0036:        import org.apache.woden.WSDLSource;
0037:        import org.apache.woden.internal.DOMWSDLFactory;
0038:        import org.apache.woden.internal.wsdl20.extensions.InterfaceOperationExtensionsImpl;
0039:        import org.apache.woden.internal.wsdl20.extensions.http.HTTPBindingExtensionsImpl;
0040:        import org.apache.woden.internal.wsdl20.extensions.http.HTTPHeaderImpl;
0041:        import org.apache.woden.internal.wsdl20.extensions.soap.SOAPBindingExtensionsImpl;
0042:        import org.apache.woden.internal.wsdl20.BindingFaultImpl;
0043:        import org.apache.woden.internal.wsdl20.BindingOperationImpl;
0044:        import org.apache.woden.schema.Schema;
0045:        import org.apache.woden.wsdl20.Binding;
0046:        import org.apache.woden.wsdl20.BindingFault;
0047:        import org.apache.woden.wsdl20.BindingFaultReference;
0048:        import org.apache.woden.wsdl20.BindingMessageReference;
0049:        import org.apache.woden.wsdl20.BindingOperation;
0050:        import org.apache.woden.wsdl20.Description;
0051:        import org.apache.woden.wsdl20.ElementDeclaration;
0052:        import org.apache.woden.wsdl20.Endpoint;
0053:        import org.apache.woden.wsdl20.Interface;
0054:        import org.apache.woden.wsdl20.InterfaceFault;
0055:        import org.apache.woden.wsdl20.InterfaceFaultReference;
0056:        import org.apache.woden.wsdl20.InterfaceMessageReference;
0057:        import org.apache.woden.wsdl20.InterfaceOperation;
0058:        import org.apache.woden.wsdl20.Service;
0059:        import org.apache.woden.wsdl20.WSDLComponent;
0060:        import org.apache.woden.wsdl20.enumeration.MessageLabel;
0061:        import org.apache.woden.wsdl20.extensions.http.HTTPBindingFaultExtensions;
0062:        import org.apache.woden.wsdl20.extensions.http.HTTPBindingMessageReferenceExtensions;
0063:        import org.apache.woden.wsdl20.extensions.http.HTTPBindingOperationExtensions;
0064:        import org.apache.woden.wsdl20.extensions.http.HTTPHeader;
0065:        import org.apache.woden.wsdl20.extensions.http.HTTPLocation;
0066:        import org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultExtensions;
0067:        import org.apache.woden.wsdl20.extensions.soap.SOAPBindingFaultReferenceExtensions;
0068:        import org.apache.woden.wsdl20.extensions.soap.SOAPBindingMessageReferenceExtensions;
0069:        import org.apache.woden.wsdl20.extensions.soap.SOAPBindingOperationExtensions;
0070:        import org.apache.woden.wsdl20.extensions.soap.SOAPEndpointExtensions;
0071:        import org.apache.woden.wsdl20.extensions.soap.SOAPHeaderBlock;
0072:        import org.apache.woden.wsdl20.extensions.soap.SOAPModule;
0073:        import org.apache.woden.wsdl20.xml.DescriptionElement;
0074:        import org.apache.woden.wsdl20.xml.TypesElement;
0075:        import org.apache.woden.wsdl20.xml.DocumentationElement;
0076:        import org.apache.woden.wsdl20.xml.DocumentableElement;
0077:        import org.apache.woden.xml.XMLAttr;
0078:        import org.apache.ws.commons.schema.XmlSchema;
0079:        import org.apache.ws.commons.schema.utils.NamespaceMap;
0080:        import org.w3c.dom.Document;
0081:        import org.w3c.dom.Element;
0082:
0083:        import javax.xml.namespace.QName;
0084:        import javax.xml.parsers.DocumentBuilder;
0085:        import javax.xml.parsers.DocumentBuilderFactory;
0086:        import java.io.File;
0087:        import java.io.InputStream;
0088:        import java.net.URI;
0089:        import java.net.URISyntaxException;
0090:        import java.util.ArrayList;
0091:        import java.util.HashMap;
0092:        import java.util.Iterator;
0093:        import java.util.List;
0094:        import java.util.Map;
0095:        import java.util.TreeMap;
0096:        import java.util.Comparator;
0097:
0098:        import com.ibm.wsdl.util.xml.DOM2Writer;
0099:
0100:        public class WSDL20ToAxisServiceBuilder extends
0101:                WSDLToAxisServiceBuilder {
0102:
0103:            protected Description description;
0104:
0105:            private String wsdlURI;
0106:
0107:            // FIXME @author Chathura THis shoud be a URI. Find whats used by
0108:            // woden.
0109:            private static String RPC = "rpc";
0110:
0111:            protected String interfaceName;
0112:
0113:            private String savedTargetNamespace;
0114:
0115:            private Map namespacemap;
0116:
0117:            private List operationNames = new ArrayList();
0118:
0119:            private NamespaceMap stringBasedNamespaceMap;
0120:
0121:            private boolean setupComplete = false;
0122:            private Service wsdlService;
0123:
0124:            //    As bindings are processed add it to this array so that we dont process the same binding twice
0125:            private Map processedBindings;
0126:
0127:            public WSDL20ToAxisServiceBuilder(InputStream in,
0128:                    QName serviceName, String interfaceName) {
0129:                this .in = in;
0130:                this .serviceName = serviceName;
0131:                this .interfaceName = interfaceName;
0132:                this .axisService = new AxisService();
0133:                setPolicyRegistryFromService(axisService);
0134:            }
0135:
0136:            public WSDL20ToAxisServiceBuilder(String wsdlUri, String name,
0137:                    String interfaceName) throws WSDLException {
0138:                String fullPath = wsdlUri;
0139:                if (!wsdlUri.startsWith("http://")) {
0140:                    File file = new File(wsdlUri);
0141:                    fullPath = file.getAbsolutePath();
0142:                }
0143:                Description description = readInTheWSDLFile(fullPath);
0144:
0145:                DescriptionElement descriptionElement = description.toElement();
0146:                savedTargetNamespace = descriptionElement.getTargetNamespace()
0147:                        .toString();
0148:                namespacemap = descriptionElement.getNamespaces();
0149:                this .description = description;
0150:                this .serviceName = null;
0151:                if (name != null) {
0152:                    serviceName = new QName(descriptionElement
0153:                            .getTargetNamespace().toString(), name);
0154:                }
0155:                this .interfaceName = interfaceName;
0156:                this .axisService = new AxisService();
0157:                setPolicyRegistryFromService(axisService);
0158:            }
0159:
0160:            public WSDL20ToAxisServiceBuilder(String wsdlUri, QName serviceName) {
0161:                super (null, serviceName);
0162:                this .wsdlURI = wsdlUri;
0163:            }
0164:
0165:            public WSDL20ToAxisServiceBuilder(String wsdlUri,
0166:                    AxisService service) {
0167:                super (null, service);
0168:                this .wsdlURI = wsdlUri;
0169:            }
0170:
0171:            public AxisService populateService() throws AxisFault {
0172:
0173:                try {
0174:                    setup();
0175:                    // Setting wsdl4jdefintion to axisService , so if some one want
0176:                    // to play with it he can do that by getting the parameter
0177:                    Parameter wsdlDescriptionParamter = new Parameter();
0178:                    wsdlDescriptionParamter
0179:                            .setName(WSDLConstants.WSDL_20_DESCRIPTION);
0180:                    wsdlDescriptionParamter.setValue(description);
0181:                    axisService.addParameter(wsdlDescriptionParamter);
0182:
0183:                    if (description == null) {
0184:                        return null;
0185:                    }
0186:                    // setting target name space
0187:                    axisService.setTargetNamespace(savedTargetNamespace);
0188:
0189:                    // if there are documentation elements in the root. Lets add them as the wsdlService description
0190:                    // but since there can be multiple documentation elements, lets only add the first one
0191:                    addDocumentation(axisService, description.toElement());
0192:                    //            DocumentationElement[] documentationElements = description.toElement().getDocumentationElements();
0193:                    //            if (documentationElements != null && documentationElements.length > 0) {
0194:                    //                axisService.setServiceDescription(documentationElements[0].getContent().toString());
0195:                    //            }
0196:
0197:                    // adding ns in the original WSDL
0198:                    // processPoliciesInDefintion(wsdl4jDefinition); TODO : Defering policy handling for now - Chinthaka
0199:                    // policy support
0200:
0201:                    // schema generation
0202:
0203:                    // Create the namespacemap
0204:
0205:                    axisService.setNameSpacesMap(stringBasedNamespaceMap);
0206:                    // TypeDefinition[] typeDefinitions =
0207:                    // description.getTypeDefinitions();
0208:                    // for(int i=0; i<typeDefinitions.length; i++){
0209:                    // if("org.apache.ws.commons.schema".equals(typeDefinitions[i].getContentModel())){
0210:                    // axisService.addSchema((XmlSchema)typeDefinitions[i].getContent());
0211:                    // }else
0212:                    // if("org.w3c.dom".equals(typeDefinitions[i].getContentModel())){
0213:                    // axisService.addSchema(getXMLSchema((Element)typeDefinitions[i].getContent(),
0214:                    // null));
0215:                    // }
0216:                    //
0217:                    // }
0218:
0219:                    DescriptionElement descriptionElement = description
0220:                            .toElement();
0221:                    TypesElement typesElement = descriptionElement
0222:                            .getTypesElement();
0223:                    if (typesElement != null) {
0224:                        Schema[] schemas = typesElement.getSchemas();
0225:                        for (int i = 0; i < schemas.length; i++) {
0226:                            XmlSchema schemaDefinition = schemas[i]
0227:                                    .getSchemaDefinition();
0228:
0229:                            // WSDL 2.0 spec requires that even the built-in schema should be returned
0230:                            // once asked for schema definitions. But for data binding purposes we can ignore that
0231:                            if (schemaDefinition != null
0232:                                    && !Constants.URI_2001_SCHEMA_XSD
0233:                                            .equals(schemaDefinition
0234:                                                    .getTargetNamespace())) {
0235:                                axisService.addSchema(schemaDefinition);
0236:                            }
0237:                        }
0238:                    }
0239:
0240:                    processService();
0241:                    return axisService;
0242:                } catch (Exception e) {
0243:                    throw AxisFault.makeFault(e);
0244:                }
0245:            }
0246:
0247:            private void processEndpoints(Interface serviceInterface)
0248:                    throws AxisFault {
0249:                Endpoint[] endpoints = wsdlService.getEndpoints();
0250:
0251:                if (endpoints.length == 0) {
0252:                    throw new AxisFault("No endpoints found in the WSDL");
0253:                }
0254:
0255:                processedBindings = new HashMap();
0256:                Endpoint endpoint = null;
0257:
0258:                if (this .interfaceName != null) {
0259:                    for (int i = 0; i < endpoints.length; ++i) {
0260:                        if (this .interfaceName.equals(endpoints[i].getName()
0261:                                .toString())) {
0262:                            endpoint = endpoints[i];
0263:                            break; // found it.  Stop looking
0264:                        }
0265:                    }
0266:                    if (endpoint == null) {
0267:                        throw new AxisFault(
0268:                                "No endpoint found for the given name :"
0269:                                        + this .interfaceName);
0270:                    }
0271:
0272:                    axisService.addEndpoint(endpoint.getName().toString(),
0273:                            processEndpoint(endpoint, serviceInterface));
0274:                } else {
0275:                    for (int i = 0; i < endpoints.length; i++) {
0276:                        axisService.addEndpoint(endpoints[i].getName()
0277:                                .toString(), processEndpoint(endpoints[i],
0278:                                serviceInterface));
0279:                    }
0280:                }
0281:
0282:                if (endpoint == null && endpoints.length > 0) {
0283:                    endpoint = endpoints[0];
0284:                }
0285:
0286:                axisService.setEndpointName(endpoint.getName().toString());
0287:                axisService.setBindingName(endpoint.getBinding().getName()
0288:                        .getLocalPart());
0289:                axisService.setEndpointURL(endpoint.getAddress().toString());
0290:
0291:            }
0292:
0293:            private void processService() throws AxisFault {
0294:                Service[] services = description.getServices();
0295:                if (services.length == 0) {
0296:                    throw new AxisFault("No wsdlService found in the WSDL");
0297:                }
0298:
0299:                if (serviceName != null) {
0300:                    for (int i = 0; i < services.length; i++) {
0301:                        if (serviceName.equals(services[i].getName())) {
0302:                            wsdlService = services[i];
0303:                            break; // found it. Stop looking.
0304:                        }
0305:                    }
0306:                    if (wsdlService == null) {
0307:                        throw new AxisFault(
0308:                                "Service with the specified name not found in the WSDL : "
0309:                                        + serviceName.getLocalPart());
0310:                    }
0311:                } else {
0312:                    wsdlService = services[0];
0313:                }
0314:
0315:                axisService.setName(wsdlService.getName().getLocalPart()
0316:                        .toString());
0317:                Interface serviceInterface = wsdlService.getInterface();
0318:                axisService.addParameter(new Parameter(
0319:                        WSDL2Constants.INTERFACE_LOCAL_NAME, serviceInterface
0320:                                .getName().getLocalPart()));
0321:                processInterface(serviceInterface);
0322:                if (isCodegen) {
0323:                    axisService.setOperationsNameList(operationNames);
0324:                }
0325:                processEndpoints(serviceInterface);
0326:
0327:            }
0328:
0329:            private AxisEndpoint processEndpoint(Endpoint endpoint,
0330:                    Interface serviceInterface) throws AxisFault {
0331:                AxisEndpoint axisEndpoint = new AxisEndpoint();
0332:                axisEndpoint.setName(endpoint.getName().toString());
0333:                axisEndpoint.setEndpointURL(endpoint.getAddress().toString());
0334:                if (processedBindings.containsKey(endpoint.getBinding()
0335:                        .getName())) {
0336:                    axisEndpoint.setBinding((AxisBinding) processedBindings
0337:                            .get(endpoint.getBinding().getName()));
0338:                } else {
0339:                    axisEndpoint.setBinding(processBinding(endpoint
0340:                            .getBinding(), serviceInterface));
0341:                }
0342:
0343:                SOAPEndpointExtensions soapEndpointExtensions = null;
0344:                try {
0345:                    soapEndpointExtensions = (SOAPEndpointExtensions) endpoint
0346:                            .getComponentExtensionsForNamespace(new URI(
0347:                                    WSDL2Constants.URI_WSDL2_SOAP));
0348:                } catch (URISyntaxException e) {
0349:                    throw new AxisFault("HTTP Binding Extention not found");
0350:                }
0351:
0352:                if (soapEndpointExtensions != null) {
0353:
0354:                    axisEndpoint.setProperty(
0355:                            WSDL2Constants.ATTR_WHTTP_AUTHENTICATION_TYPE,
0356:                            soapEndpointExtensions
0357:                                    .getHttpAuthenticationScheme());
0358:                    axisEndpoint
0359:                            .setProperty(
0360:                                    WSDL2Constants.ATTR_WHTTP_AUTHENTICATION_REALM,
0361:                                    soapEndpointExtensions
0362:                                            .getHttpAuthenticationRealm());
0363:
0364:                }
0365:                addDocumentation(axisEndpoint, endpoint.toElement());
0366:                return axisEndpoint;
0367:
0368:            }
0369:
0370:            /**
0371:             * contains all code which gathers non-wsdlService specific information from the
0372:             * wsdl.
0373:             * <p/>
0374:             * After all the setup completes successfully, the setupComplete field is
0375:             * set so that any subsequent calls to setup() will result in a no-op. Note
0376:             * that subclass WSDL20ToAllAxisServicesBuilder will call populateService
0377:             * for each endpoint in the WSDL. Separating the non-wsdlService specific
0378:             * information here allows WSDL20ToAllAxisServicesBuilder to only do this
0379:             * work 1 time per WSDL, instead of for each endpoint on each wsdlService.
0380:             *
0381:             * @throws AxisFault
0382:             */
0383:            protected void setup() throws AxisFault, WSDLException {
0384:                if (setupComplete) { // already setup, just do nothing and return
0385:                    return;
0386:                }
0387:                try {
0388:                    if (description == null) {
0389:
0390:                        Description description = null;
0391:                        DescriptionElement descriptionElement = null;
0392:                        if (wsdlURI != null && !"".equals(wsdlURI)) {
0393:                            description = readInTheWSDLFile(wsdlURI);
0394:                            descriptionElement = description.toElement();
0395:                        } else if (in != null) {
0396:
0397:                            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
0398:                                    .newInstance();
0399:                            documentBuilderFactory.setNamespaceAware(true);
0400:                            DocumentBuilder documentBuilder = documentBuilderFactory
0401:                                    .newDocumentBuilder();
0402:                            Document document = documentBuilder.parse(in);
0403:
0404:                            WSDLReader reader = DOMWSDLFactory.newInstance()
0405:                                    .newWSDLReader();
0406:                            // This turns on WSDL validation which is set off by default.
0407:                            reader.setFeature(WSDLReader.FEATURE_VALIDATION,
0408:                                    true);
0409:                            WSDLSource wsdlSource = reader.createWSDLSource();
0410:                            wsdlSource.setSource(document.getDocumentElement());
0411:                            wsdlSource.setBaseURI(new URI(getBaseUri()));
0412:                            description = reader.readWSDL(wsdlSource);
0413:                            descriptionElement = description.toElement();
0414:                        } else {
0415:                            throw new AxisFault(
0416:                                    "No resources found to read the wsdl");
0417:                        }
0418:
0419:                        savedTargetNamespace = descriptionElement
0420:                                .getTargetNamespace().toString();
0421:                        namespacemap = descriptionElement.getNamespaces();
0422:                        this .description = description;
0423:
0424:                    }
0425:                    // Create the namespacemap
0426:
0427:                    stringBasedNamespaceMap = new NamespaceMap();
0428:                    Iterator iterator = namespacemap.keySet().iterator();
0429:                    while (iterator.hasNext()) {
0430:                        String key = (String) iterator.next();
0431:                        stringBasedNamespaceMap.put(key,
0432:                                (namespacemap.get(key)).toString());
0433:                    }
0434:
0435:                    setupComplete = true;
0436:                } catch (AxisFault e) {
0437:                    throw e; // just rethrow AxisFaults
0438:                } catch (WSDLException e) {
0439:                    // Preserve the WSDLException
0440:                    throw e;
0441:                } catch (Exception e) {
0442:                    throw AxisFault.makeFault(e);
0443:                }
0444:            }
0445:
0446:            private AxisBinding processBinding(Binding binding,
0447:                    Interface serviceInterface) throws AxisFault {
0448:                AxisBinding axisBinding = new AxisBinding();
0449:                axisBinding.setName(binding.getName());
0450:                String bindingType = binding.getType().toString();
0451:                axisBinding.setType(bindingType);
0452:
0453:                if (bindingType.equals(WSDL2Constants.URI_WSDL2_SOAP)) {
0454:                    processSOAPBindingExtention(binding, axisBinding,
0455:                            serviceInterface);
0456:                } else if (bindingType.equals(WSDL2Constants.URI_WSDL2_HTTP)) {
0457:                    processHTTPBindingExtention(binding, axisBinding,
0458:                            serviceInterface);
0459:                }
0460:
0461:                // We should process the interface based on the service not on a binding
0462:
0463:                processedBindings.put(binding.getName(), axisBinding);
0464:                addDocumentation(axisBinding, binding.toElement());
0465:                return axisBinding;
0466:            }
0467:
0468:            private void processSOAPBindingExtention(Binding binding,
0469:                    AxisBinding axisBinding, Interface serviceInterface)
0470:                    throws AxisFault {
0471:
0472:                // Capture all the binding specific properties
0473:
0474:                // Set a comparator so tha httpLocations are stored in decending order
0475:                Map httpLocationTable = new TreeMap(new Comparator() {
0476:                    public int compare(Object o1, Object o2) {
0477:                        return (-1 * ((Comparable) o1).compareTo(o2));
0478:                    }
0479:                });
0480:                SOAPBindingExtensionsImpl soapBindingExtensions = null;
0481:                try {
0482:                    soapBindingExtensions = (SOAPBindingExtensionsImpl) binding
0483:                            .getComponentExtensionsForNamespace(new URI(
0484:                                    WSDL2Constants.URI_WSDL2_SOAP));
0485:                } catch (URISyntaxException e) {
0486:                    throw new AxisFault("Soap Binding Extention not found");
0487:                }
0488:
0489:                String soapVersion;
0490:                if ((soapVersion = soapBindingExtensions.getSoapVersion()) != null) {
0491:                    if (soapVersion.equals(WSDL2Constants.SOAP_VERSION_1_1)) {
0492:                        axisBinding.setProperty(
0493:                                WSDL2Constants.ATTR_WSOAP_VERSION,
0494:                                SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
0495:                    } else {
0496:                        axisBinding.setProperty(
0497:                                WSDL2Constants.ATTR_WSOAP_VERSION,
0498:                                SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
0499:                    }
0500:                } else {
0501:                    // Set the default to soap 1.2
0502:                    axisBinding
0503:                            .setProperty(
0504:                                    WSDL2Constants.ATTR_WSOAP_VERSION,
0505:                                    WSDL20DefaultValueHolder
0506:                                            .getDefaultValue(WSDL2Constants.ATTR_WSOAP_VERSION));
0507:                }
0508:
0509:                URI soapUnderlyingProtocol = soapBindingExtensions
0510:                        .getSoapUnderlyingProtocol();
0511:                if (soapUnderlyingProtocol != null) {
0512:                    axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_PROTOCOL,
0513:                            soapUnderlyingProtocol.toString());
0514:                }
0515:                URI soapMepDefault = soapBindingExtensions.getSoapMepDefault();
0516:                if (soapMepDefault != null) {
0517:                    axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_MEP,
0518:                            soapMepDefault.toString());
0519:                }
0520:                axisBinding.setProperty(
0521:                        WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING,
0522:                        soapBindingExtensions.getHttpContentEncodingDefault());
0523:                axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_MODULE,
0524:                        createSoapModules(soapBindingExtensions
0525:                                .getSoapModules()));
0526:                axisBinding.setProperty(
0527:                        WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,
0528:                        soapBindingExtensions
0529:                                .getHttpQueryParameterSeparatorDefault());
0530:
0531:                // Capture all the fault specific properties
0532:
0533:                BindingFault[] bindingFaults = binding.getBindingFaults();
0534:                for (int i = 0; i < bindingFaults.length; i++) {
0535:                    BindingFaultImpl bindingFault = (BindingFaultImpl) bindingFaults[i];
0536:                    InterfaceFault interfaceFault = serviceInterface
0537:                            .getFromAllInterfaceFaults(bindingFault.getRef());
0538:                    AxisBindingMessage axisBindingFault = new AxisBindingMessage();
0539:                    axisBindingFault.setFault(true);
0540:                    axisBindingFault.setName(interfaceFault.getName()
0541:                            .getLocalPart());
0542:                    axisBindingFault.setParent(axisBinding);
0543:
0544:                    addDocumentation(axisBindingFault, interfaceFault
0545:                            .toElement());
0546:                    SOAPBindingFaultExtensions soapBindingFaultExtensions = null;
0547:
0548:                    try {
0549:                        soapBindingFaultExtensions = (SOAPBindingFaultExtensions) bindingFault
0550:                                .getComponentExtensionsForNamespace(new URI(
0551:                                        WSDL2Constants.URI_WSDL2_SOAP));
0552:                    } catch (URISyntaxException e) {
0553:                        throw new AxisFault("Soap Binding Extention not found");
0554:                    }
0555:
0556:                    axisBindingFault.setProperty(
0557:                            WSDL2Constants.ATTR_WHTTP_HEADER,
0558:                            createHttpHeaders(soapBindingFaultExtensions
0559:                                    .getHttpHeaders()));
0560:                    axisBindingFault
0561:                            .setProperty(
0562:                                    WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING,
0563:                                    soapBindingFaultExtensions
0564:                                            .getHttpContentEncoding());
0565:                    axisBindingFault.setProperty(
0566:                            WSDL2Constants.ATTR_WSOAP_CODE,
0567:                            soapBindingFaultExtensions.getSoapFaultCode());
0568:                    axisBindingFault.setProperty(
0569:                            WSDL2Constants.ATTR_WSOAP_SUBCODES,
0570:                            soapBindingFaultExtensions.getSoapFaultSubcodes());
0571:                    axisBindingFault.setProperty(
0572:                            WSDL2Constants.ATTR_WSOAP_HEADER,
0573:                            createSoapHeaders(soapBindingFaultExtensions
0574:                                    .getSoapHeaders()));
0575:                    axisBindingFault.setProperty(
0576:                            WSDL2Constants.ATTR_WSOAP_MODULE,
0577:                            createSoapModules(soapBindingFaultExtensions
0578:                                    .getSoapModules()));
0579:
0580:                    axisBinding.addFault(axisBindingFault);
0581:
0582:                }
0583:
0584:                // Capture all the binding operation specific properties
0585:
0586:                BindingOperation[] bindingOperations = binding
0587:                        .getBindingOperations();
0588:                for (int i = 0; i < bindingOperations.length; i++) {
0589:                    BindingOperationImpl bindingOperation = (BindingOperationImpl) bindingOperations[i];
0590:
0591:                    AxisBindingOperation axisBindingOperation = new AxisBindingOperation();
0592:                    InterfaceOperation interfaceOperation = serviceInterface
0593:                            .getFromAllInterfaceOperations(bindingOperation
0594:                                    .getRef());
0595:                    AxisOperation axisOperation = axisService
0596:                            .getOperation(interfaceOperation.getName());
0597:
0598:                    axisBindingOperation.setAxisOperation(axisOperation);
0599:                    axisBindingOperation.setParent(axisBinding);
0600:                    axisBindingOperation.setName(axisOperation.getName());
0601:                    addDocumentation(axisBindingOperation, bindingOperation
0602:                            .toElement());
0603:                    SOAPBindingOperationExtensions soapBindingOperationExtensions = null;
0604:                    try {
0605:                        soapBindingOperationExtensions = ((SOAPBindingOperationExtensions) bindingOperation
0606:                                .getComponentExtensionsForNamespace(new URI(
0607:                                        WSDL2Constants.URI_WSDL2_SOAP)));
0608:                    } catch (URISyntaxException e) {
0609:                        throw new AxisFault("Soap Binding Extention not found");
0610:                    }
0611:
0612:                    URI soapAction = soapBindingOperationExtensions
0613:                            .getSoapAction();
0614:                    if (soapAction != null && !"\"\"".equals(soapAction)) {
0615:                        axisBindingOperation.setProperty(
0616:                                WSDL2Constants.ATTR_WSOAP_ACTION, soapAction
0617:                                        .toString());
0618:                    }
0619:                    axisBindingOperation.setProperty(
0620:                            WSDL2Constants.ATTR_WSOAP_MODULE,
0621:                            createSoapModules(soapBindingOperationExtensions
0622:                                    .getSoapModules()));
0623:                    URI soapMep = soapBindingOperationExtensions.getSoapMep();
0624:                    if (soapMep != null) {
0625:                        axisBindingOperation.setProperty(
0626:                                WSDL2Constants.ATTR_WSOAP_MEP, soapMep
0627:                                        .toString());
0628:                    }
0629:                    HTTPLocation httpLocation = soapBindingOperationExtensions
0630:                            .getHttpLocation();
0631:                    // If httpLocation is not null we should extract a constant part from it and add its value and the
0632:                    // corresponding AxisOperation to a map in order to dispatch rest messages. If httpLocation is null we add
0633:                    // the operation name into this map.
0634:                    String httpLocationString = "";
0635:                    if (httpLocation != null) {
0636:                        String httpLocationTemplete = httpLocation
0637:                                .getOriginalLocation();
0638:                        axisBindingOperation.setProperty(
0639:                                WSDL2Constants.ATTR_WHTTP_LOCATION,
0640:                                httpLocationTemplete);
0641:                        httpLocationString = RESTUtil
0642:                                .getConstantFromHTTPLocation(httpLocationTemplete);
0643:
0644:                    }
0645:
0646:                    httpLocationTable.put(httpLocationString, axisOperation);
0647:                    axisBindingOperation.setProperty(
0648:                            WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING,
0649:                            soapBindingOperationExtensions
0650:                                    .getHttpContentEncodingDefault());
0651:                    axisBindingOperation
0652:                            .setProperty(
0653:                                    WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,
0654:                                    soapBindingOperationExtensions
0655:                                            .getHttpQueryParameterSeparator());
0656:
0657:                    BindingMessageReference[] bindingMessageReferences = bindingOperation
0658:                            .getBindingMessageReferences();
0659:                    for (int j = 0; j < bindingMessageReferences.length; j++) {
0660:                        BindingMessageReference bindingMessageReference = bindingMessageReferences[j];
0661:
0662:                        AxisBindingMessage axisBindingMessage = new AxisBindingMessage();
0663:                        axisBindingMessage.setParent(axisBindingOperation);
0664:                        addDocumentation(axisBindingMessage,
0665:                                bindingMessageReference.toElement());
0666:                        AxisMessage axisMessage = axisOperation
0667:                                .getMessage(bindingMessageReference
0668:                                        .getInterfaceMessageReference()
0669:                                        .getMessageLabel().toString());
0670:
0671:                        axisBindingMessage.setAxisMessage(axisMessage);
0672:                        axisBindingMessage.setName(axisMessage.getName());
0673:                        axisBindingMessage.setDirection(axisMessage
0674:                                .getDirection());
0675:
0676:                        SOAPBindingMessageReferenceExtensions soapBindingMessageReferenceExtensions = null;
0677:                        try {
0678:                            soapBindingMessageReferenceExtensions = (SOAPBindingMessageReferenceExtensions) bindingMessageReference
0679:                                    .getComponentExtensionsForNamespace(new URI(
0680:                                            WSDL2Constants.URI_WSDL2_SOAP));
0681:                        } catch (URISyntaxException e) {
0682:                            throw new AxisFault(
0683:                                    "Soap Binding Extention not found");
0684:                        }
0685:
0686:                        axisBindingMessage
0687:                                .setProperty(
0688:                                        WSDL2Constants.ATTR_WHTTP_HEADER,
0689:                                        createHttpHeaders(soapBindingMessageReferenceExtensions
0690:                                                .getHttpHeaders()));
0691:                        axisBindingMessage.setProperty(
0692:                                WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING,
0693:                                soapBindingMessageReferenceExtensions
0694:                                        .getHttpContentEncoding());
0695:                        axisBindingMessage
0696:                                .setProperty(
0697:                                        WSDL2Constants.ATTR_WSOAP_HEADER,
0698:                                        createSoapHeaders(soapBindingMessageReferenceExtensions
0699:                                                .getSoapHeaders()));
0700:                        axisBindingMessage
0701:                                .setProperty(
0702:                                        WSDL2Constants.ATTR_WSOAP_MODULE,
0703:                                        createSoapModules(soapBindingMessageReferenceExtensions
0704:                                                .getSoapModules()));
0705:
0706:                        axisBindingOperation.addChild(axisMessage
0707:                                .getDirection(), axisBindingMessage);
0708:
0709:                    }
0710:
0711:                    BindingFaultReference[] bindingFaultReferences = bindingOperation
0712:                            .getBindingFaultReferences();
0713:                    for (int j = 0; j < bindingFaultReferences.length; j++) {
0714:                        BindingFaultReference bindingFaultReference = bindingFaultReferences[j];
0715:
0716:                        AxisBindingMessage axisBindingMessageFault = new AxisBindingMessage();
0717:                        addDocumentation(axisBindingMessageFault,
0718:                                bindingFaultReference.toElement());
0719:                        axisBindingMessageFault.setParent(axisBindingOperation);
0720:                        axisBindingMessageFault.setFault(true);
0721:                        axisBindingMessageFault.setName(bindingFaultReference
0722:                                .getInterfaceFaultReference()
0723:                                .getInterfaceFault().getName().getLocalPart());
0724:
0725:                        SOAPBindingFaultReferenceExtensions soapBindingFaultReferenceExtensions = null;
0726:                        try {
0727:                            soapBindingFaultReferenceExtensions = (SOAPBindingFaultReferenceExtensions) bindingFaultReference
0728:                                    .getComponentExtensionsForNamespace(new URI(
0729:                                            WSDL2Constants.URI_WSDL2_SOAP));
0730:                        } catch (URISyntaxException e) {
0731:                            throw new AxisFault(
0732:                                    "Soap Binding Extention not found");
0733:                        }
0734:
0735:                        axisBindingMessageFault
0736:                                .setProperty(
0737:                                        WSDL2Constants.ATTR_WSOAP_MODULE,
0738:                                        createSoapModules(soapBindingFaultReferenceExtensions
0739:                                                .getSoapModules()));
0740:
0741:                        axisBindingOperation.addFault(axisBindingMessageFault);
0742:
0743:                    }
0744:                    axisBinding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE,
0745:                            httpLocationTable);
0746:                    axisBinding.addChild(axisBindingOperation.getName(),
0747:                            axisBindingOperation);
0748:
0749:                }
0750:            }
0751:
0752:            private void processHTTPBindingExtention(Binding binding,
0753:                    AxisBinding axisBinding, Interface serviceInterface)
0754:                    throws AxisFault {
0755:
0756:                // Set a comparator so tha httpLocations are stored in decending order
0757:                Map httpLocationTable = new TreeMap(new Comparator() {
0758:                    public int compare(Object o1, Object o2) {
0759:                        return (-1 * ((Comparable) o1).compareTo(o2));
0760:                    }
0761:                });
0762:                // Capture all the binding specific properties
0763:
0764:                HTTPBindingExtensionsImpl httpBindingExtensions = null;
0765:                try {
0766:                    httpBindingExtensions = (HTTPBindingExtensionsImpl) binding
0767:                            .getComponentExtensionsForNamespace(new URI(
0768:                                    WSDL2Constants.URI_WSDL2_HTTP));
0769:                } catch (URISyntaxException e) {
0770:                    throw new AxisFault("HTTP Binding Extention not found");
0771:                }
0772:
0773:                axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_METHOD,
0774:                        httpBindingExtensions.getHttpMethodDefault());
0775:                axisBinding.setProperty(
0776:                        WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,
0777:                        httpBindingExtensions
0778:                                .getHttpQueryParameterSeparatorDefault());
0779:                axisBinding.setProperty(
0780:                        WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING,
0781:                        httpBindingExtensions.getHttpContentEncodingDefault());
0782:
0783:                // Capture all the fault specific properties
0784:
0785:                BindingFault[] bindingFaults = binding.getBindingFaults();
0786:                for (int i = 0; i < bindingFaults.length; i++) {
0787:                    BindingFaultImpl bindingFault = (BindingFaultImpl) bindingFaults[i];
0788:                    InterfaceFault interfaceFault = serviceInterface
0789:                            .getFromAllInterfaceFaults(bindingFault.getRef());
0790:                    AxisBindingMessage axisBindingFault = new AxisBindingMessage();
0791:                    axisBindingFault.setFault(true);
0792:                    axisBindingFault.setName(interfaceFault.getName()
0793:                            .getLocalPart());
0794:                    axisBindingFault.setParent(axisBinding);
0795:
0796:                    addDocumentation(axisBindingFault, interfaceFault
0797:                            .toElement());
0798:                    HTTPBindingFaultExtensions httpBindingFaultExtensions = null;
0799:
0800:                    try {
0801:                        httpBindingFaultExtensions = (HTTPBindingFaultExtensions) bindingFault
0802:                                .getComponentExtensionsForNamespace(new URI(
0803:                                        WSDL2Constants.URI_WSDL2_HTTP));
0804:                    } catch (URISyntaxException e) {
0805:                        throw new AxisFault("HTTP Binding Extention not found");
0806:                    }
0807:
0808:                    axisBindingFault.setProperty(
0809:                            WSDL2Constants.ATTR_WHTTP_CODE,
0810:                            httpBindingFaultExtensions.getHttpErrorStatusCode()
0811:                                    .getCode());
0812:                    axisBindingFault.setProperty(
0813:                            WSDL2Constants.ATTR_WHTTP_HEADER,
0814:                            createHttpHeaders(httpBindingFaultExtensions
0815:                                    .getHttpHeaders()));
0816:                    axisBindingFault
0817:                            .setProperty(
0818:                                    WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING,
0819:                                    httpBindingFaultExtensions
0820:                                            .getHttpContentEncoding());
0821:                    axisBinding.addFault(axisBindingFault);
0822:
0823:                }
0824:
0825:                // Capture all the binding operation specific properties
0826:
0827:                BindingOperation[] bindingOperations = binding
0828:                        .getBindingOperations();
0829:                for (int i = 0; i < bindingOperations.length; i++) {
0830:                    BindingOperationImpl bindingOperation = (BindingOperationImpl) bindingOperations[i];
0831:
0832:                    AxisBindingOperation axisBindingOperation = new AxisBindingOperation();
0833:                    InterfaceOperation interfaceOperation = serviceInterface
0834:                            .getFromAllInterfaceOperations(bindingOperation
0835:                                    .getRef());
0836:                    AxisOperation axisOperation = axisService
0837:                            .getOperation(interfaceOperation.getName());
0838:
0839:                    axisBindingOperation.setAxisOperation(axisOperation);
0840:                    axisBindingOperation.setParent(axisBinding);
0841:                    axisBindingOperation.setName(axisOperation.getName());
0842:
0843:                    addDocumentation(axisBindingOperation, bindingOperation
0844:                            .toElement());
0845:                    HTTPBindingOperationExtensions httpBindingOperationExtensions = null;
0846:                    try {
0847:                        httpBindingOperationExtensions = ((HTTPBindingOperationExtensions) bindingOperation
0848:                                .getComponentExtensionsForNamespace(new URI(
0849:                                        WSDL2Constants.URI_WSDL2_HTTP)));
0850:                    } catch (URISyntaxException e) {
0851:                        throw new AxisFault("HTTP Binding Extention not found");
0852:                    }
0853:
0854:                    axisBindingOperation.setProperty(
0855:                            WSDL2Constants.ATTR_WHTTP_FAULT_SERIALIZATION,
0856:                            httpBindingOperationExtensions
0857:                                    .getHttpFaultSerialization());
0858:                    axisBindingOperation.setProperty(
0859:                            WSDL2Constants.ATTR_WHTTP_INPUT_SERIALIZATION,
0860:                            httpBindingOperationExtensions
0861:                                    .getHttpInputSerialization());
0862:                    HTTPLocation httpLocation = httpBindingOperationExtensions
0863:                            .getHttpLocation();
0864:
0865:                    // If httpLocation is not null we should extract a constant part from it and add its value and the
0866:                    // corresponding AxisOperation to a map in order to dispatch rest messages. If httpLocation is null we add
0867:                    // the operation name into this map.
0868:                    String httpLocationString = "";
0869:                    if (httpLocation != null) {
0870:                        String httpLocationTemplete = httpLocation
0871:                                .getOriginalLocation();
0872:                        axisBindingOperation.setProperty(
0873:                                WSDL2Constants.ATTR_WHTTP_LOCATION,
0874:                                httpLocationTemplete);
0875:                        httpLocationString = RESTUtil
0876:                                .getConstantFromHTTPLocation(httpLocationTemplete);
0877:
0878:                    }
0879:
0880:                    httpLocationTable.put(httpLocationString, axisOperation);
0881:
0882:                    axisBindingOperation.setProperty(
0883:                            WSDL2Constants.ATTR_WHTTP_IGNORE_UNCITED,
0884:                            httpBindingOperationExtensions
0885:                                    .isHttpLocationIgnoreUncited());
0886:                    axisBindingOperation.setProperty(
0887:                            WSDL2Constants.ATTR_WHTTP_METHOD,
0888:                            httpBindingOperationExtensions.getHttpMethod());
0889:                    axisBindingOperation.setProperty(
0890:                            WSDL2Constants.ATTR_WHTTP_OUTPUT_SERIALIZATION,
0891:                            httpBindingOperationExtensions
0892:                                    .getHttpOutputSerialization());
0893:                    axisBindingOperation
0894:                            .setProperty(
0895:                                    WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,
0896:                                    httpBindingOperationExtensions
0897:                                            .getHttpQueryParameterSeparator());
0898:                    axisBindingOperation.setProperty(
0899:                            WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING,
0900:                            httpBindingOperationExtensions
0901:                                    .getHttpContentEncodingDefault());
0902:
0903:                    BindingMessageReference[] bindingMessageReferences = bindingOperation
0904:                            .getBindingMessageReferences();
0905:                    for (int j = 0; j < bindingMessageReferences.length; j++) {
0906:                        BindingMessageReference bindingMessageReference = bindingMessageReferences[j];
0907:
0908:                        AxisBindingMessage axisBindingMessage = new AxisBindingMessage();
0909:                        axisBindingMessage.setParent(axisBindingOperation);
0910:
0911:                        AxisMessage axisMessage = axisOperation
0912:                                .getMessage(bindingMessageReference
0913:                                        .getInterfaceMessageReference()
0914:                                        .getMessageLabel().toString());
0915:
0916:                        axisBindingMessage.setAxisMessage(axisMessage);
0917:                        axisBindingMessage.setName(axisMessage.getName());
0918:                        axisBindingMessage.setDirection(axisMessage
0919:                                .getDirection());
0920:
0921:                        addDocumentation(axisBindingMessage,
0922:                                bindingMessageReference.toElement());
0923:                        HTTPBindingMessageReferenceExtensions httpBindingMessageReferenceExtensions = null;
0924:                        try {
0925:                            httpBindingMessageReferenceExtensions = (HTTPBindingMessageReferenceExtensions) bindingMessageReference
0926:                                    .getComponentExtensionsForNamespace(new URI(
0927:                                            WSDL2Constants.URI_WSDL2_HTTP));
0928:                        } catch (URISyntaxException e) {
0929:                            throw new AxisFault(
0930:                                    "HTTP Binding Extention not found");
0931:                        }
0932:
0933:                        axisBindingMessage
0934:                                .setProperty(
0935:                                        WSDL2Constants.ATTR_WHTTP_HEADER,
0936:                                        createHttpHeaders(httpBindingMessageReferenceExtensions
0937:                                                .getHttpHeaders()));
0938:                        axisBindingMessage.setProperty(
0939:                                WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING,
0940:                                httpBindingMessageReferenceExtensions
0941:                                        .getHttpContentEncoding());
0942:                        axisBindingOperation.addChild(axisMessage
0943:                                .getDirection(), axisBindingMessage);
0944:
0945:                    }
0946:
0947:                    BindingFaultReference[] bindingFaultReferences = bindingOperation
0948:                            .getBindingFaultReferences();
0949:                    for (int j = 0; j < bindingFaultReferences.length; j++) {
0950:                        BindingFaultReference bindingFaultReference = bindingFaultReferences[j];
0951:
0952:                        AxisBindingMessage axisBindingMessageFault = new AxisBindingMessage();
0953:                        axisBindingMessageFault.setFault(true);
0954:                        axisBindingMessageFault.setName(bindingFaultReference
0955:                                .getInterfaceFaultReference()
0956:                                .getInterfaceFault().getName().getLocalPart());
0957:                        axisBindingMessageFault.setParent(axisBindingOperation);
0958:                        axisBindingOperation.addFault(axisBindingMessageFault);
0959:                        addDocumentation(axisBindingMessageFault,
0960:                                bindingFaultReference.toElement());
0961:
0962:                    }
0963:
0964:                    axisBinding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE,
0965:                            httpLocationTable);
0966:                    axisBinding.addChild(axisBindingOperation.getName(),
0967:                            axisBindingOperation);
0968:
0969:                }
0970:            }
0971:
0972:            private void processInterface(Interface serviceInterface)
0973:                    throws AxisFault {
0974:
0975:                // TODO @author Chathura copy the policy elements
0976:                // copyExtensionAttributes(wsdl4jPortType.getExtensionAttributes(),
0977:                // axisService, PORT_TYPE);
0978:
0979:                InterfaceOperation[] interfaceOperations = serviceInterface
0980:                        .getInterfaceOperations();
0981:                for (int i = 0; i < interfaceOperations.length; i++) {
0982:                    axisService
0983:                            .addOperation(populateOperations(interfaceOperations[i]));
0984:                    operationNames.add(interfaceOperations[i].getName());
0985:                }
0986:
0987:                Interface[] extendedInterfaces = serviceInterface
0988:                        .getExtendedInterfaces();
0989:                for (int i = 0; i < extendedInterfaces.length; i++) {
0990:                    Interface extendedInterface = extendedInterfaces[i];
0991:                    processInterface(extendedInterface);
0992:                }
0993:
0994:            }
0995:
0996:            private AxisOperation populateOperations(
0997:                    InterfaceOperation operation) throws AxisFault {
0998:                QName opName = operation.getName();
0999:                // Copy Name Attribute
1000:                AxisOperation axisOperation = axisService.getOperation(opName);
1001:
1002:                if (axisOperation == null) {
1003:                    URI pattern = operation.getMessageExchangePattern();
1004:                    String MEP;
1005:                    if (pattern == null) {
1006:                        MEP = WSDL20DefaultValueHolder
1007:                                .getDefaultValue(WSDL2Constants.ATTR_WSOAP_MEP);
1008:                    } else {
1009:                        MEP = pattern.toString();
1010:                    }
1011:                    if (!isServerSide) {
1012:                        // If in the client, need to toggle in-out to out-in etc.
1013:                        if (WSDL2Constants.MEP_URI_IN_OUT.equals(MEP)) {
1014:                            MEP = WSDL2Constants.MEP_URI_OUT_IN;
1015:                        }
1016:                        if (WSDL2Constants.MEP_URI_IN_ONLY.equals(MEP)) {
1017:                            MEP = WSDL2Constants.MEP_URI_OUT_ONLY;
1018:                        }
1019:                        if (WSDL2Constants.MEP_URI_IN_OPTIONAL_OUT.equals(MEP)) {
1020:                            MEP = WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN;
1021:                        }
1022:                    }
1023:                    axisOperation = AxisOperationFactory
1024:                            .getOperationDescription(MEP);
1025:                    axisOperation.setName(opName);
1026:
1027:                }
1028:                URI[] operationStyle = operation.getStyle();
1029:                if (operationStyle != null && operationStyle.length > 0) {
1030:                    Parameter opStyleParameter = new Parameter();
1031:                    opStyleParameter.setName(WSDL2Constants.OPERATION_STYLE);
1032:                    opStyleParameter.setValue(operationStyle);
1033:                    axisOperation.addParameter(opStyleParameter);
1034:                }
1035:                addDocumentation(axisOperation, operation.toElement());
1036:
1037:                // assuming the style of the operations of WSDL 2.0 is always document, for the time being :)
1038:                // The following can be used to capture the wsdlx:safe attribute
1039:
1040:                InterfaceOperationExtensionsImpl interfaceOperationExtensions;
1041:                try {
1042:                    interfaceOperationExtensions = (InterfaceOperationExtensionsImpl) operation
1043:                            .getComponentExtensionsForNamespace(new URI(
1044:                                    WSDL2Constants.URI_WSDL2_EXTENSIONS));
1045:                } catch (URISyntaxException e) {
1046:                    throw new AxisFault(
1047:                            "WSDL2 extensions not defined for this operation");
1048:                }
1049:
1050:                if (interfaceOperationExtensions != null) {
1051:                    Parameter parameter = new Parameter(
1052:                            WSDL2Constants.ATTR_WSDLX_SAFE, new Boolean(
1053:                                    interfaceOperationExtensions.isSafety()));
1054:                    axisOperation.addParameter(parameter);
1055:                }
1056:
1057:                InterfaceMessageReference[] interfaceMessageReferences = operation
1058:                        .getInterfaceMessageReferences();
1059:                for (int i = 0; i < interfaceMessageReferences.length; i++) {
1060:                    InterfaceMessageReference messageReference = interfaceMessageReferences[i];
1061:                    if (messageReference.getMessageLabel().equals(
1062:                            MessageLabel.IN)) {
1063:                        // Its an input message
1064:
1065:                        if (isServerSide) {
1066:                            createAxisMessage(axisOperation, messageReference,
1067:                                    WSDLConstants.MESSAGE_LABEL_IN_VALUE);
1068:                        } else {
1069:                            createAxisMessage(axisOperation, messageReference,
1070:                                    WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
1071:                        }
1072:                    } else if (messageReference.getMessageLabel().equals(
1073:                            MessageLabel.OUT)) {
1074:                        if (isServerSide) {
1075:                            createAxisMessage(axisOperation, messageReference,
1076:                                    WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
1077:                        } else {
1078:                            createAxisMessage(axisOperation, messageReference,
1079:                                    WSDLConstants.MESSAGE_LABEL_IN_VALUE);
1080:                        }
1081:                    }
1082:
1083:                }
1084:
1085:                // add operation level faults
1086:
1087:                InterfaceFaultReference[] faults = operation
1088:                        .getInterfaceFaultReferences();
1089:                for (int i = 0; i < faults.length; i++) {
1090:                    AxisMessage faultMessage = new AxisMessage();
1091:
1092:                    InterfaceFaultReference interfaceFaultReference = faults[i];
1093:                    faultMessage.setDirection(interfaceFaultReference
1094:                            .getDirection().toString());
1095:
1096:                    InterfaceFault interfaceFault = interfaceFaultReference
1097:                            .getInterfaceFault();
1098:
1099:                    faultMessage.setElementQName(interfaceFault
1100:                            .getElementDeclaration().getName());
1101:                    faultMessage.setName(interfaceFault.getName()
1102:                            .getLocalPart());
1103:
1104:                    axisOperation.setFaultMessages(faultMessage);
1105:                }
1106:
1107:                return axisOperation;
1108:            }
1109:
1110:            private void createAxisMessage(AxisOperation axisOperation,
1111:                    InterfaceMessageReference messageReference,
1112:                    String messageLabel) throws AxisFault {
1113:                AxisMessage message = axisOperation.getMessage(messageLabel);
1114:
1115:                String messageContentModelName = messageReference
1116:                        .getMessageContentModel();
1117:                QName elementQName = null;
1118:
1119:                if (WSDL2Constants.NMTOKEN_ELEMENT
1120:                        .equals(messageContentModelName)) {
1121:                    elementQName = messageReference.getElementDeclaration()
1122:                            .getName();
1123:                } else if (WSDL2Constants.NMTOKEN_ANY
1124:                        .equals(messageContentModelName)) {
1125:                    elementQName = Constants.XSD_ANY;
1126:                } else if (WSDL2Constants.NMTOKEN_NONE
1127:                        .equals(messageContentModelName)) {
1128:                    // nothing to do here keep the message element as null
1129:                } else {
1130:                    throw new AxisFault(
1131:                            "Sorry we do not support "
1132:                                    + messageContentModelName
1133:                                    + ". We do only support #any, #none and #element as message content models.");
1134:                }
1135:
1136:                message.setElementQName(elementQName);
1137:                message.setName(elementQName != null ? elementQName
1138:                        .getLocalPart() : axisOperation.getName()
1139:                        .getLocalPart());
1140:                axisOperation.addMessage(message, messageLabel);
1141:
1142:                if (WSDLConstants.MESSAGE_LABEL_IN_VALUE.equals(messageLabel)) {
1143:                    XMLAttr xa = messageReference
1144:                            .toElement()
1145:                            .getExtensionAttribute(
1146:                                    new QName(
1147:                                            "http://www.w3.org/2006/05/addressing/wsdl",
1148:                                            "Action"));
1149:                    if (xa != null) {
1150:                        String value = (String) xa.getContent();
1151:                        if (value != null) {
1152:                            ArrayList al = axisOperation.getWSAMappingList();
1153:                            if (al == null) {
1154:                                al = new ArrayList();
1155:                                axisOperation.setWsamappingList(al);
1156:                            }
1157:                            al.add(value);
1158:                        }
1159:                    }
1160:                } else {
1161:                    XMLAttr xa = messageReference
1162:                            .toElement()
1163:                            .getExtensionAttribute(
1164:                                    new QName(
1165:                                            "http://www.w3.org/2006/05/addressing/wsdl",
1166:                                            "Action"));
1167:                    if (xa != null) {
1168:                        String value = (String) xa.getContent();
1169:                        if (value != null) {
1170:                            axisOperation.setOutputAction(value);
1171:                        }
1172:                    }
1173:                }
1174:
1175:                // populate this map so that this can be used in SOAPBody based dispatching
1176:                if (elementQName != null) {
1177:                    axisService.addMessageElementQNameToOperationMapping(
1178:                            elementQName, axisOperation);
1179:                }
1180:            }
1181:
1182:            private Description readInTheWSDLFile(String wsdlURI)
1183:                    throws WSDLException {
1184:
1185:                WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
1186:                // This turns on WSDL validation which is set off by default.
1187:                //        reader.setFeature(WSDLReader.FEATURE_VALIDATION, true);
1188:                Description description1 = reader.readWSDL(wsdlURI);
1189:                return description1;
1190:            }
1191:
1192:            /**
1193:             * Convert woden dependent SOAPHeaderBlock objects to SOAPHeaderMessage objects
1194:             *
1195:             * @param soapHeaderBlocks - An array of SOAPHeaderBlock objects
1196:             * @return ArrayList - An ArrayList of SOAPHeaderMessage objects
1197:             */
1198:            private ArrayList createSoapHeaders(
1199:                    SOAPHeaderBlock soapHeaderBlocks[]) {
1200:
1201:                if (soapHeaderBlocks.length == 0) {
1202:                    return null;
1203:                }
1204:                ArrayList soapHeaderMessages = new ArrayList();
1205:
1206:                for (int i = 0; i < soapHeaderBlocks.length; i++) {
1207:                    SOAPHeaderBlock soapHeaderBlock = soapHeaderBlocks[i];
1208:                    ElementDeclaration elementDeclaration = soapHeaderBlock
1209:                            .getElementDeclaration();
1210:
1211:                    if (elementDeclaration != null) {
1212:                        QName name = elementDeclaration.getName();
1213:                        SOAPHeaderMessage soapHeaderMessage = new SOAPHeaderMessage();
1214:                        soapHeaderMessage.setElement(name);
1215:                        soapHeaderMessage.setRequired(soapHeaderBlock
1216:                                .isRequired().booleanValue());
1217:                        soapHeaderMessage.setMustUnderstand(soapHeaderBlock
1218:                                .mustUnderstand().booleanValue());
1219:                        soapHeaderMessages.add(soapHeaderMessage);
1220:                    }
1221:                }
1222:                return soapHeaderMessages;
1223:            }
1224:
1225:            /**
1226:             * Convert woden dependent SOAPHeaderBlock objects to SOAPHeaderMessage objects
1227:             *
1228:             * @param soapModules - An array of SOAPModule objects
1229:             * @return ArrayList - An ArrayList of SOAPHeaderMessage objects
1230:             */
1231:            private ArrayList createSoapModules(SOAPModule soapModules[]) {
1232:
1233:                if (soapModules.length == 0) {
1234:                    return null;
1235:                }
1236:                ArrayList soapModuleMessages = new ArrayList();
1237:
1238:                for (int i = 0; i < soapModules.length; i++) {
1239:                    SOAPModule soapModule = soapModules[i];
1240:                    SOAPModuleMessage soapModuleMessage = new SOAPModuleMessage();
1241:                    soapModuleMessage.setUri(soapModule.getRef().toString());
1242:                    soapModuleMessages.add(soapModuleMessage);
1243:                }
1244:                return soapModuleMessages;
1245:            }
1246:
1247:            /**
1248:             * Convert woden dependent HTTPHeader objects to Header objects
1249:             *
1250:             * @param httpHeaders - An array of HTTPHeader objects
1251:             * @return ArrayList - An ArrayList of Header objects
1252:             */
1253:            private ArrayList createHttpHeaders(HTTPHeader httpHeaders[]) {
1254:
1255:                if (httpHeaders.length == 0) {
1256:                    return null;
1257:                }
1258:                ArrayList httpHeaderMessages = new ArrayList();
1259:
1260:                for (int i = 0; i < httpHeaders.length; i++) {
1261:                    HTTPHeaderImpl httpHeader = (HTTPHeaderImpl) httpHeaders[i];
1262:                    HTTPHeaderMessage httpHeaderMessage = new HTTPHeaderMessage();
1263:                    httpHeaderMessage.setqName(httpHeader.getTypeName());
1264:                    httpHeaderMessage.setName(httpHeader.getName());
1265:                    httpHeaderMessage.setRequired(httpHeader.isRequired()
1266:                            .booleanValue());
1267:                    httpHeaderMessages.add(httpHeaderMessage);
1268:                }
1269:                return httpHeaderMessages;
1270:            }
1271:
1272:            /**
1273:             * Adds documentation details to a given AxisDescription.
1274:             * The documentation details is extracted from the WSDL element given.
1275:             * @param axisDescription - The documentation will be added to this
1276:             * @param element - The element that the documentation is extracted from.
1277:             */
1278:            private void addDocumentation(AxisDescription axisDescription,
1279:                    DocumentableElement element) {
1280:                DocumentationElement[] documentationElements = element
1281:                        .getDocumentationElements();
1282:                String documentation = "";
1283:                StringBuffer x;
1284:                for (int i = 0; i < documentationElements.length; i++) {
1285:                    DocumentationElement documentationElement = documentationElements[i];
1286:                    Element content = (Element) documentationElement
1287:                            .getContent();
1288:                    if (content != null) {
1289:                        documentation = documentation
1290:                                + DOM2Writer.nodeToString(content
1291:                                        .getFirstChild());
1292:                    }
1293:                }
1294:                if (!"".equals(documentation)) {
1295:                    axisDescription.setDocumentation(documentation);
1296:                }
1297:            }
1298:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.