KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > wsdl > builder > wsdl4j > WSDLPump


1 /*
2 * Copyright 2001-2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */

16 package org.apache.axis2.wsdl.builder.wsdl4j;
17
18 import com.ibm.wsdl.extensions.soap.SOAPConstants;
19 import org.apache.axis2.wsdl.builder.WSDLComponentFactory;
20 import org.apache.crimson.tree.XmlDocument;
21 import org.apache.wsdl.*;
22 import org.apache.wsdl.extensions.DefaultExtensibilityElement;
23 import org.apache.wsdl.extensions.ExtensionConstants;
24 import org.apache.wsdl.extensions.ExtensionFactory;
25 import org.apache.wsdl.impl.WSDLProcessingException;
26 import org.w3c.dom.Document JavaDoc;
27 import org.w3c.dom.Element JavaDoc;
28
29 import javax.wsdl.*;
30 import javax.wsdl.extensions.ExtensibilityElement;
31 import javax.wsdl.extensions.UnknownExtensibilityElement;
32 import javax.wsdl.extensions.schema.Schema;
33 import javax.wsdl.extensions.soap.SOAPAddress;
34 import javax.wsdl.extensions.soap.SOAPBinding;
35 import javax.wsdl.extensions.soap.SOAPBody;
36 import javax.wsdl.extensions.soap.SOAPOperation;
37 import javax.xml.namespace.QName JavaDoc;
38 import java.util.Iterator JavaDoc;
39 import java.util.LinkedList JavaDoc;
40 import java.util.List JavaDoc;
41 import java.util.Map JavaDoc;
42
43 /**
44  * @author chathura@opensource.lk
45  */

