Source Code Cross Referenced for WSDLSerializationUtil.java in  » Web-Services-AXIS2 » kernal » org » apache » axis2 » util » 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.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */
019:        package org.apache.axis2.util;
020:
021:        import org.apache.axis2.description.AxisMessage;
022:        import org.apache.axis2.description.WSDL2Constants;
023:        import org.apache.axis2.description.AxisOperation;
024:        import org.apache.axis2.description.AxisService;
025:        import org.apache.axis2.description.AxisDescription;
026:        import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
027:        import org.apache.axis2.wsdl.SOAPHeaderMessage;
028:        import org.apache.axis2.wsdl.SOAPModuleMessage;
029:        import org.apache.axis2.wsdl.HTTPHeaderMessage;
030:        import org.apache.axis2.namespace.Constants;
031:        import org.apache.axis2.AxisFault;
032:        import org.apache.axis2.addressing.AddressingConstants;
033:        import org.apache.axiom.om.OMElement;
034:        import org.apache.axiom.om.OMFactory;
035:        import org.apache.axiom.om.OMNamespace;
036:        import org.apache.axiom.om.OMText;
037:
038:        import javax.xml.namespace.QName;
039:        import javax.xml.stream.XMLStreamConstants;
040:        import java.util.Map;
041:        import java.util.Iterator;
042:        import java.util.ArrayList;
043:        import java.util.Set;
044:
045:        /**
046:         * Helps the AxisService to WSDL process
047:         */
048:        public class WSDLSerializationUtil {
049:
050:            public static final String CDATA_START = "<![CDATA[";
051:            public static final String CDATA_START_REGEX = "<!\\[CDATA\\[";
052:            public static final String CDATA_END = "]]>";
053:            public static final String CDATA_END_REGEX = "\\]\\]>";
054:
055:            /**
056:             * Given a namespace it returns the prefix for that namespace
057:             * @param namespace - The namespace that the prefix is needed for
058:             * @param nameSpaceMap - The namespaceMap
059:             * @return - The prefix of the namespace
060:             */
061:            public static String getPrefix(String namespace, Map nameSpaceMap) {
062:                Set keySet;
063:                if (nameSpaceMap != null
064:                        && (keySet = nameSpaceMap.keySet()) != null) {
065:                    Iterator keys = keySet.iterator();
066:                    while (keys.hasNext()) {
067:                        String key = (String) keys.next();
068:                        if (nameSpaceMap.get(key).equals(namespace)) {
069:                            return key;
070:                        }
071:                    }
072:                }
073:                return null;
074:            }
075:
076:            /**
077:             * Gets the correct element name for a given message
078:             * @param axisMessage - The axisMessage
079:             * @param nameSpaceMap - The namespaceMap
080:             * @return - The element name
081:             */
082:            public static String getElementName(AxisMessage axisMessage,
083:                    Map nameSpaceMap) {
084:                QName elementQName = axisMessage.getElementQName();
085:                if (elementQName == null) {
086:                    return WSDL2Constants.NMTOKEN_NONE;
087:                } else if (Constants.XSD_ANY.equals(elementQName)) {
088:                    return WSDL2Constants.NMTOKEN_ANY;
089:                } else {
090:                    String prefix = WSDLSerializationUtil.getPrefix(
091:                            elementQName.getNamespaceURI(), nameSpaceMap);
092:                    return prefix + ":" + elementQName.getLocalPart();
093:                }
094:            }
095:
096:            /**
097:             * Adds a soap header element to a given OMElement
098:             * @param omFactory - An OMFactory
099:             * @param list - The arraylist of soapHeaderMessages
100:             * @param wsoap - The WSDL 2.0 SOAP namespace
101:             * @param element - The element that the header should be added to
102:             * @param nameSpaceMap - The namespaceMap
103:             */
104:            public static void addSOAPHeaderElements(OMFactory omFactory,
105:                    ArrayList list, OMNamespace wsoap, OMElement element,
106:                    Map nameSpaceMap) {
107:                for (int i = 0; i < list.size(); i++) {
108:                    SOAPHeaderMessage soapHeaderMessage = (SOAPHeaderMessage) list
109:                            .get(i);
110:                    OMElement soapHeaderElement = omFactory.createOMElement(
111:                            WSDL2Constants.ATTRIBUTE_HEADER, wsoap);
112:                    QName qName = soapHeaderMessage.getElement();
113:                    soapHeaderElement.addAttribute(omFactory.createOMAttribute(
114:                            WSDL2Constants.ATTRIBUTE_ELEMENT, null, getPrefix(
115:                                    qName.getNamespaceURI(), nameSpaceMap)
116:                                    + ":" + qName.getLocalPart()));
117:                    soapHeaderElement.addAttribute(omFactory.createOMAttribute(
118:                            WSDL2Constants.ATTRIBUTE_MUST_UNDERSTAND, null,
119:                            Boolean.toString(soapHeaderMessage
120:                                    .isMustUnderstand())));
121:                    soapHeaderElement.addAttribute(omFactory.createOMAttribute(
122:                            WSDL2Constants.ATTRIBUTE_REQUIRED, null, Boolean
123:                                    .toString(soapHeaderMessage.isRequired())));
124:                    element.addChild(soapHeaderElement);
125:                }
126:            }
127:
128:            /**
129:             * Adds a soap module element to a given OMElement
130:             * @param omFactory - An OMFactory
131:             * @param list - The arraylist of soapModuleMessages
132:             * @param wsoap - The WSDL 2.0 SOAP namespace
133:             * @param element - The element that the header should be added to
134:             */
135:            public static void addSOAPModuleElements(OMFactory omFactory,
136:                    ArrayList list, OMNamespace wsoap, OMElement element) {
137:                for (int i = 0; i < list.size(); i++) {
138:                    SOAPModuleMessage soapModuleMessage = (SOAPModuleMessage) list
139:                            .get(i);
140:                    OMElement soapModuleElement = omFactory.createOMElement(
141:                            WSDL2Constants.ATTRIBUTE_MODULE, wsoap);
142:                    soapModuleElement.addAttribute(omFactory.createOMAttribute(
143:                            WSDL2Constants.ATTRIBUTE_REF, null,
144:                            soapModuleMessage.getUri()));
145:                    element.addChild(soapModuleElement);
146:                }
147:            }
148:
149:            /**
150:             * Adds a HTTP header element to a given OMElement
151:             * @param omFactory - An OMFactory
152:             * @param list - The arraylist of HTTPHeaderMessages
153:             * @param whttp - The WSDL 2.0 HTTP namespace
154:             * @param element - The element that the header should be added to
155:             * @param nameSpaceMap - The namespaceMap
156:             */
157:            public static void addHTTPHeaderElements(OMFactory omFactory,
158:                    ArrayList list, OMNamespace whttp, OMElement element,
159:                    Map nameSpaceMap) {
160:                for (int i = 0; i < list.size(); i++) {
161:                    HTTPHeaderMessage httpHeaderMessage = (HTTPHeaderMessage) list
162:                            .get(i);
163:                    OMElement httpHeaderElement = omFactory.createOMElement(
164:                            WSDL2Constants.ATTRIBUTE_HEADER, whttp);
165:                    httpHeaderElement.addAttribute(omFactory.createOMAttribute(
166:                            WSDL2Constants.ATTRIBUTE_NAME, null,
167:                            httpHeaderMessage.getName()));
168:                    QName qName = httpHeaderMessage.getqName();
169:                    httpHeaderElement.addAttribute(omFactory.createOMAttribute(
170:                            WSDL2Constants.ATTRIBUTE_TYPE, null, getPrefix(
171:                                    qName.getNamespaceURI(), nameSpaceMap)
172:                                    + ":" + qName.getLocalPart()));
173:                    httpHeaderElement.addAttribute(omFactory.createOMAttribute(
174:                            WSDL2Constants.ATTRIBUTE_REQUIRED, null, Boolean
175:                                    .valueOf(httpHeaderMessage.isRequired())
176:                                    .toString()));
177:                    element.addChild(httpHeaderElement);
178:                }
179:            }
180:
181:            /**
182:             * Generates a default SOAP 11 Binding for a given AxisService
183:             * @param fac - The OMFactory
184:             * @param axisService - The AxisService
185:             * @param wsdl the WSDL namespace
186:             * @param wsoap - The WSDL 2.0 SOAP namespace
187:             * @param tns - The target namespace
188:             * @return - The generated SOAP11Binding element
189:             */
190:            public static OMElement generateSOAP11Binding(OMFactory fac,
191:                    AxisService axisService, OMNamespace wsdl,
192:                    OMNamespace wsoap, OMNamespace tns) {
193:                OMElement binding = fac.createOMElement(
194:                        WSDL2Constants.BINDING_LOCAL_NAME, wsdl);
195:                binding.addAttribute(fac.createOMAttribute(
196:                        WSDL2Constants.ATTRIBUTE_NAME, null, axisService
197:                                .getName()
198:                                + Java2WSDLConstants.BINDING_NAME_SUFFIX));
199:                binding.addAttribute(fac.createOMAttribute(
200:                        WSDL2Constants.INTERFACE_LOCAL_NAME, null, tns
201:                                .getPrefix()
202:                                + ":" + WSDL2Constants.DEFAULT_INTERFACE_NAME));
203:
204:                binding.addAttribute(fac.createOMAttribute(
205:                        WSDL2Constants.ATTRIBUTE_TYPE, null,
206:                        WSDL2Constants.URI_WSDL2_SOAP));
207:                binding.addAttribute(fac.createOMAttribute(
208:                        WSDL2Constants.ATTRIBUTE_VERSION, wsoap,
209:                        WSDL2Constants.SOAP_VERSION_1_1));
210:                generateDefaultSOAPBindingOperations(axisService, fac, binding,
211:                        wsdl, tns, wsoap);
212:                return binding;
213:            }
214:
215:            /**
216:             * Generates a default SOAP 12 Binding for a given AxisService
217:             * @param fac - The OMFactory
218:             * @param axisService - The AxisService
219:             * @param wsdl the WSDL namespace
220:             * @param wsoap - The WSDL 2.0 SOAP namespace
221:             * @param tns - The target namespace
222:             * @return - The generated SOAP12Binding element
223:             */
224:            public static OMElement generateSOAP12Binding(OMFactory fac,
225:                    AxisService axisService, OMNamespace wsdl,
226:                    OMNamespace wsoap, OMNamespace tns) {
227:                OMElement binding = fac.createOMElement(
228:                        WSDL2Constants.BINDING_LOCAL_NAME, wsdl);
229:                binding
230:                        .addAttribute(fac
231:                                .createOMAttribute(
232:                                        WSDL2Constants.ATTRIBUTE_NAME,
233:                                        null,
234:                                        axisService.getName()
235:                                                + Java2WSDLConstants.SOAP12BINDING_NAME_SUFFIX));
236:                binding.addAttribute(fac.createOMAttribute(
237:                        WSDL2Constants.INTERFACE_LOCAL_NAME, null, tns
238:                                .getPrefix()
239:                                + ":" + WSDL2Constants.DEFAULT_INTERFACE_NAME));
240:
241:                binding.addAttribute(fac.createOMAttribute(
242:                        WSDL2Constants.ATTRIBUTE_TYPE, null,
243:                        WSDL2Constants.URI_WSDL2_SOAP));
244:                binding.addAttribute(fac.createOMAttribute(
245:                        WSDL2Constants.ATTRIBUTE_VERSION, wsoap,
246:                        WSDL2Constants.SOAP_VERSION_1_2));
247:                generateDefaultSOAPBindingOperations(axisService, fac, binding,
248:                        wsdl, tns, wsoap);
249:                return binding;
250:            }
251:
252:            /**
253:             * Generates a default HTTP Binding for a given AxisService
254:             * @param fac - The OMFactory
255:             * @param axisService - The AxisService
256:             * @param wsdl the WSDL namespace
257:             * @param whttp - The WSDL 2.0 HTTP namespace
258:             * @param tns - The target namespace
259:             * @return - The generated HTTPBinding element
260:             */
261:            public static OMElement generateHTTPBinding(OMFactory fac,
262:                    AxisService axisService, OMNamespace wsdl,
263:                    OMNamespace whttp, OMNamespace tns) {
264:                OMElement binding = fac.createOMElement(
265:                        WSDL2Constants.BINDING_LOCAL_NAME, wsdl);
266:                String serviceName = axisService.getName();
267:                binding.addAttribute(fac.createOMAttribute(
268:                        WSDL2Constants.ATTRIBUTE_NAME, null, serviceName
269:                                + Java2WSDLConstants.HTTP_BINDING));
270:                binding.addAttribute(fac.createOMAttribute(
271:                        WSDL2Constants.INTERFACE_LOCAL_NAME, null, tns
272:                                .getPrefix()
273:                                + ":" + WSDL2Constants.DEFAULT_INTERFACE_NAME));
274:
275:                binding.addAttribute(fac.createOMAttribute(
276:                        WSDL2Constants.ATTRIBUTE_TYPE, null,
277:                        WSDL2Constants.URI_WSDL2_HTTP));
278:                Iterator iterator = axisService.getChildren();
279:                while (iterator.hasNext()) {
280:                    AxisOperation axisOperation = (AxisOperation) iterator
281:                            .next();
282:                    OMElement opElement = fac.createOMElement(
283:                            WSDL2Constants.OPERATION_LOCAL_NAME, wsdl);
284:                    binding.addChild(opElement);
285:                    String name = axisOperation.getName().getLocalPart();
286:                    opElement.addAttribute(fac.createOMAttribute(
287:                            WSDL2Constants.ATTRIBUTE_REF, null, tns.getPrefix()
288:                                    + ":" + name));
289:                    opElement.addAttribute(fac.createOMAttribute(
290:                            WSDL2Constants.ATTRIBUTE_LOCATION, whttp,
291:                            serviceName + "/" + name));
292:                }
293:                return binding;
294:            }
295:
296:            private static void generateDefaultSOAPBindingOperations(
297:                    AxisService axisService, OMFactory omFactory,
298:                    OMElement binding, OMNamespace wsdl, OMNamespace tns,
299:                    OMNamespace wsoap) {
300:                Iterator iterator = axisService.getChildren();
301:                while (iterator.hasNext()) {
302:                    AxisOperation axisOperation = (AxisOperation) iterator
303:                            .next();
304:                    if (axisOperation.isControlOperation()) {
305:                        continue;
306:                    }
307:                    OMElement opElement = omFactory.createOMElement(
308:                            WSDL2Constants.OPERATION_LOCAL_NAME, wsdl);
309:                    binding.addChild(opElement);
310:                    String name = axisOperation.getName().getLocalPart();
311:                    opElement.addAttribute(omFactory.createOMAttribute(
312:                            WSDL2Constants.ATTRIBUTE_REF, null, tns.getPrefix()
313:                                    + ":" + name));
314:                    String soapAction = axisOperation.getSoapAction();
315:                    if (soapAction != null) {
316:                        opElement.addAttribute(omFactory.createOMAttribute(
317:                                WSDL2Constants.ATTRIBUTE_ACTION, wsoap,
318:                                soapAction));
319:                    }
320:                }
321:            }
322:
323:            /**
324:             * Generates a default service element
325:             * @param omFactory - The OMFactory
326:             * @param wsdl the WSDL namespace
327:             * @param tns - The targetnamespace
328:             * @param axisService - The AxisService
329:             * @param disableREST only generate REST endpoint if this is false
330:             * @return - The generated service element
331:             * @throws AxisFault - Thrown in case an exception occurs
332:             */
333:            public static OMElement generateServiceElement(OMFactory omFactory,
334:                    OMNamespace wsdl, OMNamespace tns, AxisService axisService,
335:                    boolean disableREST) throws AxisFault {
336:                return generateServiceElement(omFactory, wsdl, tns,
337:                        axisService, disableREST, null);
338:            }
339:
340:            /**
341:             * Generates a default service element
342:             * @param omFactory - The OMFactory
343:             * @param wsdl the WSDL namespace
344:             * @param tns - The targetnamespace
345:             * @param axisService - The AxisService
346:             * @param disableREST only generate REST endpoint if this is false
347:             * @return - The generated service element
348:             * @throws AxisFault - Thrown in case an exception occurs
349:             */
350:            public static OMElement generateServiceElement(OMFactory omFactory,
351:                    OMNamespace wsdl, OMNamespace tns, AxisService axisService,
352:                    boolean disableREST, String[] eprs) throws AxisFault {
353:                if (eprs == null) {
354:                    eprs = axisService.getEPRs();
355:                    if (eprs == null) {
356:                        eprs = new String[] { axisService.getName() };
357:                    }
358:                }
359:                OMElement serviceElement;
360:                serviceElement = omFactory.createOMElement(
361:                        WSDL2Constants.SERVICE_LOCAL_NAME, wsdl);
362:                serviceElement.addAttribute(omFactory.createOMAttribute(
363:                        WSDL2Constants.ATTRIBUTE_NAME, null, axisService
364:                                .getName()));
365:                serviceElement.addAttribute(omFactory.createOMAttribute(
366:                        WSDL2Constants.INTERFACE_LOCAL_NAME, null, tns
367:                                .getPrefix()
368:                                + ":" + WSDL2Constants.DEFAULT_INTERFACE_NAME));
369:                for (int i = 0; i < eprs.length; i++) {
370:                    String name = "";
371:                    String epr = eprs[i];
372:                    if (epr.startsWith("https://")) {
373:                        name = WSDL2Constants.DEFAULT_HTTPS_PREFIX;
374:                    }
375:                    OMElement soap11EndpointElement = omFactory
376:                            .createOMElement(
377:                                    WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
378:                    soap11EndpointElement
379:                            .addAttribute(omFactory
380:                                    .createOMAttribute(
381:                                            WSDL2Constants.ATTRIBUTE_NAME,
382:                                            null,
383:                                            name
384:                                                    + WSDL2Constants.DEFAULT_SOAP11_ENDPOINT_NAME));
385:                    soap11EndpointElement
386:                            .addAttribute(omFactory
387:                                    .createOMAttribute(
388:                                            WSDL2Constants.BINDING_LOCAL_NAME,
389:                                            null,
390:                                            tns.getPrefix()
391:                                                    + ":"
392:                                                    + axisService.getName()
393:                                                    + Java2WSDLConstants.BINDING_NAME_SUFFIX));
394:                    soap11EndpointElement
395:                            .addAttribute(omFactory
396:                                    .createOMAttribute(
397:                                            WSDL2Constants.ATTRIBUTE_ADDRESS,
398:                                            null, epr));
399:                    serviceElement.addChild(soap11EndpointElement);
400:                    OMElement soap12EndpointElement = omFactory
401:                            .createOMElement(
402:                                    WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
403:                    soap12EndpointElement
404:                            .addAttribute(omFactory
405:                                    .createOMAttribute(
406:                                            WSDL2Constants.ATTRIBUTE_NAME,
407:                                            null,
408:                                            name
409:                                                    + WSDL2Constants.DEFAULT_SOAP12_ENDPOINT_NAME));
410:                    soap12EndpointElement
411:                            .addAttribute(omFactory
412:                                    .createOMAttribute(
413:                                            WSDL2Constants.BINDING_LOCAL_NAME,
414:                                            null,
415:                                            tns.getPrefix()
416:                                                    + ":"
417:                                                    + axisService.getName()
418:                                                    + Java2WSDLConstants.SOAP12BINDING_NAME_SUFFIX));
419:                    soap12EndpointElement
420:                            .addAttribute(omFactory
421:                                    .createOMAttribute(
422:                                            WSDL2Constants.ATTRIBUTE_ADDRESS,
423:                                            null, epr));
424:                    serviceElement.addChild(soap12EndpointElement);
425:                    OMElement httpEndpointElement = null;
426:                    if (!disableREST) {
427:                        httpEndpointElement = omFactory.createOMElement(
428:                                WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
429:                        httpEndpointElement
430:                                .addAttribute(omFactory
431:                                        .createOMAttribute(
432:                                                WSDL2Constants.ATTRIBUTE_NAME,
433:                                                null,
434:                                                name
435:                                                        + WSDL2Constants.DEFAULT_HTTP_ENDPOINT_NAME));
436:                        httpEndpointElement
437:                                .addAttribute(omFactory
438:                                        .createOMAttribute(
439:                                                WSDL2Constants.BINDING_LOCAL_NAME,
440:                                                null,
441:                                                tns.getPrefix()
442:                                                        + ":"
443:                                                        + axisService.getName()
444:                                                        + Java2WSDLConstants.HTTP_BINDING));
445:                        httpEndpointElement.addAttribute(omFactory
446:                                .createOMAttribute(
447:                                        WSDL2Constants.ATTRIBUTE_ADDRESS, null,
448:                                        epr));
449:                        serviceElement.addChild(httpEndpointElement);
450:                    }
451:                    if (epr.startsWith("https://")) {
452:                        OMElement soap11Documentation = omFactory
453:                                .createOMElement(WSDL2Constants.DOCUMENTATION,
454:                                        wsdl);
455:                        soap11Documentation
456:                                .setText("This endpoint exposes a SOAP 11 binding over a HTTPS");
457:                        soap11EndpointElement.addChild(soap11Documentation);
458:                        OMElement soap12Documentation = omFactory
459:                                .createOMElement(WSDL2Constants.DOCUMENTATION,
460:                                        wsdl);
461:                        soap12Documentation
462:                                .setText("This endpoint exposes a SOAP 12 binding over a HTTPS");
463:                        soap12EndpointElement.addChild(soap12Documentation);
464:                        if (!disableREST) {
465:                            OMElement httpDocumentation = omFactory
466:                                    .createOMElement(
467:                                            WSDL2Constants.DOCUMENTATION, wsdl);
468:                            httpDocumentation
469:                                    .setText("This endpoint exposes a HTTP binding over a HTTPS");
470:                            httpEndpointElement.addChild(httpDocumentation);
471:                        }
472:                    } else if (epr.startsWith("http://")) {
473:                        OMElement soap11Documentation = omFactory
474:                                .createOMElement(WSDL2Constants.DOCUMENTATION,
475:                                        wsdl);
476:                        soap11Documentation
477:                                .setText("This endpoint exposes a SOAP 11 binding over a HTTP");
478:                        soap11EndpointElement.addChild(soap11Documentation);
479:                        OMElement soap12Documentation = omFactory
480:                                .createOMElement(WSDL2Constants.DOCUMENTATION,
481:                                        wsdl);
482:                        soap12Documentation
483:                                .setText("This endpoint exposes a SOAP 12 binding over a HTTP");
484:                        soap12EndpointElement.addChild(soap12Documentation);
485:                        if (!disableREST) {
486:                            OMElement httpDocumentation = omFactory
487:                                    .createOMElement(
488:                                            WSDL2Constants.DOCUMENTATION, wsdl);
489:                            httpDocumentation
490:                                    .setText("This endpoint exposes a HTTP binding over a HTTP");
491:                            httpEndpointElement.addChild(httpDocumentation);
492:                        }
493:                    }
494:                }
495:                return serviceElement;
496:            }
497:
498:            /**
499:             * Adds the namespaces to the given OMElement
500:             *
501:             * @param descriptionElement - The OMElement that the namespaces should be added to
502:             * @param nameSpaceMap - The namespaceMap
503:             */
504:            public static void populateNamespaces(OMElement descriptionElement,
505:                    Map nameSpaceMap) {
506:                if (nameSpaceMap != null) {
507:                    Iterator keys = nameSpaceMap.keySet().iterator();
508:                    while (keys.hasNext()) {
509:                        String key = (String) keys.next();
510:                        if ("".equals(key)) {
511:                            descriptionElement
512:                                    .declareDefaultNamespace((String) nameSpaceMap
513:                                            .get(key));
514:                        } else {
515:                            descriptionElement.declareNamespace(
516:                                    (String) nameSpaceMap.get(key), key);
517:                        }
518:                    }
519:                }
520:            }
521:
522:            public static void addWSAWActionAttribute(OMElement element,
523:                    String action, OMNamespace wsaw) {
524:                if (action == null || action.length() == 0) {
525:                    return;
526:                }
527:                element.addAttribute("Action", action, wsaw);
528:            }
529:
530:            public static void addExtensionElement(OMFactory fac,
531:                    OMElement element, String name, String att1Name,
532:                    String att1Value, OMNamespace soapNameSpace) {
533:                OMElement extElement = fac.createOMElement(name, soapNameSpace);
534:                element.addChild(extElement);
535:                extElement.addAttribute(att1Name, att1Value, null);
536:            }
537:
538:            public static void addWSAddressingToBinding(String addressingFlag,
539:                    OMFactory omFactory, OMElement bindingElement,
540:                    OMNamespace wsaw) {
541:                // Add WS-Addressing UsingAddressing element if appropriate
542:                // SHOULD be on the binding element per the specification
543:                if (addressingFlag
544:                        .equals(AddressingConstants.ADDRESSING_OPTIONAL)) {
545:                    WSDLSerializationUtil.addExtensionElement(omFactory,
546:                            bindingElement,
547:                            AddressingConstants.USING_ADDRESSING, "required",
548:                            "true", wsaw);
549:                } else if (addressingFlag
550:                        .equals(AddressingConstants.ADDRESSING_REQUIRED)) {
551:                    WSDLSerializationUtil.addExtensionElement(omFactory,
552:                            bindingElement,
553:                            AddressingConstants.USING_ADDRESSING, "required",
554:                            "true", wsaw);
555:                }
556:            }
557:
558:            public static void addWSDLDocumentationElement(
559:                    AxisDescription axisDescription, OMElement omElement,
560:                    OMFactory omFactory, OMNamespace wsdl) {
561:                String documentationString = axisDescription.getDocumentation();
562:                OMElement documentation;
563:                if (documentationString != null
564:                        && !"".equals(documentationString)) {
565:                    documentation = omFactory.createOMElement(
566:                            WSDL2Constants.DOCUMENTATION, wsdl);
567:                    OMText omText;
568:                    if (documentationString.indexOf(CDATA_START) > -1) {
569:                        documentationString = documentationString.replaceFirst(
570:                                CDATA_START_REGEX, "");
571:                        documentationString = documentationString.replaceFirst(
572:                                CDATA_END_REGEX, "");
573:                        omText = omFactory.createOMText(documentationString,
574:                                XMLStreamConstants.CDATA);
575:                    } else {
576:                        omText = omFactory.createOMText(documentationString);
577:                    }
578:                    documentation.addChild(omText);
579:                    omElement.addChild(documentation);
580:                }
581:            }
582:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.