Source Code Cross Referenced for WSDLBindingFactory.java in  » Workflow-Engines » bexee » bexee » wsdl » 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 » Workflow Engines » bexee » bexee.wsdl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: WSDLBindingFactory.java,v 1.9 2004/12/09 12:34:49 kowap Exp $
003:         *
004:         * Copyright (c) 2004 Patric Fornasier, Pawel Kowalski
005:         * Berne University of Applied Sciences
006:         * School of Engineering and Information Technology
007:         * All rights reserved.
008:         */
009:        package bexee.wsdl;
010:
011:        import java.util.Iterator;
012:        import java.util.List;
013:        import java.util.Map;
014:
015:        import javax.wsdl.Binding;
016:        import javax.wsdl.BindingFault;
017:        import javax.wsdl.BindingInput;
018:        import javax.wsdl.BindingOperation;
019:        import javax.wsdl.BindingOutput;
020:        import javax.wsdl.Definition;
021:        import javax.wsdl.Fault;
022:        import javax.wsdl.Input;
023:        import javax.wsdl.Operation;
024:        import javax.wsdl.Output;
025:        import javax.wsdl.Port;
026:        import javax.wsdl.PortType;
027:        import javax.wsdl.Service;
028:        import javax.wsdl.WSDLException;
029:        import javax.wsdl.extensions.ExtensibilityElement;
030:        import javax.wsdl.extensions.ExtensionRegistry;
031:        import javax.wsdl.extensions.soap.SOAPAddress;
032:        import javax.wsdl.extensions.soap.SOAPBinding;
033:        import javax.wsdl.extensions.soap.SOAPBody;
034:        import javax.wsdl.extensions.soap.SOAPFault;
035:        import javax.wsdl.extensions.soap.SOAPOperation;
036:        import javax.xml.namespace.QName;
037:
038:        import bexee.util.Constants;
039:
040:        /**
041:         * This class is used as a WSDL:Binding and WSDL:Service factory. It will be
042:         * used for the generation of concrete bindings and services for abstract web
043:         * services.
044:         * 
045:         * @version $Revision: 1.9 $, $Date: 2004/12/09 12:34:49 $
046:         * @author Patric Fornasier
047:         * @author Pawel Kowalski
048:         */
049:        public class WSDLBindingFactory {
050:
051:            /**
052:             * Add a binding information to the Definitions instance. Uses the given URI
053:             * String as the service location.
054:             * 
055:             * @param definition
056:             * @param uri
057:             * @return @throws
058:             *         WSDLException
059:             */
060:            public Definition addBinding(Definition definition, String uri)
061:                    throws WSDLException {
062:
063:                ExtensionRegistry extReg = definition.getExtensionRegistry();
064:
065:                // create and add operationbindings
066:                Map portTypes = definition.getPortTypes();
067:                for (Iterator iter = portTypes.values().iterator(); iter
068:                        .hasNext();) {
069:                    PortType portType = (PortType) iter.next();
070:
071:                    // create and add a binding
072:                    Binding binding = getBinding(portType, definition);
073:                    definition.addBinding(binding);
074:
075:                    // create and add a service
076:                    definition.addService(getService(binding, portType,
077:                            definition, uri));
078:                }
079:
080:                // add the soap address to the definition
081:                definition.addNamespace(Constants.WSDL_SOAP_PPREFIX,
082:                        Constants.URI_WSDL_SOAP);
083:                definition.addNamespace(Constants.WSDL_PRFIX,
084:                        Constants.URI_WSDL);
085:
086:                return definition;
087:            }
088:
089:            private Service getService(Binding binding, PortType portType,
090:                    Definition def, String uri) throws WSDLException {
091:
092:                ExtensionRegistry extReg = def.getExtensionRegistry();
093:
094:                // create a service for the portType
095:                Service service = def.createService();
096:                service.setQName(new QName(portType.getQName()
097:                        .getNamespaceURI(), portType.getQName().getLocalPart()
098:                        + Constants.SERVICE_SUFFIX));
099:
100:                // create a port and add it to the service
101:                Port port = def.createPort();
102:                port.setBinding(binding);
103:                port.setName(portType.getQName().getLocalPart());
104:                service.addPort(port);
105:
106:                // create a soapaddress and add it to the port
107:                SOAPAddress soapAddress = (SOAPAddress) extReg.createExtension(
108:                        Port.class, Constants.SOAP_ADDRESS_QNAME);
109:                soapAddress.setLocationURI(uri);
110:                port.addExtensibilityElement(soapAddress);
111:
112:                return service;
113:            }
114:
115:            private Binding getBinding(PortType portType, Definition def)
116:                    throws WSDLException {
117:
118:                ExtensionRegistry extReg = def.getExtensionRegistry();
119:
120:                // Create a binding
121:                Binding binding = def.createBinding();
122:                binding.setUndefined(false);
123:                binding.setQName(new QName(portType.getQName()
124:                        .getNamespaceURI(), portType.getQName().getLocalPart()
125:                        + Constants.SOAP_BINDING_SUFFIX));
126:                binding.setPortType(portType);
127:
128:                // create a soapbinding
129:                SOAPBinding soapBinding = (SOAPBinding) extReg.createExtension(
130:                        Binding.class, Constants.SOAP_BINDING_QNAME);
131:                soapBinding.setStyle(bexee.util.Constants.DEFAULT_STYLE);
132:                soapBinding.setTransportURI(bexee.util.Constants.URI_SOAP_HTTP);
133:
134:                // add the soapbinding
135:                binding.addExtensibilityElement(soapBinding);
136:
137:                // create and add operationbindings
138:                List operations = portType.getOperations();
139:                for (Iterator iterator = operations.iterator(); iterator
140:                        .hasNext();) {
141:                    Operation operation = (Operation) iterator.next();
142:                    binding.addBindingOperation(getBindingOperation(operation,
143:                            def));
144:                }
145:
146:                return binding;
147:            }
148:
149:            private BindingOperation getBindingOperation(Operation operation,
150:                    Definition definition) throws WSDLException {
151:
152:                // get the extension registry for element creation
153:                ExtensionRegistry extReg = definition.getExtensionRegistry();
154:
155:                // create the parts of the BindingOperation
156:                BindingOperation bindingOper = definition
157:                        .createBindingOperation();
158:                BindingInput bindingInput = definition.createBindingInput();
159:                BindingOutput bindingOutput = definition.createBindingOutput();
160:
161:                // set properties of the BindingOperation
162:                bindingOper.setName(operation.getName());
163:                bindingOper.setOperation(operation);
164:
165:                // create a soapoperation and set it
166:                SOAPOperation soapOper = (SOAPOperation) extReg
167:                        .createExtension(BindingOperation.class,
168:                                Constants.SOAP_OPERATION_QNAME);
169:                soapOper.setSoapActionURI("");
170:                bindingOper.addExtensibilityElement(soapOper);
171:
172:                // Input clause
173:                bindingOper.setBindingInput(getBindingInput(operation
174:                        .getInput(), definition));
175:
176:                // Output clause
177:                bindingOper.setBindingOutput(getBindingOutput(operation
178:                        .getOutput(), definition));
179:
180:                // Faults clause
181:                Map faults = operation.getFaults();
182:                for (Iterator iter = faults.values().iterator(); iter.hasNext();) {
183:                    Fault fault = (Fault) iter.next();
184:                    bindingOper.addBindingFault(getBindingFault(fault,
185:                            definition));
186:                }
187:
188:                return bindingOper;
189:            }
190:
191:            private BindingInput getBindingInput(Input input,
192:                    Definition definition) throws WSDLException {
193:
194:                // create an input and set properties
195:                BindingInput bindInput = definition.createBindingInput();
196:                bindInput.setName(input.getMessage().getQName().getLocalPart());
197:
198:                bindInput.addExtensibilityElement(getSOAPBody(bindInput
199:                        .getClass(), definition));
200:
201:                return bindInput;
202:            }
203:
204:            private BindingOutput getBindingOutput(Output output,
205:                    Definition definition) throws WSDLException {
206:
207:                // create an input and set properties
208:                BindingOutput bindOutput = definition.createBindingOutput();
209:                bindOutput.setName(output.getMessage().getQName()
210:                        .getLocalPart());
211:
212:                bindOutput.addExtensibilityElement(getSOAPBody(bindOutput
213:                        .getClass(), definition));
214:                return bindOutput;
215:            }
216:
217:            private BindingFault getBindingFault(Fault fault,
218:                    Definition definition) throws WSDLException {
219:
220:                BindingFault bindingFault = definition.createBindingFault();
221:                bindingFault.setName(fault.getName());
222:                bindingFault.addExtensibilityElement(getSOAPFault(bindingFault,
223:                        definition));
224:
225:                return bindingFault;
226:
227:            }
228:
229:            private ExtensibilityElement getSOAPBody(Class clazz,
230:                    Definition definition) throws WSDLException {
231:
232:                // get the extension registry for element creation
233:                ExtensionRegistry extReg = definition.getExtensionRegistry();
234:
235:                // create a soapbody
236:                SOAPBody soapBody = (SOAPBody) extReg.createExtension(clazz
237:                        .getInterfaces()[0], Constants.SOAP_BODY_QNAME);
238:
239:                // set properties
240:                soapBody.setUse(Constants.DEFAULT_USE);
241:                soapBody.setEncodingStyles(Constants.ENCODING_STYLES);
242:                soapBody.setNamespaceURI(definition.getTargetNamespace());
243:
244:                return soapBody;
245:            }
246:
247:            private SOAPFault getSOAPFault(BindingFault fault,
248:                    Definition definition) throws WSDLException {
249:
250:                // get the extension registry for element creation
251:                ExtensionRegistry extReg = definition.getExtensionRegistry();
252:
253:                SOAPFault soapFault = (SOAPFault) extReg.createExtension(
254:                        BindingFault.class, Constants.SOAP_FAULT_QNAME);
255:
256:                soapFault.setUse(Constants.DEFAULT_USE);
257:                soapFault.setEncodingStyles(Constants.ENCODING_STYLES);
258:
259:                return soapFault;
260:            }
261:
262:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.