46 public class WSDLPump {
47
48     private static final String JavaDoc BOUND_INTERFACE_NAME = "BoundInterface";
49
50     private WSDLDescription womDefinition;
51
52     private Definition wsdl4jParsedDefinition;
53
54     private WSDLComponentFactory wsdlComponenetFactory;
55
56
57     private List JavaDoc resolvedMultipartMessageList = new LinkedList JavaDoc();
58
59     public WSDLPump(WSDLDescription womDefinition,
60                     Definition wsdl4jParsedDefinition) {
61         this(womDefinition, wsdl4jParsedDefinition, womDefinition);
62     }
63
64     public WSDLPump(WSDLDescription womDefinition,
65                     Definition wsdl4jParsedDefinition,
66                     WSDLComponentFactory wsdlComponentFactory) {
67         this.womDefinition = womDefinition;
68         this.wsdl4jParsedDefinition = wsdl4jParsedDefinition;
69         this.wsdlComponenetFactory = wsdlComponentFactory;
70     }
71
72     public void pump() {
73         if (null != this.wsdl4jParsedDefinition && null != this.womDefinition) {
74             this.populateDefinition(this.womDefinition,
75                     this.wsdl4jParsedDefinition);
76         } else {
77             throw new WSDLProcessingException("Properties not set properly");
78         }
79
80     }
81
82     private void populateDefinition(WSDLDescription wsdlDefinition,
83                                     Definition wsdl4JDefinition) {
84         //Go through the WSDL4J Definition and pump it to the WOM
85
wsdlDefinition.setWSDL1DefinitionName(wsdl4JDefinition.getQName());
86         wsdlDefinition
87                 .setTargetNameSpace(wsdl4JDefinition.getTargetNamespace());
88         wsdlDefinition.setNamespaces(wsdl4JDefinition.getNamespaces());
89         this.copyExtensibleElements(wsdl4JDefinition.getExtensibilityElements(), wsdlDefinition);
90
91         /////////////////////////////////////////////////////////////////////
92
// Order of the following items shouldn't be changed unless you //
93
// really know what you are doing. Reason being the components that //
94
// are copied(pumped) towards the end depend on the components that //
95
// has already being pumped. Following Lists some of the //
96
// dependencies. //
97
//1) The Binding refers to the Interface //
98
//2) The Endpoint refers to the Bindings //
99
// .... //
100
// //
101
//////////////////////////////////////////////////////////////////////
102

103         //////////////////(1)First Copy the Types/////////////////////////////
104
//Types may get changed inside the Operation pumping.
105

106         Types wsdl4jTypes = wsdl4JDefinition.getTypes();
107         if (null != wsdl4jTypes) {
108             WSDLTypes wsdlTypes = this.wsdlComponenetFactory.createTypes();
109
110
111             this.copyExtensibleElements(wsdl4jTypes.getExtensibilityElements(),
112                     wsdlTypes);
113
114             this.womDefinition.setTypes(wsdlTypes);
115         }
116
117         ///////////////////(2)Copy the Interfaces///////////////////////////
118
//copy the Interfaces: Get the PortTypes from WSDL4J parse OM and
119
// copy it to the
120
//WOM's WSDLInterface Components
121

122         Iterator JavaDoc portTypeIterator = wsdl4JDefinition.getPortTypes().values()
123                 .iterator();
124         WSDLInterface wsdlInterface;
125         PortType portType;
126         while (portTypeIterator.hasNext()) {
127             wsdlInterface = this.wsdlComponenetFactory.createInterface();
128             portType = (PortType) portTypeIterator.next();
129             this.populateInterfaces(wsdlInterface, portType);
130             this.copyExtensibilityAttribute(portType.getExtensionAttributes(),
131                     wsdlInterface);
132             wsdlDefinition.addInterface(wsdlInterface);
133         }
134
135         //////////////////(3)Copy the Bindings///////////////////////
136
//pump the Bindings: Get the Bindings map from WSDL4J and create a new
137
// map of
138
//WSDLBinding elements
139

140         Iterator JavaDoc bindingIterator = wsdl4JDefinition.getBindings().values()
141                 .iterator();
142         WSDLBinding wsdlBinding;
143         Binding wsdl4jBinding;
144         while (bindingIterator.hasNext()) {
145             wsdlBinding = this.wsdlComponenetFactory.createBinding();
146             wsdl4jBinding = (Binding) bindingIterator.next();
147             this.populateBindings(wsdlBinding, wsdl4jBinding);
148             this.copyExtensibleElements(wsdl4jBinding.getExtensibilityElements(),
149                     wsdlBinding);
150             wsdlDefinition.addBinding(wsdlBinding);
151
152         }
153
154         ///////////////////(4)Copy the Services///////////////////////////////
155

156         Iterator JavaDoc serviceIterator = wsdl4JDefinition.getServices().values()
157                 .iterator();
158         WSDLService wsdlService;
159         Service wsdl4jService;
160         while (serviceIterator.hasNext()) {
161             wsdlService = this.wsdlComponenetFactory.createService();
162             wsdl4jService = (Service) serviceIterator.next();
163             this.populateServices(wsdlService, wsdl4jService);
164             this.copyExtensibleElements(wsdl4jService.getExtensibilityElements(),
165                     wsdlService);
166             wsdlDefinition.addService(wsdlService);
167         }
168
169     }
170
171     //////////////////////////////////////////////////////////////////////////////
172
////////////////////////// Top level Components Copying
173
// ////////////////////
174

175     /**
176      * Simply Copy information.
177      *
178      * @param wsdlInterface
179      * @param wsdl4jPortType
180      */

181     //FIXME Evaluate a way of injecting features and priperties with a general
182
// formatted input
183
private void populateInterfaces(WSDLInterface wsdlInterface,
184                                     PortType wsdl4jPortType) {
185
186         //Copy the Attrebute information items
187
//Copied with the Same QName so it will require no Query in Binding
188
//Coping.
189
wsdlInterface.setName(wsdl4jPortType.getQName());
190         Iterator JavaDoc wsdl4JOperationsIterator =
191                 wsdl4jPortType.getOperations().iterator();
192         WSDLOperation wsdloperation;
193         Operation wsdl4jOperation;
194         while (wsdl4JOperationsIterator.hasNext()) {
195             wsdloperation = this.wsdlComponenetFactory.createOperation();
196             wsdl4jOperation = (Operation) wsdl4JOperationsIterator.next();
197             this.populateOperations(wsdloperation,
198                     wsdl4jOperation,
199                     wsdl4jPortType.getQName().getNamespaceURI());
200             this.copyExtensibleElements(wsdl4jOperation.getExtensibilityElements(), wsdloperation);
201             wsdlInterface.setOperation(wsdloperation);
202         }
203     }
204
205     /**
206      * Pre Condition: The Interface Components must be copied by now.
207      */

208     private void populateBindings(WSDLBinding wsdlBinding, Binding wsdl4JBinding) {
209         //Copy attrebutes
210
wsdlBinding.setName(wsdl4JBinding.getQName());
211         QName JavaDoc interfaceName = wsdl4JBinding.getPortType().getQName();
212         WSDLInterface wsdlInterface =
213                 this.womDefinition.getInterface(interfaceName);
214
215         //FIXME Do We need this eventually???
216
if (null == wsdlInterface)
217             throw new WSDLProcessingException(
218                     "Interface/PortType not found for the Binding :"
219                     + wsdlBinding.getName());
220         wsdlBinding.setBoundInterface(wsdlInterface);
221         Iterator JavaDoc bindingoperationsIterator =
222                 wsdl4JBinding.getBindingOperations().iterator();
223         WSDLBindingOperation wsdlBindingOperation;
224         BindingOperation wsdl4jBindingOperation;
225         while (bindingoperationsIterator.hasNext()) {
226             wsdlBindingOperation =
227                     this.wsdlComponenetFactory.createWSDLBindingOperation();
228             wsdl4jBindingOperation =
229                     (BindingOperation)bindingoperationsIterator.next();
230             this.populateBindingOperation(wsdlBindingOperation,
231                     wsdl4jBindingOperation,
232                     wsdl4JBinding.getQName().getNamespaceURI());
233             wsdlBindingOperation.setOperation(
234                     wsdlInterface.getOperation(wsdl4jBindingOperation.getOperation().getName())
235             );
236             this.copyExtensibleElements(
237                     wsdl4jBindingOperation.getExtensibilityElements(),
238                     wsdlBindingOperation);
239             wsdlBinding.addBindingOperation(wsdlBindingOperation);
240         }
241
242     }
243
244     public void populateServices(WSDLService wsdlService, Service wsdl4jService) {
245         wsdlService.setName(wsdl4jService.getQName());
246         Iterator JavaDoc wsdl4jportsIterator =
247                 wsdl4jService.getPorts().values().iterator();
248         wsdlService.setServiceInterface(this.getBoundInterface(wsdlService));
249         WSDLEndpoint wsdlEndpoint;
250         Port wsdl4jPort;
251         while (wsdl4jportsIterator.hasNext()) {
252             wsdlEndpoint = this.wsdlComponenetFactory.createEndpoint();
253             wsdl4jPort = (Port) wsdl4jportsIterator.next();
254             this.populatePorts(wsdlEndpoint,
255                     wsdl4jPort,
256                     wsdl4jService.getQName().getNamespaceURI());
257             this.copyExtensibleElements(wsdl4jPort.getExtensibilityElements(),
258                     wsdlEndpoint);
259             wsdlService.setEndpoint(wsdlEndpoint);
260         }
261
262     }
263
264     /////////////////////////////////////////////////////////////////////////////
265
//////////////////////////// Internal Component Copying ///////////////////
266
public void populateOperations(WSDLOperation wsdlOperation,
267                                    Operation wsdl4jOperation, String JavaDoc nameSpaceOfTheOperation) {
268         //Copy Name Attrebute
269
wsdlOperation.setName(new QName JavaDoc(nameSpaceOfTheOperation,
270                 wsdl4jOperation.getName()));
271
272         //This code make no attempt to make use of the special xs:Token
273
//defined in the WSDL 2.0. eg like #any, #none
274
// Create the Input Message and add
275
Input wsdl4jInputMessage = wsdl4jOperation.getInput();
276
277         if(null != wsdl4jInputMessage){
278             MessageReference wsdlInputMessage = this.wsdlComponenetFactory
279                     .createMessageReference();
280             wsdlInputMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
281             wsdlInputMessage.setMessageLabel(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
282             
283             Message message = wsdl4jInputMessage.getMessage();
284             if(null != message){
285                 wsdlInputMessage.setElement(this.generateReferenceQname(message));
286                 this.copyExtensibleElements(
287                         (message).getExtensibilityElements(),
288                         wsdlInputMessage
289                 );
290             }
291             this.copyExtensibilityAttribute(wsdl4jInputMessage.getExtensionAttributes(),
292                     wsdlInputMessage);
293             wsdlOperation.setInputMessage(wsdlInputMessage);
294         }
295
296         //Create an output message and add
297
Output wsdl4jOutputMessage = wsdl4jOperation.getOutput();
298         if(null != wsdl4jOutputMessage){
299             MessageReference wsdlOutputMessage =
300                     this.wsdlComponenetFactory.createMessageReference();
301             wsdlOutputMessage.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
302             wsdlOutputMessage.setMessageLabel(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
303
304             Message outputMessage = wsdl4jOutputMessage.getMessage();
305             if(null != outputMessage){
306                 wsdlOutputMessage.setElement(this.generateReferenceQname(outputMessage));
307                 this.copyExtensibleElements(
308                         (outputMessage).getExtensibilityElements(),
309                         wsdlOutputMessage
310                 );
311             }
312             this.copyExtensibilityAttribute(wsdl4jOutputMessage.getExtensionAttributes(),
313                     wsdlOutputMessage);
314             wsdlOperation.setOutputMessage(wsdlOutputMessage);
315         }
316
317         Map JavaDoc faults = wsdl4jOperation.getFaults();
318         Iterator JavaDoc faultKeyIterator = faults.keySet().iterator();
319         WSDLFaultReference faultReference = null;
320
321         while(faultKeyIterator.hasNext()){
322
323             Fault fault = (Fault)faults.get(faultKeyIterator.next());
324             faultReference = wsdlComponenetFactory.createFaultReference();
325             faultReference.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
326             Message faultMessage = fault.getMessage();
327             if(null != faultMessage){
328                 faultReference.setRef(this.generateReferenceQname(faultMessage));
329             }
330             wsdlOperation.addOutFault(faultReference);
331             this.copyExtensibilityAttribute(fault.getExtensionAttributes(), faultReference);
332             //TODO Fault Message lable
333

334         }
335
336         //Set the MEP
337
wsdlOperation.setMessageExchangePattern(WSDL11MEPFinder
338                 .getMEP(wsdl4jOperation));
339
340     }
341     private QName JavaDoc generateReferenceQname(Message wsdl4jMessage){
342         QName JavaDoc referenceQName = null;
343         if (wsdl4jMessage.getParts().size() > 1){
344             // Multipart Message
345

346             // Check whether this message parts have been made to a type
347
Iterator JavaDoc multipartListIterator = this.resolvedMultipartMessageList.iterator();
348             boolean multipartAlreadyResolved = false;
349             while(multipartListIterator.hasNext() && !multipartAlreadyResolved){
350                 QName JavaDoc temp = (QName JavaDoc)multipartListIterator.next();
351                 multipartAlreadyResolved = wsdl4jMessage.getQName().equals(temp);
352             }
353             if(multipartAlreadyResolved){
354                 //This message with multiple parts has resolved and a new type has been
355
//made out of it earlier.
356
//FIXME Actual element name should it be xs:, if yes change the qname added to the
357
//resolvedmessage list too.
358
referenceQName = wsdl4jMessage.getQName();
359             }else{
360                 //Get the list of multiparts of the message and create a new Element
361
//out of it and add it to the schema.
362
Map JavaDoc parts = wsdl4jMessage.getParts();
363                 Element element = null;
364                 WSDLTypes types = womDefinition.getTypes();
365                 if(null == types){
366                     XmlDocument newDoc = new XmlDocument();
367
368                     Element schemaElement = newDoc.createElement("schema");//http://www.w3.org/2001/XMLSchema
369
types =wsdlComponenetFactory.createTypes();
370                     ExtensionFactory extensionFactory = wsdlComponenetFactory.createExtensionFactory();
371                     org.apache.wsdl.extensions.Schema typesElement = (org.apache.wsdl.extensions.Schema)extensionFactory.getExtensionElement(ExtensionConstants.SCHEMA);
372                     typesElement.setElelment(schemaElement);
373                     types.addExtensibilityElement(typesElement);
374                     this.womDefinition.setTypes(types);
375                 }
376                 Iterator JavaDoc schemaEIIterator = types.getExtensibilityElements().iterator();
377                 while(schemaEIIterator.hasNext()){
378                     WSDLExtensibilityElement temp = (WSDLExtensibilityElement)schemaEIIterator.next();
379                     if(ExtensionConstants.SCHEMA.equals(temp.getType())){
380                         element = ((org.apache.wsdl.extensions.Schema)temp).getElelment();
381                         break;
382                     }
383                 }
384
385                 Document doc = element.getOwnerDocument();
386                 String JavaDoc name = wsdl4jMessage.getQName().getLocalPart();
387                 Element newElement = doc.createElement("complexType");
388                 newElement.setAttribute("name", name);
389
390                 Element cmplxContent = doc.createElement("complexContent");
391                 Element child;
392                 Iterator JavaDoc iterator = parts.keySet().iterator();
393                 while(iterator.hasNext()){
394                     Part part = (Part)parts.get(iterator.next());
395                     QName JavaDoc elementName = part.getElementName();
396                     if(null == elementName){
397                         elementName = part.getTypeName();
398                     }
399
400
401                     child = doc.createElement("element");
402                     child.setAttribute("name", "var"+elementName.getLocalPart());
403                     child.setAttribute("type", elementName.getNamespaceURI()+":"+elementName.getLocalPart());
404                     cmplxContent.appendChild(child);
405                 }
406
407
408                 newElement.appendChild(cmplxContent);
409
410                 element.appendChild(newElement);
411                 //Now since a new type is created augmenting the parts add the QName
412
//of the newly created type as the messageReference's name.
413
referenceQName = wsdl4jMessage.getQName();
414                 //Add this message as a resolved message, so that incase some other
415
//operation refer to the same message the if above will take a hit
416
//and the cashed QName can be used instead of crating another type
417
//for the same message.
418

419                 this.resolvedMultipartMessageList.add(wsdl4jMessage.getQName());
420
421             }
422         }else{
423             //Only one part so copy the QName of the referenced type.
424
Iterator JavaDoc outputIterator =
425                     wsdl4jMessage.getParts().values().iterator();
426             if (outputIterator.hasNext()) {
427                 Part outPart = ((Part) outputIterator.next());
428                 QName JavaDoc typeName;
429                 if (null != (typeName = outPart.getTypeName())) {
430                     referenceQName = typeName;
431                 } else {
432                     referenceQName = outPart.getElementName();
433                 }
434             }
435         }
436         return referenceQName;
437     }
438
439     private void populateBindingOperation(
440             WSDLBindingOperation wsdlBindingOperation,
441             BindingOperation wsdl4jBindingOperation,
442             String JavaDoc nameSpaceOfTheBindingOperation) {
443
444         wsdlBindingOperation.setName(new QName JavaDoc(nameSpaceOfTheBindingOperation,
445                 wsdl4jBindingOperation.getName()));
446         BindingInput wsdl4jInputBinding =
447                 wsdl4jBindingOperation.getBindingInput();
448         if(null != wsdl4jInputBinding){
449             WSDLBindingMessageReference wsdlInputBinding =
450                     this.wsdlComponenetFactory.createWSDLBindingMessageReference();
451             wsdlInputBinding.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
452             this.copyExtensibleElements(wsdl4jInputBinding.getExtensibilityElements(),
453                     wsdlInputBinding);
454             wsdlBindingOperation.setInput(wsdlInputBinding);
455         }
456
457         BindingOutput wsdl4jOutputBinding = wsdl4jBindingOperation
458                 .getBindingOutput();
459         if(null != wsdl4jOutputBinding){
460             WSDLBindingMessageReference wsdlOutputBinding = this.wsdlComponenetFactory
461                     .createWSDLBindingMessageReference();
462             wsdlOutputBinding.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
463             
464             this.copyExtensibleElements(wsdl4jOutputBinding.getExtensibilityElements(),
465                     wsdlOutputBinding);
466             wsdlBindingOperation.setOutput(wsdlOutputBinding);
467         }
468
469
470         Map JavaDoc bindingFaults = wsdl4jBindingOperation.getBindingFaults();
471         Iterator JavaDoc keyIterator = bindingFaults.keySet().iterator();
472         while(keyIterator.hasNext()){
473             BindingFault bindingFault = (BindingFault)bindingFaults.get(keyIterator.next());
474             WSDLBindingFault womBindingFault = this.wsdlComponenetFactory.createBindingFault();
475             this.copyExtensibleElements(bindingFault.getExtensibilityElements(), womBindingFault);
476             wsdlBindingOperation.addOutFault(womBindingFault);
477         }
478
479     }
480
481     public void populatePorts(WSDLEndpoint wsdlEndpoint, Port wsdl4jPort,
482                               String JavaDoc targetNamspace) {
483         wsdlEndpoint.setName(new QName JavaDoc(targetNamspace, wsdl4jPort.getName()));
484
485         wsdlEndpoint.setBinding(this.womDefinition.getBinding(wsdl4jPort
486                 .getBinding().getQName()));
487
488     }
489
490     /**
491      * This method will fill up the gap of WSDL 1.1 and WSDL 2.0 w.r.t. the
492      * bound interface for the Service Component Defined in the WSDL 2.0. Logic
493      * being if there exist only one PortType in the WSDL 1.1 file then that
494      * will be set as the bound interface of the Service. If more than one
495      * Porttype exist in the WSDl 1.1 file this will create a dummy Interface
496      * with the available PortTypes and will return that interface so that it
497      * will inherit all those interfaces.
498      *
499      * Eventuall this will have to be fixed using user input since
500      *
501      * @param service
502      * @return
503      */

504     private WSDLInterface getBoundInterface(WSDLService service) {
505
506         // Throw an exception if there are no interfaces defined as at yet.
507
if (0 == this.womDefinition.getWsdlInterfaces().size())
508             throw new WSDLProcessingException(
509                     "There are no "
510                     + "Interfaces/PortTypes identified in the current partially built"
511                     + "WOM");
512
513         //If there is only one Interface available hten return that because
514
// normally
515
// that interface must be the one to the service should get bound.
516
if (1 == this.womDefinition.getWsdlInterfaces().size())
517             return (WSDLInterface) this.womDefinition.getWsdlInterfaces()
518                     .values().iterator().next();
519
520         //If there are more than one interface available... For the time being
521
// create a
522
// new interface and set all those existing interfaces as
523
// superinterfaces of it
524
// and return.
525
WSDLInterface newBoundInterface = this.womDefinition.createInterface();
526         newBoundInterface.setName(new QName JavaDoc(service.getNamespace(), service
527                 .getName().getLocalPart()
528                 + BOUND_INTERFACE_NAME));
529         Iterator JavaDoc interfaceIterator = this.womDefinition.getWsdlInterfaces()
530                 .values().iterator();
531         while (interfaceIterator.hasNext()) {
532             newBoundInterface
533                     .addSuperInterface((WSDLInterface) interfaceIterator.next());
534         }
535         return newBoundInterface;
536     }
537
538     /**
539      * Get the Extensible elements form wsdl4jExtensibleElements
540      * <code>Vector</code> if any and copy them to <code>Component</code>
541      *
542      * @param wsdl4jExtensibleElements
543      * @param womExtensibleElements
544      */

545     private void copyExtensibleElements(List JavaDoc wsdl4jExtensibleElements,
546                                         Component component) {
547         Iterator JavaDoc iterator = wsdl4jExtensibleElements.iterator();
548         ExtensionFactory extensionFactory = this.wsdlComponenetFactory
549                 .createExtensionFactory();
550         while (iterator.hasNext()) {
551
552             ExtensibilityElement wsdl4jElement = (ExtensibilityElement) iterator
553                     .next();
554
555             if (wsdl4jElement instanceof UnknownExtensibilityElement) {
556                 UnknownExtensibilityElement unknown = (UnknownExtensibilityElement) (wsdl4jElement);
557                 DefaultExtensibilityElement extensibilityElement = (DefaultExtensibilityElement) extensionFactory
558                         .getExtensionElement(wsdl4jElement.getElementType());
559                 extensibilityElement.setElement(unknown.getElement());
560                 Boolean JavaDoc required = unknown.getRequired();
561                 if (null != required) {
562                     extensibilityElement.setRequired(required.booleanValue());
563                 }
564                 component.addExtensibilityElement(extensibilityElement);
565             } else if (wsdl4jElement instanceof SOAPAddress) {
566                 SOAPAddress soapAddress = (SOAPAddress) wsdl4jElement;
567                 org.apache.wsdl.extensions.SOAPAddress extensibilityElement = (org.apache.wsdl.extensions.SOAPAddress) extensionFactory
568                         .getExtensionElement(soapAddress.getElementType());
569                 extensibilityElement.setLocationURI(soapAddress
570                         .getLocationURI());
571                 Boolean JavaDoc required = soapAddress.getRequired();
572                 if (null != required) {
573                     extensibilityElement.setRequired(required.booleanValue());
574                 }
575                 component.addExtensibilityElement(extensibilityElement);
576             }else if(wsdl4jElement instanceof Schema) {
577                 Schema schema = (Schema)wsdl4jElement;
578                 org.apache.wsdl.extensions.Schema extensibilityElement = (org.apache.wsdl.extensions.Schema)extensionFactory.getExtensionElement(schema.getElementType());
579                 extensibilityElement.setElelment(schema.getElement());
580                 Boolean JavaDoc required = schema.getRequired();
581                 if(null != required){
582                     extensibilityElement.setRequired(required.booleanValue());
583                 }
584                 component.addExtensibilityElement(extensibilityElement);
585             }else if(SOAPConstants.Q_ELEM_SOAP_OPERATION.equals(wsdl4jElement.getElementType())){
586                 SOAPOperation soapOperation = (SOAPOperation)wsdl4jElement;
587                 org.apache.wsdl.extensions.SOAPOperation extensibilityElement = (org.apache.wsdl.extensions.SOAPOperation)extensionFactory.getExtensionElement(soapOperation.getElementType());
588                 extensibilityElement.setSoapAction(soapOperation.getSoapActionURI());
589                 extensibilityElement.setStyle(soapOperation.getStyle());
590                 Boolean JavaDoc required = soapOperation.getRequired();
591                 if(null != required){
592                     extensibilityElement.setRequired(required.booleanValue());
593                 }
594                 component.addExtensibilityElement(extensibilityElement);
595             }else if(SOAPConstants.Q_ELEM_SOAP_BODY.equals(wsdl4jElement.getElementType())){
596                 SOAPBody soapBody = (SOAPBody)wsdl4jElement;
597                 org.apache.wsdl.extensions.SOAPBody extensibilityElement = (org.apache.wsdl.extensions.SOAPBody)extensionFactory.getExtensionElement(soapBody.getElementType());
598                 extensibilityElement.setNamespaceURI(soapBody.getNamespaceURI());
599                 extensibilityElement.setUse(soapBody.getUse());
600                 Boolean JavaDoc required = soapBody.getRequired();
601                 if(null != required){
602                     extensibilityElement.setRequired(required.booleanValue());
603                 }
604                 component.addExtensibilityElement(extensibilityElement);
605             }else if(SOAPConstants.Q_ELEM_SOAP_BINDING.equals(wsdl4jElement.getElementType())){
606                 SOAPBinding soapBinding = (SOAPBinding)wsdl4jElement;
607                 org.apache.wsdl.extensions.SOAPBinding extensibilityElement = (org.apache.wsdl.extensions.SOAPBinding)extensionFactory.getExtensionElement(soapBinding.getElementType());
608                 extensibilityElement.setTransportURI(soapBinding.getTransportURI());
609                 extensibilityElement.setStyle(soapBinding.getStyle());
610                 Boolean JavaDoc required = soapBinding.getRequired();
611                 if(null != required){
612                     extensibilityElement.setRequired(required.booleanValue());
613                 }
614                 component.addExtensibilityElement(extensibilityElement);
615             }else {
616 // throw new AxisError(
617
// "An Extensible item "+wsdl4jElement.getElementType()+" went unparsed during WSDL Parsing");
618
}
619         }
620     }
621
622     /**
623      * Get the Extensible Attributes from wsdl4jExtensibilityAttribute
624      * <code>Map</code> if any and copy them to the <code>Component</code>
625      *
626      * @param wsdl4jExtensibilityAttributes
627      * @param component
628      */

629     private void copyExtensibilityAttribute(Map JavaDoc wsdl4jExtensibilityAttributes,
630                                             Component component) {
631         Iterator JavaDoc iterator = wsdl4jExtensibilityAttributes.keySet().iterator();
632         while (iterator.hasNext()) {
633             QName JavaDoc attributeName = (QName JavaDoc) iterator.next();
634             QName JavaDoc value = (QName JavaDoc) wsdl4jExtensibilityAttributes
635                     .get(attributeName);
636             WSDLExtensibilityAttribute attribute = this.wsdlComponenetFactory
637                     .createWSDLExtensibilityAttribute();
638             attribute.setKey(attributeName);
639             attribute.setValue(value);
640             component.addExtensibleAttributes(attribute);
641         }
642     }
643
644 }
Popular Tags