You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by br...@apache.org on 2007/01/09 18:29:44 UTC

svn commit: r494510 [3/3] - in /incubator/yoko/trunk: bindings/src/main/java/org/apache/yoko/bindings/corba/ bindings/src/main/java/org/apache/yoko/bindings/corba/interceptors/ bindings/src/main/java/org/apache/yoko/bindings/corba/types/ bindings/src/t...

Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaHelper.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaHelper.java?view=auto&rev=494510
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaHelper.java (added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaHelper.java Tue Jan  9 10:29:42 2007
@@ -0,0 +1,1359 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.yoko.tools.processors.wsdl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.Part;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.schemas.yoko.bindings.corba.CaseType;
+import org.apache.schemas.yoko.bindings.corba.Enum;
+import org.apache.schemas.yoko.bindings.corba.Enumerator;
+import org.apache.schemas.yoko.bindings.corba.MemberType;
+import org.apache.schemas.yoko.bindings.corba.Struct;
+import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
+import org.apache.schemas.yoko.bindings.corba.Union;
+import org.apache.schemas.yoko.bindings.corba.Unionbranch;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaAll;
+import org.apache.ws.commons.schema.XmlSchemaAnnotation;
+import org.apache.ws.commons.schema.XmlSchemaAttribute;
+import org.apache.ws.commons.schema.XmlSchemaChoice;
+import org.apache.ws.commons.schema.XmlSchemaComplexContent;
+import org.apache.ws.commons.schema.XmlSchemaComplexContentExtension;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet;
+import org.apache.ws.commons.schema.XmlSchemaFacet;
+import org.apache.ws.commons.schema.XmlSchemaLengthFacet;
+import org.apache.ws.commons.schema.XmlSchemaMaxLengthFacet;
+import org.apache.ws.commons.schema.XmlSchemaParticle;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaSimpleContent;
+import org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension;
+import org.apache.ws.commons.schema.XmlSchemaSimpleContentRestriction;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeList;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.yoko.tools.common.CorbaPrimitiveMap;
+import org.apache.yoko.tools.common.ReferenceConstants;
+import org.apache.yoko.tools.common.W3CConstants;
+import org.apache.yoko.wsdl.CorbaConstants;
+import org.apache.yoko.wsdl.CorbaTypeImpl;
+
+public class WSDLToCorbaHelper {
+
+    public static final String REPO_STRING = "IDL:";
+    public static final String IDL_VERSION = ":1.0";
+
+    protected static final Logger LOG = LogUtils.getL7dLogger(WSDLToCorbaHelper.class);
+    protected static final String DISCRIMINATORTYPES[] 
+        = new String[] {"long", "short", "boolean", "char"};
+    protected static final Set<String> SUPPORTEDDISTYPES = 
+        new TreeSet<String>(Arrays.asList(DISCRIMINATORTYPES)); 
+
+    protected static final CorbaPrimitiveMap CORBAPRIMITIVEMAP = new CorbaPrimitiveMap();
+
+    String idlNamespace;
+    XmlSchema xmlSchemaType;
+    List<XmlSchema> xmlSchemaList;
+    TypeMappingType typeMappingType;
+    Definition def;
+
+    public void setXMLSchema(XmlSchema schema) {
+        xmlSchemaType = schema;
+    }
+
+    public void setTypeMap(TypeMappingType map) {
+        typeMappingType = map;
+    }
+
+    public void setIdlNamespace(String ns) {
+        idlNamespace = ns;
+    }
+
+    public String getIdlNamespace() {
+        return idlNamespace;
+    }
+
+    public void setXMLSchemaList(List<XmlSchema> list) {
+        xmlSchemaList = list;
+    }
+
+    public void setWsdlDefinition(Definition defn) {
+        def = defn;
+    }
+
+    public CorbaTypeImpl convertSchemaToCorbaType(XmlSchemaType stype, 
+                                                  QName defaultName,
+                                                  XmlSchemaType parent,
+                                                  XmlSchemaAnnotation annotation, 
+                                                  boolean anonymous)
+        throws Exception {
+        CorbaTypeImpl corbaTypeImpl = null;
+        if (!isAddressingNamespace(stype.getQName())) {
+            // need to determine if its a primitive type.
+            if (stype.getBaseSchemaType() != null) {
+                corbaTypeImpl = processPrimitiveType(stype.getQName());
+            }
+
+            if (stype instanceof XmlSchemaComplexType) {
+                return corbaTypeImpl = processComplexType((XmlSchemaComplexType)stype, 
+                                                          defaultName, annotation, anonymous);
+            } else if (stype instanceof XmlSchemaSimpleType) {            
+                return corbaTypeImpl = processSimpleType((XmlSchemaSimpleType)stype, 
+                                                         defaultName, anonymous);
+            }  else if (xmlSchemaType.getElementByName(stype.getQName()) != null) {
+                XmlSchemaElement el = xmlSchemaType.getElementByName(stype.getQName());
+                return corbaTypeImpl = processElementType(el, defaultName);
+            } else {
+                throw new Exception("Couldn't convert schema " + stype.getQName() + " to corba type");
+            }
+        }
+        return corbaTypeImpl;
+    }
+
+    protected List processContainerAsMembers(XmlSchemaParticle particle,
+                                             QName defaultName,
+                                             QName schemaTypeName)
+        throws Exception {
+        List<MemberType> members = new ArrayList<MemberType>();
+
+        Iterator iterL = null;
+        if (particle instanceof XmlSchemaSequence) {
+            XmlSchemaSequence scontainer = (XmlSchemaSequence)particle;
+            iterL = scontainer.getItems().getIterator();
+        } else if (particle instanceof XmlSchemaChoice) {
+            XmlSchemaChoice scontainer = (XmlSchemaChoice)particle;
+            iterL = scontainer.getItems().getIterator();
+        } else if (particle instanceof XmlSchemaAll) {
+            XmlSchemaAll acontainer = (XmlSchemaAll)particle;
+            iterL = acontainer.getItems().getIterator();
+        }
+
+        while (iterL.hasNext()) {
+            XmlSchemaParticle container = (XmlSchemaParticle)iterL.next();
+            
+            if (container instanceof XmlSchemaSequence) {
+                XmlSchemaSequence sequence = (XmlSchemaSequence)container;
+                CorbaTypeImpl memberType = processSequenceType(sequence, defaultName, schemaTypeName);
+                QName typeName = memberType.getQName();
+                if (memberType instanceof Struct) {
+                    memberType.setQName(null);                  
+                    if (memberType != null && !isDuplicate(memberType)) {
+                        typeMappingType.getStructOrExceptionOrUnion().add(memberType);
+                    }                    
+                }
+                
+                MemberType member = new MemberType(); 
+                member.setName(memberType.getName() + "_f");
+                member.setIdltype(typeName);
+                members.add(member);
+
+            } else if (container instanceof XmlSchemaChoice) {
+                XmlSchemaChoice choice = (XmlSchemaChoice)container;
+                CorbaTypeImpl corbatype = processChoice(choice, defaultName, schemaTypeName);
+                MemberType member = new MemberType(); 
+                member.setName(corbatype.getQName().getLocalPart());
+                member.setIdltype(corbatype.getQName());
+                members.add(member);
+            } else if (container instanceof XmlSchemaAll) {
+                XmlSchemaAll all = (XmlSchemaAll)container;
+                CorbaTypeImpl corbatype = processAllType(all, defaultName, schemaTypeName);
+                MemberType member = new MemberType(); 
+                member.setName(corbatype.getQName().getLocalPart());
+                member.setIdltype(corbatype.getQName());
+                members.add(member);
+            } else if (container instanceof XmlSchemaElement) {
+                XmlSchemaElement element = (XmlSchemaElement)container;
+                CorbaTypeImpl corbatype = processLocalElement(element);
+
+                if (corbatype != null) {
+                    MemberType member;
+                    String memberName = element.getQName().getLocalPart();
+
+                    member = new MemberType();
+                    member.setName(memberName);
+                    member.setIdltype(corbatype.getQName());                    
+                    members.add(member);
+                } else {
+                    String msg = "Unsupported Element Found in CORBA Binding Generation:"
+                                 + element.getQName();
+                    LOG.log(Level.WARNING, msg.toString());
+                }
+            }
+        }
+        return members;
+    }
+    
+    private CorbaTypeImpl processChoice(XmlSchemaChoice choice,
+                                        QName defaultName, 
+                                        QName schemaTypeName)
+        throws Exception {        
+        QName choicename = null;
+
+        if (schemaTypeName == null) {
+            choicename = createQNameTargetNamespace(defaultName.getLocalPart());
+        } else {
+            choicename = createQNameTargetNamespace(schemaTypeName.getLocalPart());
+        }
+        choicename = checkPrefix(choicename);
+
+        CorbaTypeImpl corbatype = createUnion(choicename, choice, defaultName, schemaTypeName);
+        String repoId = REPO_STRING + corbatype.getQName().getLocalPart().replace('.', '/') 
+            + IDL_VERSION;
+        ((Union)corbatype).setRepositoryID(repoId);                                
+
+        if (!(choice.getMaxOccurs() == 1) || !(choice.getMinOccurs() == 1)) {
+            QName name = createQNameTargetNamespace(corbatype.getQName().getLocalPart() + "Array");
+            CorbaTypeImpl arrayType = 
+                createArray(name, corbatype.getQName(), corbatype.getQName(), 
+                    choice.getMaxOccurs(), choice.getMinOccurs(), false);
+            
+            if (arrayType != null) {
+                arrayType.setQName(null);                
+                if (!isDuplicate(arrayType)) {
+                    typeMappingType.getStructOrExceptionOrUnion().add(arrayType);
+                }
+            }
+        }
+        return corbatype;
+    }
+    
+    private CorbaTypeImpl processLocalElement(XmlSchemaElement element) throws Exception {
+        CorbaTypeImpl membertype = new CorbaTypeImpl();
+        CorbaTypeImpl memtype = new CorbaTypeImpl();
+
+        QName memName = null;
+        if (element.isNillable()) {
+
+            CorbaTypeImpl elemtype = convertSchemaToCorbaType(element.getSchemaType(), element.getQName(),
+                                                              element.getSchemaType(), null, true);
+            QName name = createQNameTargetNamespace(elemtype.getQName().getLocalPart() + "_nil");
+            QName elName = checkPrefix(element.getQName());
+            if (elName ==  null) {
+                elName = createQNameTargetNamespace(element.getQName().getLocalPart());
+            }
+            memtype = createNillableUnion(name, elName, 
+                                             elemtype.getQName());
+            memName = createQNameCorbaNamespace(memtype.getQName().getLocalPart());
+                                    
+            if (memtype != null) {                          
+                memtype.setQName(null);
+                if (!isDuplicate(memtype)) {
+                    typeMappingType.getStructOrExceptionOrUnion().add(memtype);
+                }
+            }
+            membertype.setQName(memName);
+            membertype.setName(memtype.getName());
+            membertype.setType(memtype.getType());
+            
+        } else {
+            // Need TO DO
+            // Need to check if its referencing a type first refname=""
+            //if (element.getRefName()
+            if (element.getSchemaType() != null) {
+                XmlSchemaType st = element.getSchemaType();
+                boolean anonymous = WSDLTypes.isAnonymous(st.getName());            
+                membertype = convertSchemaToCorbaType(st, element.getQName(), st, null, anonymous);
+            } else {                
+                if (element.getSchemaTypeName() != null) {
+                    QName name = checkPrefix(element.getSchemaTypeName());
+                    membertype = getLocalType(name);                    
+                }
+            }
+        }
+
+        if (!(element.getMaxOccurs() == 1) || !(element.getMinOccurs() == 1)) {
+            QName name = createQNameCorbaNamespace(getModulePrefix(membertype) 
+                                                    + element.getQName().getLocalPart() + "Array");
+            
+            // workaround for now - sent bug to WSCommons - the elements
+            // QName should have its namespace included.
+            QName schemaName = element.getQName();
+            if (schemaName.getNamespaceURI().equals("")) {
+                schemaName = new QName(xmlSchemaList.get(0).getTargetNamespace(), 
+                                       schemaName.getLocalPart());                
+            }
+            
+            CorbaTypeImpl arraytype = null;
+            if (memName != null) {
+                arraytype = createArray(name, schemaName, memName, 
+                                        element.getMaxOccurs(), element.getMinOccurs(), false);
+            } else {
+                arraytype = createArray(name, schemaName, membertype.getQName(), 
+                                        element.getMaxOccurs(), element.getMinOccurs(), false);
+            }
+                        
+            membertype.setName(arraytype.getName());
+            membertype.setQName(arraytype.getQName());
+            membertype.setType(arraytype.getType());
+                        
+            if (arraytype != null) {                
+                arraytype.setQName(null);
+                if (!isDuplicate(arraytype)) {
+                    typeMappingType.getStructOrExceptionOrUnion().add(arraytype);               
+                }                
+            }                   
+        }
+
+        return membertype;
+    }
+
+    
+    public XmlSchemaType getSchemaType(QName name) throws Exception {                
+        XmlSchemaType type = null;
+        Iterator i = xmlSchemaList.iterator();
+        while (i.hasNext()) {
+            XmlSchema xmlSchema = (XmlSchema)i.next();      
+            String nspace = xmlSchema.getTargetNamespace();
+            QName tname = createQName(nspace, name.getLocalPart(), "xsd");
+            type = findSchemaType(tname);                            
+            if (type != null) {
+                break;
+            }
+        }       
+        return type;
+    }
+          
+    private String getModulePrefix(CorbaTypeImpl type) {
+        String name = type.getQName().getLocalPart();
+        int dotPos = name.lastIndexOf(".");
+        return dotPos == -1 ? "" : name.substring(0, dotPos + 1);
+    }
+
+    
+    protected CorbaTypeImpl processSequenceType(XmlSchemaSequence seq, 
+                                                QName defaultName, QName schemaTypeName)
+        throws Exception {
+        CorbaTypeImpl type = null;
+        QName seqName = null;
+
+        if (schemaTypeName == null) {
+            seqName = createQNameTargetNamespace(defaultName.getLocalPart() + "SequenceStruct");        
+        } else {        
+            seqName = createQName(schemaTypeName.getNamespaceURI(),
+                                  schemaTypeName.getLocalPart() + "SequenceStruct", 
+                                  schemaTypeName.getPrefix());
+        }
+        
+        schemaTypeName = checkPrefix(schemaTypeName);
+        Struct struct = new Struct();       
+        struct.setName(seqName.getLocalPart());
+        struct.setQName(seqName);
+        struct.setRepositoryID(REPO_STRING + seqName.getLocalPart().replace('.', '/') + IDL_VERSION);
+        struct.setType(schemaTypeName);
+        
+        List members = processContainerAsMembers(seq, defaultName, schemaTypeName);
+        for (Iterator iterator = members.iterator(); iterator.hasNext();) {
+            MemberType memberType = (MemberType)iterator.next();
+            struct.getMember().add(memberType);            
+        }        
+        
+        type = struct;
+                              
+        if (!"1".equals(seq.getMaxOccurs()) || !"1".equals(seq.getMinOccurs())) {
+            QName name = createQNameTargetNamespace(type.getQName().getLocalPart() + "Array");            
+            CorbaTypeImpl atype = createArray(name, type.getQName(), type.getQName(),
+                                           seq.getMaxOccurs(), seq.getMinOccurs(), false);
+            
+            if (atype != null) {
+                atype.setQName(null);               
+                if (!isDuplicate(atype)) {
+                    typeMappingType.getStructOrExceptionOrUnion().add(atype);               
+                }
+            }
+        }
+        
+        if ((type instanceof Struct) && (struct.getMember().size() == 0)) {
+            String msgStr = "Cannot create CORBA Struct" + struct.getName()
+                            + "from container with no members";
+            org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(
+                                      msgStr, LOG);
+            throw new Exception(msg.toString());
+        }        
+                
+        return type;
+    }
+    
+    
+    protected CorbaTypeImpl processAllType(XmlSchemaAll seq, QName defaultName, 
+                                           QName schematypeName) throws Exception {
+        QName allName = null;
+        Struct type = null;
+
+        if (schematypeName == null) {
+            allName = createQNameCorbaNamespace(defaultName.getLocalPart() + "AllStruct");
+        } else {
+            allName = createQNameCorbaNamespace(schematypeName.getLocalPart() + "AllStruct");
+        }
+
+        type = new Struct();
+        type.setName(allName.getLocalPart());
+        type.setQName(allName);
+        type.setType(schematypeName);
+        
+        List members = processContainerAsMembers(seq, defaultName, schematypeName);
+        for (Iterator iterator = members.iterator(); iterator.hasNext();) {
+            MemberType memberType = (MemberType)iterator.next();
+            type.getMember().add(memberType);
+        }
+                
+        String repoId = REPO_STRING + type.getQName().getLocalPart().replace('.', '/') + IDL_VERSION;
+        type.setRepositoryID(repoId);
+        return type;
+    }
+    
+    private CorbaTypeImpl processPrimitiveType(QName typeName) {
+        QName qName = createQNameXmlSchemaNamespace(typeName.getLocalPart());        
+        CorbaTypeImpl corbatype = (CorbaTypeImpl)CORBAPRIMITIVEMAP.get(qName);
+        if (corbatype == null) {
+            if (typeName.equals(W3CConstants.NT_SCHEMA_DECIMAL)) {
+                QName name = new QName(idlNamespace, "fixed_1");
+                corbatype = WSDLTypes.getFixedCorbaType(name, typeName, 31, 6);
+            } else if (typeName.equals(W3CConstants.NT_SCHEMA_BASE64)
+                       || typeName.equals(W3CConstants.NT_SCHEMA_HBIN)) {
+                       //|| typeName.equals(SOAPConstants.NT_SOAP_BASE64)
+                       //|| typeName.equals(SOAPConstants.NT_SOAP_HBIN)) {
+                QName name = new QName(idlNamespace, typeName.getLocalPart() + "Seq");
+                corbatype = WSDLTypes.getOctetCorbaType(name, typeName, 0);
+            }
+
+        }
+        return corbatype;
+    }
+
+    protected List<MemberType> processAttributesAsMembers(Iterator attrs) throws Exception {
+        QName memName = null;
+        List <MemberType>members = new ArrayList<MemberType>();
+
+        while (attrs.hasNext()) {
+            XmlSchemaAttribute attribute = (XmlSchemaAttribute)attrs.next();
+            CorbaTypeImpl membertype = null;
+
+            if (attribute.getUse().getValue().equals("none")
+                || attribute.getUse().getValue().equals(W3CConstants.USE_OPTIONAL)) {                
+                CorbaTypeImpl attType = null;
+                if (attribute.getSchemaType() != null) {                    
+                    attType = convertSchemaToCorbaType(attribute.getSchemaType(), 
+                                                       attribute.getQName(), 
+                                              attribute.getSchemaType(), null, true);                   
+                    if (attType != null) {
+                        QName typeName = attType.getQName();
+                        attType.setQName(null);           
+                        if (!isDuplicate(attType)) {
+                            typeMappingType.getStructOrExceptionOrUnion().add(attType);
+                        }
+                        QName name =  createQNameTargetNamespace(typeName.getLocalPart() + "_nil");
+                        membertype = createNillableUnion(name, attribute.getQName(), 
+                                     createQNameCorbaNamespace(typeName.getLocalPart()));
+                    }
+                } else {
+                    attType = processPrimitiveType(attribute.getSchemaTypeName());
+                    //REVISIT, bravi, attType is null for the wsaddr type
+                    //{http://www.w3.org/2005/08/addressing}RelationshipTypeOpenEnum
+                    if (attType != null) {
+                        QName name =  createQNameTargetNamespace(attType.getQName().getLocalPart() + "_nil");
+                        membertype = createNillableUnion(name, attribute.getQName(), 
+                                                         attType.getQName());
+                    }
+
+                }
+                if (membertype != null) {
+                    memName = createQNameCorbaNamespace(membertype.getQName().getLocalPart());
+                    membertype.setQName(null);           
+                    if (!isDuplicate(membertype)) {
+                        typeMappingType.getStructOrExceptionOrUnion().add(membertype);
+                    }
+                }
+            } else {
+                if (attribute.getSchemaType() != null) {
+                    membertype = convertSchemaToCorbaType(attribute.getSchemaType(), attribute.getQName(), 
+                                                      attribute.getSchemaType(), null, false);
+                } else {
+                    membertype = processPrimitiveType(attribute.getSchemaTypeName());
+                }
+            }
+
+            if (membertype != null) {
+                MemberType member;
+                String memberName = attribute.getQName().getLocalPart();
+
+                member = new MemberType();
+                member.setName(memberName);
+                if (memName != null) {
+                    member.setIdltype(memName);
+                } else {
+                    member.setIdltype(membertype.getQName());
+                }
+                members.add(member);
+            } else {
+                String msg = "Unsupported Attribute Found in CORBA Binding Generation:" 
+                    + attribute.getQName();
+                LOG.log(Level.WARNING, msg.toString());            
+            }
+        }
+
+        return members;
+    }
+
+    
+    private CorbaTypeImpl processElementType(XmlSchemaElement stype, QName defaultName) 
+        throws Exception {
+
+        QName schematypeName;
+
+        if (stype.getName() == null) {
+            schematypeName = defaultName;
+        } else {
+            schematypeName = createQNameTargetNamespace(stype.getName());
+        }
+
+        return convertSchemaToCorbaType(stype.getSchemaType(), schematypeName, 
+                                        stype.getSchemaType(), null, false);
+
+    }
+
+    private CorbaTypeImpl processSimpleType(XmlSchemaSimpleType stype, QName defaultName, 
+                                            boolean anonymous)
+        throws Exception {
+
+        CorbaTypeImpl corbaTypeImpl = null;
+        QName name;
+        QName schematypeName = null; 
+        
+        if (stype.getQName() == null) {
+            schematypeName = defaultName;
+            name = createQNameTargetNamespace(defaultName.getLocalPart() + "Type");
+        } else {
+            schematypeName = checkPrefix(stype.getQName());
+            if (schematypeName == null) {
+                schematypeName = stype.getQName();
+            }
+            name = createQNameCorbaNamespace(schematypeName.getLocalPart());
+        }        
+        
+        if (stype.getContent() instanceof XmlSchemaSimpleTypeRestriction) {
+            corbaTypeImpl = processSimpleRestrictionType(stype, name, schematypeName, anonymous);
+        } else if (stype.getContent() instanceof XmlSchemaSimpleTypeList) {
+            XmlSchemaSimpleTypeList ltype = (XmlSchemaSimpleTypeList)stype.getContent();
+            CorbaTypeImpl itemType = null;
+            if (ltype.getItemType() != null) {
+                itemType = convertSchemaToCorbaType(ltype.getItemType(), name, stype, null, false);
+                if (itemType != null) {
+                    return WSDLTypes.mapToSequence(name, checkPrefix(schematypeName), 
+                                                   itemType.getQName(), 0, false);
+                }
+                return itemType;
+            }
+            QName ltypeName = createQNameXmlSchemaNamespace(ltype.getItemTypeName().getLocalPart());
+            itemType = processPrimitiveType(ltypeName);
+            return WSDLTypes.mapToSequence(name, checkPrefix(schematypeName), itemType.getQName(), 0, false);
+        } else if (stype.getContent() == null) {
+            // elements primitive type
+            QName stypeName = createQNameXmlSchemaNamespace(stype.getName());
+            corbaTypeImpl = getLocalType(stypeName);            
+        } else {
+            System.out.println("SimpleType Union Not Supported in CORBA Binding");
+        }
+        return corbaTypeImpl;
+ 
+    }
+    
+    private CorbaTypeImpl processSimpleRestrictionType(XmlSchemaSimpleType stype,
+                                                       QName name, QName schematypeName,
+                                                       boolean anonymous) 
+        throws Exception {
+        CorbaTypeImpl corbaTypeImpl = null;
+    
+        // checks if enumeration
+        XmlSchemaSimpleTypeRestriction restrictionType = (XmlSchemaSimpleTypeRestriction)stype
+            .getContent();
+        
+        QName baseName = checkPrefix(restrictionType.getBaseTypeName());
+        
+        String maxLength = null;
+        String length = null;
+
+        Iterator i = restrictionType.getFacets().getIterator();
+        while (i.hasNext()) {
+            XmlSchemaFacet val = (XmlSchemaFacet)i.next();
+            if (val instanceof XmlSchemaMaxLengthFacet) {                
+                maxLength = val.getValue().toString();
+            }
+            if (val instanceof XmlSchemaLengthFacet) {
+                length = val.getValue().toString();
+            }
+        }
+        
+        if (isEnumeration(restrictionType)) {
+            corbaTypeImpl = createCorbaEnum(restrictionType, name, schematypeName);
+        } else {
+            if (restrictionType.getBaseType() != null) {
+                corbaTypeImpl = convertSchemaToCorbaType(restrictionType.getBaseType(), schematypeName,
+                                                         stype, null, false);
+            } else {                
+                corbaTypeImpl = processPrimitiveType(baseName);                
+                if (corbaTypeImpl == null) {
+                    XmlSchemaType schematype = findSchemaType(baseName);
+                    corbaTypeImpl = convertSchemaToCorbaType(schematype, schematypeName,
+                                                             schematype, null, false); 
+                }
+            }
+
+            if (corbaTypeImpl != null) {
+                if (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_STRING)
+                    || (baseName.equals(W3CConstants.NT_SCHEMA_STRING))) {                
+                    corbaTypeImpl = 
+                        WSDLTypes.processStringType(corbaTypeImpl, name, maxLength, length);                
+                } else if (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_DECIMAL)
+                    || (baseName.equals(W3CConstants.NT_SCHEMA_DECIMAL))) {                
+                    corbaTypeImpl = WSDLTypes.processDecimalType(restrictionType, name, 
+                                                             corbaTypeImpl, anonymous);
+                } else if ((corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_BASE64))
+                    || (baseName.equals(W3CConstants.NT_SCHEMA_BASE64))
+                    || (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_HBIN))
+                    || (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_HBIN))) {                
+                    corbaTypeImpl = WSDLTypes.processBase64Type(corbaTypeImpl, 
+                                                                name, maxLength, length);          
+                }            
+            }
+        }
+        
+        return corbaTypeImpl;
+    }               
+ 
+    private CorbaTypeImpl getLocalType(QName qname) {
+        return processPrimitiveType(qname);
+    }
+
+    private Enum createCorbaEnum(XmlSchemaSimpleTypeRestriction restrictionType, QName name,
+                                 QName schematypeName) {
+        Enum corbaEnum = new Enum();
+        corbaEnum.setType(schematypeName);
+        corbaEnum.setName(name.getLocalPart());
+        corbaEnum.setQName(name);
+
+        corbaEnum.setRepositoryID(REPO_STRING + name.getLocalPart().replace('.', '/') + IDL_VERSION);
+        Iterator enums = restrictionType.getFacets().getIterator();
+
+        while (enums.hasNext()) {
+            XmlSchemaEnumerationFacet val = (XmlSchemaEnumerationFacet)enums.next();
+            Enumerator enumerator = new Enumerator();
+            enumerator.setValue(val.getValue().toString());
+            corbaEnum.getEnumerator().add(enumerator);
+        }
+        return corbaEnum;
+    }
+
+    private boolean isEnumeration(XmlSchemaSimpleTypeRestriction restriction) {
+
+        if ((restriction == null) || (restriction.getFacets().getCount() == 0)
+            || (restriction.getBaseTypeName() == null)) {
+            return false;
+        }
+
+        Iterator it = restriction.getFacets().getIterator();
+        while (it.hasNext()) {
+            XmlSchemaFacet facet = (XmlSchemaFacet)it.next();
+            if (facet instanceof XmlSchemaEnumerationFacet) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    
+    protected XmlSchemaType lookUpType(Part part) {
+        XmlSchemaType schemaType = null;
+        
+        Iterator i = xmlSchemaList.iterator();
+        while (i.hasNext()) {
+            XmlSchema xmlSchema = (XmlSchema)i.next();
+        
+            if (part.getElementName() != null) {
+                XmlSchemaElement schemaElement = xmlSchema.getElementByName(part.getElementName());
+                if (schemaElement != null) {
+                    schemaType = schemaElement.getSchemaType();
+                }
+            } else {
+                if (part.getTypeName() != null) {
+                    schemaType = xmlSchema.getTypeByName(part.getTypeName());
+                }
+            }
+            if (schemaType != null) {
+                return schemaType;
+            }
+        }
+            
+        return schemaType;
+    }
+    
+    private XmlSchemaType findSchemaType(QName typeName) {
+        XmlSchemaType schemaType = null;
+        
+        Iterator i = xmlSchemaList.iterator();
+        while (i.hasNext()) {
+            XmlSchema xmlSchema = (XmlSchema)i.next();        
+            if (xmlSchema.getElementByName(typeName) != null) {
+                XmlSchemaElement schemaElement = xmlSchema.getElementByName(typeName);                
+                schemaType = schemaElement.getSchemaType();                
+            } else if (xmlSchema.getTypeByName(typeName) != null) {                
+                schemaType = xmlSchema.getTypeByName(typeName);                
+            }
+            if (schemaType != null) {
+                return schemaType;
+            } 
+        }            
+        return schemaType;
+    }
+    
+    protected boolean isSchemaTypeException(XmlSchemaType stype) {
+        boolean exception = false;
+        XmlSchemaComplexType complex = null;
+
+        if (stype instanceof XmlSchemaComplexType) {           
+            complex = (XmlSchemaComplexType)stype;
+
+            if (!isLiteralArray(complex)   
+                && !WSDLTypes.isOMGUnion(complex) 
+                && !WSDLTypes.isUnion(complex)) {
+                exception = true;
+            }
+        }         
+        return exception;
+    }
+
+    
+    public boolean isLiteralArray(XmlSchemaComplexType type) {
+        boolean array = false;
+
+        if ((type.getAttributes().getCount() == 0) 
+            && (type.getParticle() instanceof XmlSchemaSequence)) {
+            XmlSchemaSequence stype = (XmlSchemaSequence)type.getParticle();
+                    
+            if ((stype.getItems().getCount() == 1)
+                && (stype.getItems().getIterator().next() instanceof XmlSchemaElement)) {
+                XmlSchemaElement el = (XmlSchemaElement)stype.getItems().getIterator().next();
+                if (!(el.getMaxOccurs() == 1)) {
+                    // it's a literal array
+                    array = true;
+                }                
+                if (el.getMaxOccurs() == 1 && el.getMinOccurs() == 1) {
+                    if (type.getName() != null &&  WSDLTypes.isAnonymous(type.getName())) {                
+                        array = true;
+                    }
+                }
+            }
+        }
+        return array;
+    }
+    
+    /**
+     * Create a CORBA Array or Sequence based on min and max Occurs If minOccurs ==
+     * maxOccurs == 1 then log warning and return null. Else if minOccurs is
+     * equal to maxOccurs then create an Array. Else create a Sequence
+     */
+    protected CorbaTypeImpl createArray(QName name, QName schematypeName, QName arrayType,
+                                        Long maxOccurs, Long minOccurs, boolean anonymous) {
+        
+        int max = maxOccurs.intValue();
+        if (max == -1) {
+            return WSDLTypes.mapToSequence(name, schematypeName, arrayType, 0, anonymous);
+        }
+        
+        int min = minOccurs.intValue();        
+        
+        if (min == max) {
+            if (max == 1) {
+                if (!anonymous) {
+                    String msg = "Couldn't Map to Array:" + name + ":minOccurs=" 
+                        + minOccurs + ":maxOccurs=" + maxOccurs;
+                    LOG.log(Level.WARNING, msg.toString());
+                    return null;
+                } else {
+                    return WSDLTypes.mapToArray(name, checkPrefix(schematypeName), arrayType, max, anonymous);
+                }
+            } else {
+                return WSDLTypes.mapToArray(name, checkPrefix(schematypeName), arrayType, max, anonymous);
+            }
+        } else {
+            return WSDLTypes.mapToSequence(name, checkPrefix(schematypeName), arrayType, max, anonymous);
+        }
+    }
+
+    
+    private CorbaTypeImpl processComplexType(XmlSchemaComplexType complex, QName defaultName, 
+                                             XmlSchemaAnnotation annotation, 
+                                             boolean anonymous) throws Exception {
+        CorbaTypeImpl corbatype = null;
+        if (isLiteralArray(complex)) {
+            corbatype = processLiteralArray(complex, defaultName, anonymous);
+        } else if (WSDLTypes.isOMGUnion(complex)) {
+            corbatype = processOMGUnion(complex, defaultName);
+        } else if (WSDLTypes.isUnion(complex)) {
+            corbatype = processRegularUnion(complex, defaultName);                                           
+        } else if (complex.getQName() != null && isIDLObjectType(complex.getQName())) {
+            // process it.
+            corbatype = WSDLTypes.processObject(def, complex, annotation, checkPrefix(complex.getQName()), 
+                                                defaultName, idlNamespace);
+        } else {
+            // Deal the ComplexType as Struct
+            corbatype = processStruct(complex, defaultName);
+        }
+        return corbatype;
+    }
+    
+        
+    private CorbaTypeImpl processStruct(XmlSchemaComplexType complex, QName defaultName)
+        throws Exception {
+        QName name;
+        Struct corbaStruct = null;
+        
+        QName schematypeName = checkPrefix(complex.getQName());               
+        if (schematypeName == null) {
+            schematypeName = checkPrefix(defaultName);
+            name = checkPrefix(createQNameCorbaNamespace(defaultName.getLocalPart()));            
+        } else {
+            name = checkPrefix(createQNameCorbaNamespace(schematypeName.getLocalPart()));            
+        }
+
+        corbaStruct = new Struct();
+        corbaStruct.setName(name.getLocalPart());
+        corbaStruct.setQName(name);
+        String repoId = REPO_STRING + name.getLocalPart().replace('.', '/') + IDL_VERSION;
+        corbaStruct.setRepositoryID(repoId);
+        corbaStruct.setType(schematypeName);
+          
+        if (complex.getContentModel() instanceof XmlSchemaSimpleContent) {
+            corbaStruct = processSimpleContentStruct((XmlSchemaSimpleContent)complex.getContentModel(), 
+                                                     defaultName, corbaStruct, schematypeName);
+        } else if (complex.getContentModel() instanceof XmlSchemaComplexContent) {
+            corbaStruct = processComplexContentStruct((XmlSchemaComplexContent)complex.getContentModel(), 
+                                                      defaultName, corbaStruct, schematypeName);        
+        } 
+        
+        // Process attributes at ComplexType level
+        if (complex.getAttributes().getIterator() != null) {
+            Iterator iterator = complex.getAttributes().getIterator();
+            List attlist2 = processAttributesAsMembers(iterator);
+            MemberType member = new MemberType();
+            for (int i = 0; i < attlist2.size(); i++) {
+                member = (MemberType)attlist2.get(i);
+                corbaStruct.getMember().add(member);
+            }
+        }
+
+        if (complex.getParticle() != null) {
+            List members = processContainerAsMembers(complex.getParticle(), defaultName, schematypeName);
+
+            for (Iterator it = members.iterator(); it.hasNext();) {
+                MemberType memberType = (MemberType)it.next();
+                corbaStruct.getMember().add(memberType);
+            }
+        }
+
+        return corbaStruct;
+    }
+        
+    protected Struct processSimpleContentStruct(XmlSchemaSimpleContent simpleContent, 
+                                                QName defaultName, Struct corbaStruct, QName schematypeName)
+        throws Exception {        
+        XmlSchemaType base = null;        
+        List attrMembers = null;
+        CorbaTypeImpl basetype = null;
+
+        if (simpleContent.getContent() instanceof XmlSchemaSimpleContentExtension) {        
+            XmlSchemaSimpleContentExtension ext = 
+                (XmlSchemaSimpleContentExtension)simpleContent.getContent();
+                        
+            if (ext.getBaseTypeName() != null) {
+                basetype = processPrimitiveType(ext.getBaseTypeName());
+            }
+            
+            // process  ext types ????                      
+            MemberType basemember = new MemberType();
+            basemember.setName("_simpleTypeValue");
+            basemember.setIdltype(basetype.getType());
+            corbaStruct.getMember().add(basemember);
+            attrMembers = processAttributesAsMembers(ext.getAttributes().getIterator());
+        } else if (simpleContent.getContent() instanceof XmlSchemaSimpleContentRestriction) {
+            XmlSchemaSimpleContentRestriction restrict 
+                = (XmlSchemaSimpleContentRestriction)simpleContent.getContent();
+            basetype = convertSchemaToCorbaType(base, base.getQName(), base, null, false);
+            base = restrict.getBaseType();
+            basetype = convertSchemaToCorbaType(base, base.getQName(), base, null, false);
+            MemberType basemember = new MemberType();
+            basemember.setName("_simpleTypeValue");
+            basemember.setIdltype(basetype.getType());
+            corbaStruct.getMember().add(basemember);
+            attrMembers = processAttributesAsMembers(restrict.getAttributes().getIterator());
+        }
+
+        //Deal with Attributes defined in Extension
+        MemberType member = new MemberType();
+        for (int i = 0; i < attrMembers.size(); i++) {
+            member = (MemberType)attrMembers.get(i);
+            corbaStruct.getMember().add(member);
+        }
+
+        //Process attributes at ComplexType level
+        //List attlist2 = processAttributesAsMembers(simpleContent.unhandledAttributes.);
+        //corbaStruct.getMembers().addAll(attlist2);      
+
+        return corbaStruct;
+    }
+    
+    protected Struct processComplexContentStruct(XmlSchemaComplexContent complex, QName defaultName,
+                                                 Struct corbaStruct, QName schematypeName)
+        throws Exception {        
+
+        if (complex.getContent() instanceof XmlSchemaComplexContentExtension) {
+            XmlSchemaComplexContentExtension extype 
+                = (XmlSchemaComplexContentExtension)complex.getContent();
+            
+            // Add base as a member of this struct
+            MemberType memberType = new MemberType();     
+            QName extName = extype.getBaseTypeName();
+            memberType.setName(extName.getLocalPart() + "_f");
+            if (extName.getLocalPart().equals("anyType")) {
+                memberType.setIdltype(processPrimitiveType(extName).getQName());                
+            } else {
+                memberType.setIdltype(createQNameCorbaNamespace(extName.getLocalPart()));
+            }            
+            corbaStruct.getMember().add(memberType);
+            
+            // process attributes at complexContent level
+            List attlist1 = processAttributesAsMembers(extype.getAttributes().getIterator());
+            MemberType member = new MemberType();
+            for (int i = 0; i < attlist1.size(); i++) {
+                member = (MemberType)attlist1.get(i);
+                corbaStruct.getMember().add(member);
+            }
+            
+            // Process members of Current Type
+            if (extype.getParticle() instanceof XmlSchemaChoice) {
+                XmlSchemaChoice choice = (XmlSchemaChoice)extype.getParticle();
+                MemberType choicemem = processComplexContentStructChoice(choice, schematypeName, defaultName);
+                corbaStruct.getMember().add(choicemem);                                
+            } else if (extype.getParticle() instanceof  XmlSchemaSequence) {
+                XmlSchemaSequence seq = (XmlSchemaSequence)extype.getParticle();
+                CorbaTypeImpl seqtype = 
+                    processSequenceType(seq, defaultName, schematypeName);                               
+
+                if (seqtype != null) {                    
+                    MemberType seqmem = new MemberType();
+                    seqmem.setName(seqtype.getQName().getLocalPart() + "_f");
+                    QName type = createQNameCorbaNamespace(seqtype.getQName().getLocalPart());
+                    seqmem.setIdltype(type);
+                    corbaStruct.getMember().add(seqmem);
+                    if (!isDuplicate(seqtype)) {
+                        seqtype.setQName(null);
+                        typeMappingType.getStructOrExceptionOrUnion().add(seqtype);
+                    }
+                } else {                    
+                    LOG.log(Level.WARNING, "Couldnt map Sequence inside extension");
+                }
+
+            } else if (extype.getParticle() instanceof  XmlSchemaAll) {
+                XmlSchemaAll all = (XmlSchemaAll)extype.getParticle();
+                
+                CorbaTypeImpl alltype = processAllType(all, defaultName, schematypeName);
+                if (alltype != null) {
+                    MemberType allmem = new MemberType();
+                    allmem.setName(alltype.getQName().getLocalPart() + "_f");
+                    allmem.setIdltype(alltype.getQName());
+                    corbaStruct.getMember().add(allmem);
+                    if (!isDuplicate(alltype)) {
+                        alltype.setQName(null);
+                        typeMappingType.getStructOrExceptionOrUnion().add(alltype);
+                    }
+                } else {
+                    LOG.log(Level.WARNING, "Couldnt map All inside extension");
+                }
+            }
+            
+        } else {
+            org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(
+                               "Restriction inside ComplexContent is not yet Supported.", LOG);
+            //throw new Exception(msg.toString());            
+            return null;
+        }
+
+        return corbaStruct;
+    }
+    
+    protected MemberType processComplexContentStructChoice(XmlSchemaChoice choice, 
+                                                     QName schematypeName, QName defaultName) 
+        throws Exception {
+        QName choicename = createQNameTargetNamespace(schematypeName.getLocalPart() + "ChoiceType");
+        Union choiceunion = createUnion(choicename, choice,
+                                        defaultName, schematypeName);
+
+        String repoId = REPO_STRING + choiceunion.getQName().getLocalPart().replace('.', '/')
+            + IDL_VERSION;
+        choiceunion.setRepositoryID(repoId);                                
+        
+        MemberType choicemem = new MemberType();
+        choicemem.setName(choiceunion.getQName().getLocalPart() + "_f");
+        choicemem.setIdltype(createQNameCorbaNamespace(choiceunion.getQName().getLocalPart()));          
+        
+        if ((choiceunion != null) && (!isDuplicate(choiceunion))) {
+            choiceunion.setQName(null);
+            typeMappingType.getStructOrExceptionOrUnion().add(choiceunion);
+        }
+        
+        return choicemem;
+    }                    
+    
+    protected CorbaTypeImpl createNillableUnion(QName name, QName schemaType, QName membertype) {        
+        
+        Union nilUnion = new Union();
+        nilUnion.setName(name.getLocalPart());
+        nilUnion.setType(schemaType);
+        nilUnion.setQName(name);
+        nilUnion.setDiscriminator(CorbaConstants.NT_CORBA_BOOLEAN);
+        String id = REPO_STRING + nilUnion.getQName().getLocalPart().replace('.', '/') + IDL_VERSION;
+        nilUnion.setRepositoryID(id);
+
+        Unionbranch branch = new Unionbranch();
+        branch.setName("value");
+        branch.setIdltype(membertype);
+        branch.setDefault(false);
+        CaseType caseType = new CaseType();
+        caseType.setLabel("TRUE");
+        branch.getCase().add(caseType);
+        nilUnion.getUnionbranch().add(branch);       
+        
+        return nilUnion;
+    }
+    
+    private CorbaTypeImpl processLiteralArray(XmlSchemaComplexType complex, QName defaultName, 
+                                              boolean anonymous) throws Exception {
+        // NEED TO DO    
+        QName name;
+        QName typeName = null;
+        QName schematypeName = checkPrefix(complex.getQName());
+
+        if (schematypeName == null) {
+            schematypeName = defaultName;
+            name = createQNameCorbaNamespace(defaultName.getLocalPart() + "Type");
+            schematypeName = checkPrefix(schematypeName);
+            name = checkPrefix(name);
+        } else {
+            name = createQNameCorbaNamespace(schematypeName.getLocalPart());
+            name = checkPrefix(name);
+        }
+
+        CorbaTypeImpl arrayType = null;
+        XmlSchemaElement arrayEl = null;
+        if (complex.getParticle() instanceof XmlSchemaSequence) {
+            XmlSchemaSequence seq = (XmlSchemaSequence)complex.getParticle();
+            
+            Iterator iterator = seq.getItems().getIterator();
+            Iterator iter = seq.getItems().getIterator();
+            while (iterator.hasNext()) {
+                if (iter.next() instanceof XmlSchemaElement) {
+                    arrayEl = (XmlSchemaElement)iterator.next();
+                    XmlSchemaType atype = arrayEl.getSchemaType();
+                    if (atype == null) {
+                        atype = getSchemaType(arrayEl.getSchemaTypeName());
+                    }
+                    arrayType = convertSchemaToCorbaType(atype, arrayEl.getQName(), 
+                                                         atype, null, true);
+                    typeName = arrayType.getQName();
+                }
+            }
+        }
+
+        
+        if (arrayEl.isNillable()) {
+            QName nilunionname = createQNameTargetNamespace(arrayType.getQName().getLocalPart() + "_nil");
+            arrayType = createNillableUnion(nilunionname, arrayEl.getQName(), 
+                            arrayType.getQName());
+            typeName = createQNameCorbaNamespace(arrayType.getQName().getLocalPart());
+            if (arrayType != null) {
+                arrayType.setQName(null);           
+                if (!isDuplicate(arrayType)) {
+                    typeMappingType.getStructOrExceptionOrUnion().add(arrayType);
+                }
+            }
+        }
+        
+        Long maxOccurs = null;
+        Long minOccurs = null;
+        if (arrayEl != null) {
+            maxOccurs = arrayEl.getMaxOccurs();
+            minOccurs = arrayEl.getMinOccurs();
+        }
+        
+        return createArray(name, schematypeName, 
+                           checkPrefix(typeName), maxOccurs, minOccurs, anonymous);     
+    }
+    
+    private CorbaTypeImpl processOMGUnion(XmlSchemaComplexType complex, QName defaultName) throws Exception {
+        QName name;
+        Union corbaUnion = null;
+        QName schematypeName = checkPrefix(complex.getQName());                
+
+        if (schematypeName == null) {
+            schematypeName = defaultName;
+            name = createQNameTargetNamespace(defaultName.getLocalPart() + "Type");
+        } else {
+            name = createQNameTargetNamespace(schematypeName.getLocalPart());
+        }
+
+        corbaUnion = new Union();
+        corbaUnion.setName(name.getLocalPart());
+        corbaUnion.setQName(name);
+        String id = REPO_STRING + name.getLocalPart().replace('.', '/') + IDL_VERSION;
+        corbaUnion.setRepositoryID(id);
+        corbaUnion.setType(schematypeName);
+
+        XmlSchemaSequence stype = (XmlSchemaSequence)complex.getParticle();
+        Iterator it = stype.getItems().getIterator();
+        XmlSchemaParticle st1 = (XmlSchemaParticle)it.next();
+        XmlSchemaParticle st2 = (XmlSchemaParticle)it.next();
+        XmlSchemaElement discEl = null;
+        XmlSchemaChoice choice = null;
+
+        if (st1 instanceof XmlSchemaElement) {
+            discEl = (XmlSchemaElement)st1;
+            choice = (XmlSchemaChoice)st2;
+        } else {
+            discEl = (XmlSchemaElement)st2;
+            choice = (XmlSchemaChoice)st1;
+        }
+
+        CorbaTypeImpl disctype = convertSchemaToCorbaType(discEl.getSchemaType(), discEl.getQName(), discEl
+            .getSchemaType(), null, false);
+        corbaUnion.setDiscriminator(disctype.getQName());
+
+        List fields = processContainerAsMembers(choice, defaultName, schematypeName);
+
+        List<String> caselist = new ArrayList<String>();
+
+        if (disctype instanceof Enum) {
+            Enum corbaenum = (Enum)disctype;
+            Iterator iterator = corbaenum.getEnumerator().iterator();
+
+            while (iterator.hasNext()) {
+                Enumerator enumerator = (Enumerator)iterator.next();
+                caselist.add(enumerator.getValue());
+            }
+        } else if (SUPPORTEDDISTYPES.contains(disctype.getQName().getLocalPart())) {
+            if (disctype.getQName().getLocalPart().equals("long")
+                || disctype.getQName().getLocalPart().equals("short")) {
+                for (int i = 0; i < fields.size(); i++) {
+                    caselist.add(Integer.toString(i));
+                }
+            } else if (disctype.getQName().getLocalPart().equals("char")) {
+                for (int i = 0; i < fields.size(); i++) {
+                    caselist.add(Integer.toString(i));
+                }
+            } else if (disctype.getQName().getLocalPart().equals("char")) {
+                for (int i = 0; i < fields.size(); i++) {
+                    caselist.add(Integer.toString(i));
+                }
+            } else if (disctype.getQName().getLocalPart().equals("boolean")) {
+                if (fields.size() == 2) {
+                    caselist.add("TRUE");
+                    caselist.add("FALSE");
+                } else if (fields.size() == 1) {
+                    caselist.add("TRUE");
+                } else {
+                    String msg = "Discriminator Type doesnt match number of Choices in Union:" + name;
+                    LOG.log(Level.WARNING, msg.toString());
+                }
+            }
+        }
+
+        WSDLTypes.processUnionBranches(corbaUnion, fields, caselist);
+
+        return corbaUnion;
+    }           
+
+    
+    private CorbaTypeImpl processRegularUnion(XmlSchemaComplexType complex, 
+                                              QName defaultName) throws Exception {
+        //NEED TO DO
+        QName name = null;
+        QName schematypeName = complex.getQName();
+        
+        if (schematypeName == null) {
+            schematypeName = defaultName;
+            name = createQNameTargetNamespace(defaultName.getLocalPart() + "Type");
+        } else {
+            name = createQNameTargetNamespace(schematypeName.getLocalPart());
+        }
+
+        return createUnion(name, (XmlSchemaChoice)complex.getParticle(), defaultName, schematypeName);        
+    }
+    
+    protected Union createUnion(QName name, XmlSchemaChoice choice, QName defaultName,
+                                QName schematypeName)
+        throws Exception {
+        Union corbaUnion = new Union();
+        corbaUnion.setName(name.getLocalPart());
+        corbaUnion.setQName(name);        
+        corbaUnion.setType(schematypeName);
+        String id = REPO_STRING + name.getLocalPart().replace('.', '/') + IDL_VERSION;
+        corbaUnion.setRepositoryID(id); 
+
+        //Set Integer as Discriminator
+        corbaUnion.setDiscriminator(CorbaConstants.NT_CORBA_LONG);
+
+        List fields = processContainerAsMembers(choice, defaultName, schematypeName);
+
+        //Choose an Integer as a Discriminator
+        List<String> caselist = new ArrayList<String>();        
+
+        for (int i = 0; i < fields.size(); i++) {
+            caselist.add(Integer.toString(i));
+        }
+
+        return WSDLTypes.processUnionBranches(corbaUnion, fields, caselist);
+    }
+                       
+    protected boolean isDuplicate(CorbaTypeImpl corbaTypeImpl) {        
+        String corbaName = corbaTypeImpl.getName();
+        QName corbaType = corbaTypeImpl.getType();
+        
+        QName primName = createQNameXmlSchemaNamespace(corbaName);
+        if ((CorbaTypeImpl)CORBAPRIMITIVEMAP.get(primName) != null) {              
+            return true;
+        }        
+        if (!typeMappingType.getStructOrExceptionOrUnion().isEmpty()) {
+            Iterator i = typeMappingType.getStructOrExceptionOrUnion().iterator();
+            while (i.hasNext()) {
+                CorbaTypeImpl type = (CorbaTypeImpl)i.next();
+                if ((corbaName != null) && type.getType() != null && corbaType != null
+                    && (corbaName.equals(type.getName()))
+                    && (corbaType.getLocalPart().equals(type.getType().getLocalPart()))
+                    && (corbaTypeImpl.getClass().getName().equals(type.getClass().getName()))) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+    
+    
+    protected CorbaTypeImpl isDuplicateException(CorbaTypeImpl corbaTypeImpl) {
+        CorbaTypeImpl duplicate = null;
+        String corbaName = corbaTypeImpl.getName();
+        String corbaType = corbaTypeImpl.getType().getLocalPart();
+        if (!typeMappingType.getStructOrExceptionOrUnion().isEmpty()) {
+            Iterator i = typeMappingType.getStructOrExceptionOrUnion().iterator();
+            while (i.hasNext()) {
+                CorbaTypeImpl type = (CorbaTypeImpl)i.next();
+                if (corbaName.equals(type.getName())
+                                     && corbaType.equals(type.getType().getLocalPart())) {                    
+                    if (type instanceof Struct) {                        
+                        return type;
+                    }
+                }
+            }
+        }
+        return duplicate;
+    }
+    
+    protected QName checkPrefix(QName schematypeName) {
+        QName name = schematypeName;
+        if ((name != null) && (name.getPrefix() == null || name.getPrefix().equals(""))) {
+            String prefix = def.getPrefix(name.getNamespaceURI());
+            if (prefix == null) {
+                prefix = xmlSchemaType.getNamespaceContext().getPrefix(name.getNamespaceURI());
+            }
+            if (prefix != null) {
+                return new QName(name.getNamespaceURI(),
+                                 name.getLocalPart(),
+                                 prefix);
+            } else {
+                return null;
+            }
+        }
+     
+        return name;
+    }
+
+    public QName createQNameTargetNamespace(String name) {       
+        return new QName(def.getTargetNamespace(), name, def.getPrefix(def.getTargetNamespace()));
+    }
+
+    public QName createQNameCorbaNamespace(String name) {
+        return new QName(getIdlNamespace(), name, def.getPrefix(getIdlNamespace()));
+    }
+
+    public QName createQName(String name, String namespaceName, String prefix) {
+        return new QName(name, namespaceName, prefix);
+    }
+    
+    public QName createQNameXmlSchemaNamespace(String name) {
+        return new QName(W3CConstants.NU_SCHEMA_XSD, name, W3CConstants.NP_SCHEMA_XSD);
+    }
+
+    private boolean isIDLObjectType(QName typeName) {
+        if (typeName.equals(ReferenceConstants.REFERENCE_TYPE)
+            || typeName.equals(ReferenceConstants.WSADDRESSING_TYPE)) {
+            return true;
+        }
+
+        return false;
+    }
+    
+    private boolean isAddressingNamespace(QName typeName) {
+        if ((typeName != null) && (!isIDLObjectType(typeName))) {
+            if (typeName.getNamespaceURI().equals(ReferenceConstants.REFERENCE_NAMESPACE)
+                || typeName.getNamespaceURI().equals(ReferenceConstants.WSADDRESSING_NAMESPACE)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    protected static boolean queryBinding(Definition definition, QName bqname) {
+        Map bindings = definition.getBindings();
+        Iterator i = bindings.values().iterator();
+        while (i.hasNext()) {
+            Binding binding = (Binding)i.next();
+            if (binding.getQName().getLocalPart().equals(bqname.getLocalPart())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+}

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaHelper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToProcessor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToProcessor.java?view=diff&rev=494510&r1=494509&r2=494510
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToProcessor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToProcessor.java Tue Jan  9 10:29:42 2007
@@ -91,7 +91,6 @@
             }
             wsdlDefinition = reader.readWSDL(wsdlUrl);
 
-            //bravi, Why are we doing this?
             parseImports(wsdlDefinition);
             buildWSDLDefinition();    
         } catch (WSDLException we) {
@@ -160,7 +159,7 @@
                     }
                 }
                 if (schemaElem != null) {
-                    schematype = schemaCol.read(schemaElem);                       
+                    schematype = schemaCol.read(schemaElem);                    
                     schematypeList.add(schematype);
                 }
             }
@@ -177,12 +176,6 @@
         extractSchema(wsdlDefinition);
         for (Definition def : importedDefinitions) {
             extractSchema(def);
-        }
-        if (schemaList.size() == 0) {
-            if (env.isVerbose()) {
-                System.err.println("No schema provided in the wsdl file");
-            }
-            return;
         }
         schemaTargetNamespaces.clear();     
     }

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLTypes.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLTypes.java?view=diff&rev=494510&r1=494509&r2=494510
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLTypes.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLTypes.java Tue Jan  9 10:29:42 2007
@@ -61,18 +61,16 @@
 import org.apache.yoko.wsdl.CorbaConstants;
 import org.apache.yoko.wsdl.CorbaTypeImpl;
 
-public class WSDLTypes extends WSDLToCorbaBinding {
+public final class WSDLTypes {
     
     protected static final Logger LOG = LogUtils.getL7dLogger(WSDLTypes.class);
-    static String idlversion = ":1.0";    
-    static String repoString = "IDL:";     
 
-    public WSDLTypes() {            
+    private WSDLTypes() {
     }
-    
-    public CorbaTypeImpl processObject(Definition definition, XmlSchemaComplexType complex,  
-                                       XmlSchemaAnnotation annotation, QName typeName,
-                                       QName defaultName, String idlNamespace) 
+
+    public static CorbaTypeImpl processObject(Definition definition, XmlSchemaComplexType complex,  
+                                              XmlSchemaAnnotation annotation, QName typeName,
+                                              QName defaultName, String idlNamespace) 
         throws Exception {
         CorbaTypeImpl corbaTypeImpl = null;
                 
@@ -93,7 +91,7 @@
 
                         //Check if the Binding with name already exists
                         Binding binding = null;
-                        if (queryBinding(definition, bqname)) {
+                        if (WSDLToCorbaHelper.queryBinding(definition, bqname)) {
                             binding = definition.getBinding(bqname);
                         }
 
@@ -143,8 +141,8 @@
     }         
 
     
-    public CorbaTypeImpl processStringType(CorbaTypeImpl corbaTypeImpl, QName name, 
-                                           String maxLength, String length) throws Exception {
+    public static CorbaTypeImpl processStringType(CorbaTypeImpl corbaTypeImpl, QName name, 
+                                                  String maxLength, String length) throws Exception {
         boolean boundedString = true;             
         int bound = 0;
 
@@ -174,8 +172,8 @@
         return corbaTypeImpl;
     }
     
-    public CorbaTypeImpl mapToArray(QName name, QName schematypeName, QName arrayType, int bound,
-                                     boolean anonymous) {
+    public static CorbaTypeImpl mapToArray(QName name, QName schematypeName, QName arrayType, int bound,
+                                           boolean anonymous) {
         CorbaTypeImpl corbatype = null;
             
         //schematypeName = checkPrefix(schematypeName);
@@ -187,7 +185,9 @@
             corbaArray.setType(schematypeName);
             corbaArray.setElemtype(arrayType);
             corbaArray.setBound(bound);
-            corbaArray.setRepositoryID(repoString + name.getLocalPart().replace('.', '/') + idlversion);
+            corbaArray.setRepositoryID(WSDLToCorbaHelper.REPO_STRING
+                                       + name.getLocalPart().replace('.', '/')
+                                       + WSDLToCorbaHelper.IDL_VERSION);
             corbaArray.setQName(name);            
             corbatype = corbaArray;
         } else {
@@ -203,8 +203,8 @@
         return corbatype;
     }
 
-    public CorbaTypeImpl mapToSequence(QName name, QName schematypeName, QName arrayType, int bound,
-                                        boolean anonymous) {
+    public static CorbaTypeImpl mapToSequence(QName name, QName schematypeName, QName arrayType, int bound,
+                                              boolean anonymous) {
         CorbaTypeImpl corbaTypeImpl = null;
 
         //schematypeName = checkPrefix(schematypeName);
@@ -216,7 +216,9 @@
             corbaSeq.setType(schematypeName);
             corbaSeq.setElemtype(arrayType);
             corbaSeq.setBound(bound);
-            corbaSeq.setRepositoryID(repoString + name.getLocalPart().replace('.', '/') + idlversion);
+            corbaSeq.setRepositoryID(WSDLToCorbaHelper.REPO_STRING
+                                     + name.getLocalPart().replace('.', '/')
+                                     + WSDLToCorbaHelper.IDL_VERSION);
             corbaTypeImpl = corbaSeq;
         } else {
             // Create a Anonymous Sequence
@@ -232,7 +234,7 @@
         return corbaTypeImpl;
     }
     
-    public Union processUnionBranches(Union corbaUnion, List fields, List<String> caselist) {
+    public static Union processUnionBranches(Union corbaUnion, List fields, List<String> caselist) {
         int caseIndex = 0;
 
         for (int i = 0; i < fields.size(); i++) {
@@ -252,7 +254,7 @@
     }    
 
     
-    public boolean isOMGUnion(XmlSchemaComplexType type) {
+    public static boolean isOMGUnion(XmlSchemaComplexType type) {
         boolean isUnion = false;
 
         if (type.getParticle() instanceof XmlSchemaSequence 
@@ -281,7 +283,7 @@
         return isUnion;
     }
         
-    public boolean isUnion(XmlSchemaComplexType type) {
+    public static boolean isUnion(XmlSchemaComplexType type) {
         boolean isUnion = false;
         
         if (type.getParticle() instanceof XmlSchemaChoice && type.getAttributes().getCount() == 0) {
@@ -292,9 +294,9 @@
     }
 
     
-    public CorbaTypeImpl processDecimalType(XmlSchemaSimpleTypeRestriction restrictionType, 
-                                             QName name, CorbaTypeImpl corbaTypeImpl,
-                                             boolean anonymous) throws Exception {
+    public static CorbaTypeImpl processDecimalType(XmlSchemaSimpleTypeRestriction restrictionType, 
+                                                   QName name, CorbaTypeImpl corbaTypeImpl,
+                                                   boolean anonymous) throws Exception {
                 
         String tdigits = null;
         String fdigits = null;
@@ -387,8 +389,8 @@
     }   
     
     
-    public CorbaTypeImpl processBase64Type(CorbaTypeImpl corbaTypeImpl, QName name, 
-                                           String maxLength, String length) 
+    public static CorbaTypeImpl processBase64Type(CorbaTypeImpl corbaTypeImpl, QName name, 
+                                                  String maxLength, String length) 
         throws Exception {
         int bound = 0;
         boolean boundedOctet = true;    
@@ -415,7 +417,7 @@
     }
     
     //  checks if the type is an anonymous type.
-    public boolean isAnonymous(String typeName) {
+    public static boolean isAnonymous(String typeName) {
         boolean anonymous = false;
         
         if (typeName == null) {
@@ -435,7 +437,7 @@
         return anonymous;
     }
     
-    public CorbaTypeImpl getFixedCorbaType(QName name, QName stype, int digits, int scale) {        
+    public static CorbaTypeImpl getFixedCorbaType(QName name, QName stype, int digits, int scale) {        
         Fixed fixed = new Fixed();
         fixed.setName(name.getLocalPart());
         fixed.setQName(name);
@@ -445,7 +447,7 @@
         return fixed;
     }
     
-    public CorbaTypeImpl getAnonFixedCorbaType(QName name, QName stype, int digits, int scale) {
+    public static CorbaTypeImpl getAnonFixedCorbaType(QName name, QName stype, int digits, int scale) {
         Anonfixed fixed = new Anonfixed();
         fixed.setName(name.getLocalPart());
         fixed.setQName(name);
@@ -455,7 +457,7 @@
         return fixed;
     }
     
-    public CorbaTypeImpl getOctetCorbaType(QName name, QName stype, int bound) {
+    public static CorbaTypeImpl getOctetCorbaType(QName name, QName stype, int bound) {
         Sequence seq = new Sequence();
         seq.setName(name.getLocalPart());
         seq.setQName(name);