Package org.apache.axis.wsdl.wsdl2ws.info

Examples of org.apache.axis.wsdl.wsdl2ws.info.ElementInfo


     * @param type
     */
    private void addInputElementsToMethodInfo(MethodInfo minfo, Type type)
    {
        ParameterInfo pinfo;
        ElementInfo eleinfo;
        Iterator elementNames = type.getElementnames();
        ArrayList elementlist = new ArrayList();
        while (elementNames.hasNext())
        {
            elementlist.add(elementNames.next());
        }

        for (int i = 0; i < elementlist.size(); i++)
        {
            String elementname = (String) elementlist.get(i);
            eleinfo = type.getElementForElementName(elementname);
            Type innerType = eleinfo.getType();
            pinfo = new ParameterInfo(innerType, elementname);
            if (eleinfo.getMaxOccurs() > 1)
            {
                pinfo.setArray(true);
            }
            pinfo.setElementName(
                type.getElementForElementName(elementname).getName());
            if (innerType.getName().equals(CUtils.anyTypeQname))
                pinfo.setAnyType(true);
            pinfo.setNillable(eleinfo.getNillable());
            minfo.addInputParameter(pinfo);
        }
    }
View Full Code Here


            if (base != null)
            {
                String localpart = type.getQName().getLocalPart() + "_value";
                QName typeName =
                    new QName(type.getQName().getNamespaceURI(), localpart);
                ElementInfo eleinfo =
                    new ElementInfo(
                        typeName,
                        createTypeInfo(base.getQName(), targetLanguage));
                typedata.setExtensionBaseType(eleinfo);
                if (WSDL2Ws.verbose)
                    System.out.print(
                        "=====complexType with simpleContent is found : "
                            + type.getQName().getLocalPart()
                            + "=====\n");
            }
            else
            {
                //types declared as simpleType
                restrictdata =
                    CUtils.getRestrictionBaseAndValues(node, symbolTable);
                if (restrictdata != null)
                    typedata.setRestrictiondata(restrictdata);
            }
            // There can be attributes in this extended basic type
            // Process the attributes
            Vector attributes =
                CSchemaUtils.getContainedAttributeTypes(
                    type.getNode(),
                    symbolTable);
            if (attributes != null)
            {
                for (int j = 0; j < attributes.size(); j += 2)
                {
                    typedata.setTypeForAttributeName(
                        ((QName) attributes.get(j + 1)).getLocalPart(),
                        createTypeInfo(
                            ((TypeEntry) attributes.get(j)).getQName(),
                            targetLanguage));
                }
            }
        }
        else
            if (type instanceof CollectionType)
            {
                typedata.setTypeNameForElementName(
                    new ElementInfo(
                        type.getQName(),
                        createTypeInfo(
                            type.getRefType().getQName(),
                            targetLanguage)));
                typedata.setArray(true);
            }
            else
            {
                //is this a SOAPEnc array type 
                QName arrayType =
                    CSchemaUtils.getArrayComponentQName(
                        node,
                        new IntHolder(0),
                        symbolTable);
                if (arrayType != null)
                {
                    typedata.setTypeNameForElementName(
                        new ElementInfo(
                            new QName("item"),
                            createTypeInfo(arrayType, targetLanguage)));
                    typedata.setArray(true);
                }
                else
                    if ((arrayType =
                        CSchemaUtils.getCollectionComponentQName(node))
                        != null)
                    {
                        typedata.setTypeNameForElementName(
                            new ElementInfo(
                                new QName("item"),
                                createTypeInfo(arrayType, targetLanguage)));
                        typedata.setArray(true);
                    }
                //Note in a array the parameter type is stored as under the name item all the time 
                else
                {
                    // get all extended types
                    Vector extendList = new Vector();
                    extendList.add(type);
                    TypeEntry parent =
                        CSchemaUtils.getComplexElementExtensionBase(
                            type.getNode(),
                            symbolTable);
                    while (parent != null)
                    {
                        extendList.add(parent);
                        parent =
                            CSchemaUtils.getComplexElementExtensionBase(
                                parent.getNode(),
                                symbolTable);
                    }

                    // Now generate a list of names and types starting with
                    // the oldest parent.  (Attrs are considered before elements).
                    for (int i = extendList.size() - 1; i >= 0; i--)
                    {
                        TypeEntry te = (TypeEntry) extendList.elementAt(i);

                        //TODO the code require the attributes name at extension base types
                        //different, the WSDL2Ws do not support it having same name at up and below.

                        // The names of the inherited parms are mangled
                        // in case they interfere with local parms.
                        // String mangle = "";
                        //if (i > 0) {
                        //  mangle = "_" +
                        //    Utils.xmlNameToJava(te.getQName().getLocalPart()) +
                        //    "_";
                        //}

                        // Process the attributes
                        Vector attributes =
                            CSchemaUtils.getContainedAttributeTypes(
                                te.getNode(),
                                symbolTable);
                        if (attributes != null)
                        {
                            for (int j = 0; j < attributes.size(); j += 2)
                            {
                                typedata.setTypeForAttributeName(
                                    ((QName) attributes.get(j + 1))
                                        .getLocalPart(),
                                    createTypeInfo(
                                        ((TypeEntry) attributes.get(j))
                                            .getQName(),
                                        targetLanguage));
                            }
                        }
                        // Process the elements
                        Vector elements =
                            CSchemaUtils.getContainedElementDeclarations(
                                te.getNode(),
                                symbolTable);
                        if (elements != null)
                        {
                            for (int j = 0; j < elements.size(); j++)
                            {
                                ElementInfo eleinfo = null;
                                CElementDecl elem =
                                    (CElementDecl) elements.get(j);
                                if (elem.getAnyElement())
                                {

                                    Type anyType =
                                        new Type(
                                            CUtils.anyTypeQname,
                                            CUtils.anyTypeQname.getLocalPart(),
                                            true,
                                            targetLanguage);
                                    eleinfo =
                                        new ElementInfo(
                                            elem.getName(),
                                            anyType);
                                }
                                else
                                {
                                    QName typeName = elem.getType().getQName();
                                    if (typeName.getLocalPart().indexOf('[')
                                        > 0)
                                    {
                                        String localpart =
                                            typeName.getLocalPart().substring(
                                                0,
                                                typeName
                                                    .getLocalPart()
                                                    .indexOf(
                                                    '['));
                                        typeName =
                                            new QName(
                                                typeName.getNamespaceURI(),
                                                localpart);
                                        if (CUtils.isBasicType(typeName))
                                        {
                                            eleinfo =
                                                new ElementInfo(
                                                    elem.getName(),
                                                    createTypeInfo(
                                                        typeName,
                                                        targetLanguage));
                                        }
                                        else
                                        {
                                            eleinfo =
                                                new ElementInfo(
                                                    elem.getName(),
                                                    createTypeInfo(
                                                        elem.getType(),
                                                        targetLanguage));
                                        }
                                    }
                                    else
                                    {
                                        eleinfo =
                                            new ElementInfo(
                                                elem.getName(),
                                                createTypeInfo(
                                                    typeName,
                                                    targetLanguage));
                                    }
                                }
                                eleinfo.setMinOccurs(elem.getMinOccurs());
                                eleinfo.setMaxOccurs(elem.getMaxOccurs());
                                eleinfo.setNillable( elem.isNillable());
                               
                                // Dushshantha:
                                // states whether this element is a xsd:choice
                                eleinfo.setChoiceElement(elem.getChoiceElement());
                                //.................................................
                               
                                // Chinthana:
                                // states whether this element is a xsd:all
                                eleinfo.setAllElement(elem.getAllElement());
                                //04/05/2005.................................................
                               
                                typedata.setTypeNameForElementName(eleinfo);
                            }
                        }
View Full Code Here

    /* genarate the attribs array */
    private void populateAttribList() throws WrapperFault
    {
     
      ElementInfo elemi = type.getExtensionBaseType();
        if (elemi != null)
        {
            extensionBaseAttrib = new AttributeInfo(this.classname);
            extensionBaseAttrib.setParamName(elemi.getName().getLocalPart());
            extensionBaseAttrib.setTypeName(
                CUtils.getclass4qname(elemi.getType().getName()));
            extensionBaseAttrib.setType(elemi.getType());
            extensionBaseAttrib.setElementName(elemi.getName());
           
           
        }
        ArrayList attribfeilds = new ArrayList();
        ArrayList elementfeilds = new ArrayList();

        Iterator names = type.getAttributeNames();
        while (names.hasNext())
        {
            attribfeilds.add(names.next());
        }
        names = type.getElementnames();
        while (names.hasNext())
        {
            elementfeilds.add(names.next());
        }
        int intAttrFieldSz = attribfeilds.size();
        attributeParamCount = intAttrFieldSz;
        int intEleFieldSz = elementfeilds.size();
        this.attribs = new AttributeInfo[intAttrFieldSz + intEleFieldSz];
        for (int i = 0; i < intAttrFieldSz; i++)
        {
            this.attribs[i] = new AttributeInfo(this.classname);
            this.attribs[i].setParamName((String) attribfeilds.get(i));
            Type attribType =
                type.getTypForAttribName(this.attribs[i].getParamName());
            if (CUtils.isSimpleType(attribType.getName()))
                this.attribs[i].setTypeName(
                    CUtils.getclass4qname(attribType.getName()));
            else
            {
                this.attribs[i].setTypeName(
                    attribType.getLanguageSpecificName());
                this.attribs[i].setSimpleType(false);
            }
            this.attribs[i].setType(attribType);
            this.attribs[i].setAttribute(true);
            this.attribs[i].setElementName(attribType.getName());
           
                       
            //TODO this is wrong. correct immediately. this will cause attributes serialized incorrectly
            //TODO : how to find whether this attribute is optional or not ?
        }

        for (int i = intAttrFieldSz; i < intAttrFieldSz + intEleFieldSz; i++)
        {
            this.attribs[i] = new AttributeInfo(this.classname);
            this.attribs[i].setParamName(
                (String) elementfeilds.get(i - attributeParamCount));
            ElementInfo elem =
                type.getElementForElementName(this.attribs[i].getParamName());
            Type elementType = elem.getType();
            if (CUtils.isAnyType(elementType.getName()))
            {
                this.attribs[i].setAnyType(true);
            }
            if (CUtils.isSimpleType(elementType.getName()))
                this.attribs[i].setTypeName(
                    CUtils.getclass4qname(elementType.getName()));
            else
            {
                this.attribs[i].setTypeName(
                    elementType.getLanguageSpecificName());
                this.attribs[i].setSimpleType(false);
            }
            this.attribs[i].setType(elementType);
            this.attribs[i].setElementName(elem.getName());
            //Dushshantha:
            //setting the choice element availability.
            this.attribs[i].setChoiceElement(elem.getChoiceElement());
                                  
            //..................................................
           
            //Chinthana:
            //setting the all element availability.
            this.attribs[i].setAllElement(elem.getAllElement());
            //04/05/2005..................................................
            //setting the minoccures
            this.attribs[i].setMinOccurs(elem.getMinOccurs());
            //12/05/2005..................................................

           
           
            if (elementType.isArray())
            { //soap encoding arrays.
                Type arrayType = WrapperUtils.getArrayType(elementType);
                //get contained type
                this.attribs[i].setArray(true);
                if (CUtils.isSimpleType(arrayType.getName()))
                {
                    this.attribs[i].setTypeName(
                        CUtils.getclass4qname(arrayType.getName()));
                    this.attribs[i].setSimpleType(true);
                }
                else
                {
                    this.attribs[i].setTypeName(
                        arrayType.getLanguageSpecificName());
                    this.attribs[i].setSimpleType(false);
                }
                this.attribs[i].setType(arrayType);
                //set contained type as type
            }
            else
                if (elem.getMaxOccurs() > 1)
                {
                    //arrays but the same type as was set above
                    this.attribs[i].setArray(true);
                }
            if (elem.getMinOccurs() == 0)
                this.attribs[i].setOptional(true);
        }
    }
View Full Code Here

  public AttributeInfo[] getAttribList(String Qualifiedname) throws WrapperFault {
    return this.attribs;
  }  
   /* genarate the arrtibs array */
   private void populateAttribList(String Qualifiedname) throws WrapperFault {
     ElementInfo elemi = type.getExtensionBaseType();
     if ( elemi != null){
      extensionBaseAttrib = new AttributeInfo(this.classname);
      extensionBaseAttrib.setParamName(elemi.getName().getLocalPart());
      extensionBaseAttrib.setTypeName(CUtils.getclass4qname(elemi.getType().getName()));
      extensionBaseAttrib.setType(elemi.getType());
      extensionBaseAttrib.setElementName(elemi.getName());
     }
    ArrayList attribfeilds = new ArrayList();
    ArrayList elementfeilds = new ArrayList();

    Iterator names = type.getAttributeNames();
    while (names.hasNext()){
      attribfeilds.add(names.next());
    }       
    names = type.getElementnames();
    while (names.hasNext()){
      elementfeilds.add(names.next());
    }
    int intAttrFieldSz = attribfeilds.size();
    attributeParamCount = intAttrFieldSz;
    int intEleFieldSz = elementfeilds.size();
    this.attribs = new AttributeInfo[intAttrFieldSz+intEleFieldSz];
    for (int i = 0 ; i < intAttrFieldSz; i++) {
      this.attribs[i] = new AttributeInfo(this.classname);
      this.attribs[i].setParamName((String)attribfeilds.get(i));
      Type attribType = type.getTypForAttribName(this.attribs[i].getParamName());           
      if(CUtils.isSimpleType(attribType.getName()))
        this.attribs[i].setTypeName(CUtils.getclass4qname(attribType.getName()));
      else{
        this.attribs[i].setTypeName(attribType.getLanguageSpecificName());
        this.attribs[i].setSimpleType(false);
      }
      this.attribs[i].setType(attribType);
      this.attribs[i].setAttribute(true);
      this.attribs[i].setElementName(attribType.getName()); //TODO this is wrong. correct immediately. this will cause attributes serialized incorrectly
      //TODO : how to find whether this attribute is optional or not ?
    }

    for (int i = intAttrFieldSz ; i < intAttrFieldSz+intEleFieldSz; i++) {
      this.attribs[i] = new AttributeInfo(this.classname);
      this.attribs[i].setParamName((String) elementfeilds.get(i-attributeParamCount));  
      ElementInfo elem = type.getElementForElementName(this.attribs[i].getParamName());
      Type elementType = elem.getType();
      if(CUtils.isAnyType(elementType.getName())){
        this.attribs[i].setAnyType(true);
      }
      if(CUtils.isSimpleType(elementType.getName()))
        this.attribs[i].setTypeName(CUtils.getclass4qname(elementType.getName()));
      else{
        this.attribs[i].setTypeName(elementType.getLanguageSpecificName());
        this.attribs[i].setSimpleType(false);
      }
      this.attribs[i].setType(elementType);
      this.attribs[i].setElementName(elem.getName());
         if(elementType.isArray()){ //soap encoding arrays.
        Type arrayType = WrapperUtils.getArrayType(elementType); //get contained type
        this.attribs[i].setArray(true);
        if(CUtils.isSimpleType(arrayType.getName())){
          this.attribs[i].setTypeName(CUtils.getclass4qname(arrayType.getName()));
          this.attribs[i].setSimpleType(true);
        }
        else{
          this.attribs[i].setTypeName(arrayType.getLanguageSpecificName());
          this.attribs[i].setSimpleType(false);
        }
        this.attribs[i].setType(arrayType); //set contained type as type
       }else if (elem.getMaxOccurs() > 1){
           //arrays but the same type as was set above
        this.attribs[i].setArray(true);
       }
       if (elem.getMinOccurs() == 0) this.attribs[i].setOptional(true);
   
   }
View Full Code Here

        ArrayList methods = new ArrayList();
        MethodInfo minfo;
    Element element;
    QName qname;
        ParameterInfo pinfo;
    ElementInfo eleinfo;
    Type type;
        org.apache.axis.wsdl.symbolTable.Type ptype;
        //for each operation
        while (oplist.hasNext()) {
            minfo = new MethodInfo();
            methods.add(minfo);
            //add operation to operation List
            Operation op = (Operation) oplist.next();
            minfo.setMethodname(op.getName());
           
            //setting the faults
            Map faults = op.getFaults();
      addFaultInfo(faults,minfo);
            Iterator paramlist = null;
            //add each parameter to parameter list
            if ("document".equals(bindingEntry.getBindingStyle().getName())){
        paramlist = op.getInput().getMessage().getParts().values().iterator();
        Part part = (Part) paramlist.next();
        QName minfoqname;
        element = symbolTable.getElement(part.getElementName());
        if ( element == null ) {
          // the part reference a type.
          qname =  symbolTable.getType(part.getTypeName()).getQName();
          minfoqname = symbolTable.getType(part.getTypeName()).getQName();
        }
        else {
          qname = element.getRefType().getQName();
          minfoqname = element.getQName();
        }
        if (qname != null){
          minfo.setInputMessage(minfoqname);
         
          type = this.typeMap.getType(qname);
          //boolean wrapped = true; //TODO take this from a commandline argument
          //boolean wrapped = false; //just for testing the non-wrapped style wsdl
          boolean wrapped = wsdlWrappingStyle;

          if (wrapped){
            if(type == null)
               throw new WrapperFault("unregisterd type "+qname+" refered");
            else{
              /* if(type.getLanguageSpecificName().startsWith(">")){*/ //anyway skip the wrapping element type even if it is a named type.
              //get inner attributes and elements and add them as parameters
              ArrayList elementlist = new ArrayList();
              Iterator names = type.getElementnames();
              while (names.hasNext()){
                elementlist.add(names.next());
              }

              Type innerType;
              for (int i = 0 ; i < elementlist.size(); i++) {
                String elementname = (String)elementlist.get(i);
                eleinfo = type.getElementForElementName(elementname);
                innerType = eleinfo.getType();
                pinfo = new ParameterInfo(innerType,elementname);
                if (eleinfo.getMaxOccurs() > 1){
                  pinfo.setArray(true);                 
                }
                pinfo.setElementName(type.getElementForElementName(elementname).getName());
                if (innerType.getName().equals(CUtils.anyTypeQname))
                  pinfo.setAnyType(true);
                minfo.addInputParameter(pinfo);   
              }

              ArrayList attributeList = new ArrayList();
              names = type.getAttributeNames();
              while (names.hasNext()){
                attributeList.add(names.next());
              }
              for (int i = 0; i < attributeList.size();i++){
                String attributeName = (String) attributeList.get(i);
                innerType = type.getTypForAttribName(attributeName);
                pinfo= new ParameterInfo(innerType, attributeName);
                pinfo.setElementName(type.getTypForAttribName(attributeName).getName());
                pinfo.setAttribute(true);
                minfo.addInputParameter(pinfo);
              }
              //remove the type that represents the wrapping element so that such type is not created.
              //following is commented for the moment because the same element can be refered by more
              //than one message. Also this complex type may be used as a type while it is the wrapping
              //element here
              //this.typeMap.removeType(qname);
            }
          }
          else{ // for non-wrapped style wsdl's
            if(type == null)
               throw new WrapperFault("unregisterd type "+qname+" refered");
            else{
              // String elementName = (String)type.getName().toString();
              String elementName = (String)element.getQName().getLocalPart();
              pinfo = new ParameterInfo(type,elementName);
              pinfo.setElementName(type.getName());
              if (type.getName().equals(CUtils.anyTypeQname))
                pinfo.setAnyType(true);
              minfo.addInputParameter(pinfo);
            }
          }
        }
        }
          else{
        minfo.setInputMessage(op.getInput().getMessage().getQName());
             if (op.getParameterOrdering() != null){
               for (int ix=0; ix < op.getParameterOrdering().size(); ix++){
            Part p = (Part)(op.getInput().getMessage().getParts().get((String)op.getParameterOrdering().get(ix)));
            if (p == null) continue;
            pinfo = createParameterInfo(p);
            if (null != pinfo) minfo.addInputParameter(pinfo);
               }
             }
             else {
          paramlist = op.getInput().getMessage().getParts().values().iterator();
          while (paramlist.hasNext()) { //RPC style messages can have multiple parts
            Part p = (Part) paramlist.next();
            pinfo = createParameterInfo(p);
            if (null != pinfo) minfo.addInputParameter(pinfo);
          }              
             }
           }
            //get the return type
      if(op.getOutput()!=null){
              Iterator returnlist = op.getOutput().getMessage().getParts().values().iterator();
        if (returnlist.hasNext() && "document".equals(bindingEntry.getBindingStyle().getName())){
          Part part = (Part) returnlist.next();
          QName minfoqname;
          element = symbolTable.getElement(part.getElementName());
          if ( element == null ) {
            // the part reference a type.
            qname =  symbolTable.getType(part.getTypeName()).getQName();
            minfoqname = symbolTable.getType(part.getTypeName()).getQName();
          }
          else {
            qname = element.getRefType().getQName();
            minfoqname = element.getQName();
          }
          if (qname != null){
            minfo.setOutputMessage(minfoqname);
            type = this.typeMap.getType(qname);       
            //boolean wrapped = true; //TODO take this from a commandline argument
            boolean wrapped = wsdlWrappingStyle;
            if (wrapped){
              if(type == null)
                 throw new WrapperFault("unregisterd type "+qname+" refered");
              else{
                /*if(type.getLanguageSpecificName().startsWith(">")){*///anyway skip the wrapping element type even if it is a named type.
                //get inner attributes and elements and add them as parameters
                ArrayList elementlist = new ArrayList();
                Iterator names = type.getElementnames();
                while (names.hasNext()){
                  elementlist.add(names.next());
                }
                Type innerType;
                for (int i = 0 ; i < elementlist.size(); i++) {
                  String elementname = (String)elementlist.get(i);
                  eleinfo = type.getElementForElementName(elementname);
                  innerType = eleinfo.getType();
                  pinfo = new ParameterInfo(innerType,elementname);
                  if (eleinfo.getMaxOccurs() > 1){
                    pinfo.setArray(true);                 
                  }
                  pinfo.setElementName(type.getElementForElementName(elementname).getName());
                  if (innerType.getName().equals(CUtils.anyTypeQname))
                    pinfo.setAnyType(true);
View Full Code Here

      //check for extended types
      TypeEntry base = SchemaUtils.getComplexElementExtensionBase(type.getNode(),symbolTable);
      if (base != null){
        String localpart = type.getQName().getLocalPart()+ "_value";
        QName typeName = new QName(type.getQName().getNamespaceURI(),localpart);
        ElementInfo eleinfo = new ElementInfo(typeName,createTypeInfo(base.getQName(),targetLanguage));
        typedata.setExtensionBaseType(eleinfo);
        if ( WSDL2Ws.verbose)
            System.out.print("=====complexType with simpleContent is found : "+ type.getQName().getLocalPart()+"=====\n");
      }
      else{
      //types declared as simpleType
        restrictdata = CUtils.getRestrictionBaseAndValues(node,symbolTable);
        if(restrictdata != null)
          typedata.setRestrictiondata(restrictdata);
      }
      // There can be attributes in this extended basic type
      // Process the attributes
      Vector attributes = SchemaUtils.getContainedAttributeTypes(
        type.getNode(), symbolTable);
      if (attributes != null) {
        for (int j=0; j<attributes.size(); j+=2) {
          typedata.setTypeForAttributeName(
            ((QName)attributes.get(j + 1)).getLocalPart(),
          createTypeInfo(((TypeEntry) attributes.get(j)).getQName(),targetLanguage));
        }
      }     
    }else if(type instanceof CollectionType){
      typedata.setTypeNameForElementName(new ElementInfo(type.getQName(),
          createTypeInfo(type.getRefType().getQName(),targetLanguage)));
      typedata.setArray(true);
    }else{
      //is this a SOAPEnc array type 
      QName arrayType =
        SchemaUtils.getArrayComponentQName(node, new IntHolder(0),symbolTable);
      if (arrayType != null) {
        typedata.setTypeNameForElementName(new ElementInfo(new QName("item"),
            createTypeInfo(arrayType,targetLanguage)));
        typedata.setArray(true);
      } else if (
        (arrayType = SchemaUtils.getCollectionComponentQName(node))
          != null) {
        typedata.setTypeNameForElementName(new ElementInfo(new QName("item"),
            createTypeInfo(arrayType,targetLanguage)));
        typedata.setArray(true);
      }
      //Note in a array the parameter type is stored as under the name item all the time 
      else {
        // get all extended types
        Vector extendList = new Vector();
        extendList.add(type);
        TypeEntry parent = SchemaUtils.getComplexElementExtensionBase(
                            type.getNode(),symbolTable);
        while(parent != null) {
          extendList.add(parent);
          parent = SchemaUtils.getComplexElementExtensionBase(
                        parent.getNode(),symbolTable);
        }
   
        // Now generate a list of names and types starting with
        // the oldest parent.  (Attrs are considered before elements).
        for (int i=extendList.size()-1; i >= 0; i--) {
          TypeEntry te = (TypeEntry) extendList.elementAt(i);
   
         
          //TODO the code require the attributes name at extension base types
          //different, the WSDL2Ws do not support it having same name at up and below.
         
          // The names of the inherited parms are mangled
          // in case they interfere with local parms.
          String mangle = "";
          //if (i > 0) {
          //  mangle = "_" +
          //    Utils.xmlNameToJava(te.getQName().getLocalPart()) +
          //    "_";
          //}
         
          // Process the attributes
          Vector attributes = SchemaUtils.getContainedAttributeTypes(
            te.getNode(), symbolTable);
          if (attributes != null) {
            for (int j=0; j<attributes.size(); j+=2) {
              typedata.setTypeForAttributeName(
                ((QName)attributes.get(j + 1)).getLocalPart(),
              createTypeInfo(((TypeEntry) attributes.get(j)).getQName(),targetLanguage));
            }
          }
          // Process the elements
          Vector elements = SchemaUtils.getContainedElementDeclarations(
                      te.getNode(), symbolTable);
          if (elements != null) {
            for (int j=0; j<elements.size(); j++) {
              ElementInfo eleinfo = null;
              ElementDecl elem = (ElementDecl)elements.get(j);
              if (elem.getAnyElement()){
             
                Type anyType = new Type(CUtils.anyTypeQname, CUtils.anyTypeQname.getLocalPart(), true, targetLanguage);
                eleinfo = new ElementInfo(elem.getName(),anyType);             
              }
              else{
                QName typeName = elem.getType().getQName();
                if(typeName.getLocalPart().indexOf('[')>0){
                  String localpart = typeName.getLocalPart().substring(0,typeName.getLocalPart().indexOf('['));
                  typeName = new QName(typeName.getNamespaceURI(),localpart);
                  if (CUtils.isBasicType(typeName)){
                    eleinfo = new ElementInfo(elem.getName(),createTypeInfo(typeName,targetLanguage));
                  }
                  else{
                    eleinfo = new ElementInfo(elem.getName(),createTypeInfo(elem.getType(),targetLanguage));
                  }
                }
                else{
                  eleinfo = new ElementInfo(elem.getName(),createTypeInfo(typeName,targetLanguage));               
                }
              }
              eleinfo.setMinOccurs(elem.getMinOccrs());
              eleinfo.setMaxOccurs(elem.getMaxOccurs());
              typedata.setTypeNameForElementName(eleinfo);
            }     
          }
        }
      }
View Full Code Here

      //check for extended types
      TypeEntry base = SchemaUtils.getComplexElementExtensionBase(type.getNode(),symbolTable);
      if (base != null){
        String localpart = type.getQName().getLocalPart()+ "_value";
        QName typeName = new QName(type.getQName().getNamespaceURI(),localpart);
        ElementInfo eleinfo = new ElementInfo(typeName,createTypeInfo(base.getQName(),targetLanguage));
        typedata.setExtensionBaseType(eleinfo);
        if ( WSDL2Ws.verbose)
            System.out.print("=====complexType with simpleContent is found : "+ type.getQName().getLocalPart()+"=====\n");
      }
      else{
      //types declared as simpleType
        restrictdata = CUtils.getRestrictionBaseAndValues(node,symbolTable);
        if(restrictdata != null)
          typedata.setRestrictiondata(restrictdata);
      }
      // There can be attributes in this extended basic type
      // Process the attributes
      Vector attributes = SchemaUtils.getContainedAttributeTypes(
        type.getNode(), symbolTable);
      if (attributes != null) {
        for (int j=0; j<attributes.size(); j+=2) {
          typedata.setTypeForAttributeName(
            ((QName)attributes.get(j + 1)).getLocalPart(),
          createTypeInfo(((TypeEntry) attributes.get(j)).getQName(),targetLanguage));
        }
      }     
    }else if(type instanceof CollectionType){
      typedata.setTypeNameForElementName(new ElementInfo(type.getQName(),
          createTypeInfo(type.getRefType().getQName(),targetLanguage)));
      typedata.setArray(true);
    }else{
      //is this a SOAPEnc array type 
      QName arrayType =
        SchemaUtils.getArrayComponentQName(node, new IntHolder(0),symbolTable);
      if (arrayType != null) {
        typedata.setTypeNameForElementName(new ElementInfo(new QName("item"),
            createTypeInfo(arrayType,targetLanguage)));
        typedata.setArray(true);
      } else if (
        (arrayType = SchemaUtils.getCollectionComponentQName(node))
          != null) {
        typedata.setTypeNameForElementName(new ElementInfo(new QName("item"),
            createTypeInfo(arrayType,targetLanguage)));
        typedata.setArray(true);
      }
      //Note in a array the parameter type is stored as under the name item all the time 
      else {
        // get all extended types
        Vector extendList = new Vector();
        extendList.add(type);
        TypeEntry parent = SchemaUtils.getComplexElementExtensionBase(
                            type.getNode(),symbolTable);
        while(parent != null) {
          extendList.add(parent);
          parent = SchemaUtils.getComplexElementExtensionBase(
                        parent.getNode(),symbolTable);
        }
   
        // Now generate a list of names and types starting with
        // the oldest parent.  (Attrs are considered before elements).
        for (int i=extendList.size()-1; i >= 0; i--) {
          TypeEntry te = (TypeEntry) extendList.elementAt(i);
   
         
          //TODO the code require the attributes name at extension base types
          //different, the WSDL2Ws do not support it having same name at up and below.
         
          // The names of the inherited parms are mangled
          // in case they interfere with local parms.
          String mangle = "";
          //if (i > 0) {
          //  mangle = "_" +
          //    Utils.xmlNameToJava(te.getQName().getLocalPart()) +
          //    "_";
          //}
         
          // Process the attributes
          Vector attributes = SchemaUtils.getContainedAttributeTypes(
            te.getNode(), symbolTable);
          if (attributes != null) {
            for (int j=0; j<attributes.size(); j+=2) {
              typedata.setTypeForAttributeName(
                ((QName)attributes.get(j + 1)).getLocalPart(),
              createTypeInfo(((TypeEntry) attributes.get(j)).getQName(),targetLanguage));
            }
          }
          // Process the elements
          Vector elements = SchemaUtils.getContainedElementDeclarations(
                      te.getNode(), symbolTable);
          if (elements != null) {
            for (int j=0; j<elements.size(); j++) {
              ElementInfo eleinfo = null;
              ElementDecl elem = (ElementDecl)elements.get(j);
              if (elem.getAnyElement()){
             
                Type anyType = new Type(CUtils.anyTypeQname, CUtils.anyTypeQname.getLocalPart(), true, targetLanguage);
                eleinfo = new ElementInfo(elem.getName(),anyType);             
              }
              else{
                QName typeName = elem.getType().getQName();
                if(typeName.getLocalPart().indexOf('[')>0){
                  String localpart = typeName.getLocalPart().substring(0,typeName.getLocalPart().indexOf('['));
                  typeName = new QName(typeName.getNamespaceURI(),localpart);
                  if (CUtils.isBasicType(typeName)){
                    eleinfo = new ElementInfo(elem.getName(),createTypeInfo(typeName,targetLanguage));
                  }
                  else{
                    eleinfo = new ElementInfo(elem.getName(),createTypeInfo(elem.getType(),targetLanguage));
                  }
                }
                else{
                  eleinfo = new ElementInfo(elem.getName(),createTypeInfo(typeName,targetLanguage));               
                }
              }
              eleinfo.setMinOccurs(elem.getMinOccrs());
              eleinfo.setMaxOccurs(elem.getMaxOccurs());
              typedata.setTypeNameForElementName(eleinfo);
            }     
          }
        }
      }
View Full Code Here

  public AttributeInfo[] getAttribList(String Qualifiedname) throws WrapperFault {
    return this.attribs;
  }  
   /* genarate the arrtibs array */
   private void populateAttribList(String Qualifiedname) throws WrapperFault {
     ElementInfo elemi = type.getExtensionBaseType();
     if ( elemi != null){
      extensionBaseAttrib = new AttributeInfo();
      extensionBaseAttrib.setParamName(elemi.getName().getLocalPart());
      extensionBaseAttrib.setTypeName(CUtils.getclass4qname(elemi.getType().getName()));
      extensionBaseAttrib.setType(elemi.getType());
      extensionBaseAttrib.setElementName(elemi.getName());
     }
    ArrayList attribfeilds = new ArrayList();
    ArrayList elementfeilds = new ArrayList();

    Iterator names = type.getAttributeNames();
    while (names.hasNext()){
      attribfeilds.add(names.next());
    }       
    names = type.getElementnames();
    while (names.hasNext()){
      elementfeilds.add(names.next());
    }
    int intAttrFieldSz = attribfeilds.size();
    attributeParamCount = intAttrFieldSz;
    int intEleFieldSz = elementfeilds.size();
    this.attribs = new AttributeInfo[intAttrFieldSz+intEleFieldSz];
    for (int i = 0 ; i < intAttrFieldSz; i++) {
      this.attribs[i] = new AttributeInfo();
      this.attribs[i].setParamName((String)attribfeilds.get(i));
      Type attribType = type.getTypForAttribName(this.attribs[i].getParamName());           
      if(CUtils.isSimpleType(attribType.getName()))
        this.attribs[i].setTypeName(CUtils.getclass4qname(attribType.getName()));
      else{
        this.attribs[i].setTypeName(attribType.getLanguageSpecificName());
        this.attribs[i].setSimpleType(false);
      }
      this.attribs[i].setType(attribType);
      this.attribs[i].setAttribute(true);
      this.attribs[i].setElementName(attribType.getName()); //TODO this is wrong. correct immediately. this will cause attributes serialized incorrectly
      //TODO : how to find whether this attribute is optional or not ?
    }

    for (int i = intAttrFieldSz ; i < intAttrFieldSz+intEleFieldSz; i++) {
      this.attribs[i] = new AttributeInfo();
      this.attribs[i].setParamName((String) elementfeilds.get(i-attributeParamCount));  
      ElementInfo elem = type.getElementForElementName(this.attribs[i].getParamName());
      Type elementType = elem.getType();
      if(CUtils.isAnyType(elementType.getName())){
        this.attribs[i].setAnyType(true);
      }
      if(CUtils.isSimpleType(elementType.getName()))
        this.attribs[i].setTypeName(CUtils.getclass4qname(elementType.getName()));
      else{
        this.attribs[i].setTypeName(elementType.getLanguageSpecificName());
        this.attribs[i].setSimpleType(false);
      }
      this.attribs[i].setType(elementType);
      this.attribs[i].setElementName(elem.getName());
         if(elementType.isArray()){ //soap encoding arrays.
        Type arrayType = WrapperUtils.getArrayType(elementType); //get contained type
        this.attribs[i].setArray(true);
        if(CUtils.isSimpleType(arrayType.getName())){
          this.attribs[i].setTypeName(CUtils.getclass4qname(arrayType.getName()));
          this.attribs[i].setSimpleType(true);
        }
        else{
          this.attribs[i].setTypeName(arrayType.getLanguageSpecificName());
          this.attribs[i].setSimpleType(false);
        }
        this.attribs[i].setType(arrayType); //set contained type as type
       }else if (elem.getMaxOccurs() > 1){
           //arrays but the same type as was set above
        this.attribs[i].setArray(true);
       }
       if (elem.getMinOccurs() == 0) this.attribs[i].setOptional(true);
   
   }
View Full Code Here

     * @param type
     */
    private void addOutputElementsToMethodInfo(MethodInfo minfo, Type type)
    {
        ParameterInfo pinfo;
        ElementInfo eleinfo;
        ArrayList elementlist = new ArrayList();
        Iterator names = type.getElementnames();
        while (names.hasNext())
        {
            elementlist.add(names.next());
        }
        Type innerType;
        for (int i = 0; i < elementlist.size(); i++)
        {
            String elementname = (String) elementlist.get(i);
            eleinfo = type.getElementForElementName(elementname);
            innerType = eleinfo.getType();
            pinfo = new ParameterInfo(innerType, elementname);
            if (eleinfo.getMaxOccurs() > 1)
            {
                pinfo.setArray(true);
            }
            pinfo.setElementName(
                type.getElementForElementName(elementname).getName());
View Full Code Here

     * @param type
     */
    private void addInputElementsToMethodInfo(MethodInfo minfo, Type type)
    {
        ParameterInfo pinfo;
        ElementInfo eleinfo;
        Iterator elementNames = type.getElementnames();
        ArrayList elementlist = new ArrayList();
        while (elementNames.hasNext())
        {
            elementlist.add(elementNames.next());
        }

        for (int i = 0; i < elementlist.size(); i++)
        {
            String elementname = (String) elementlist.get(i);
            eleinfo = type.getElementForElementName(elementname);
            Type innerType = eleinfo.getType();
            pinfo = new ParameterInfo(innerType, elementname);
            if (eleinfo.getMaxOccurs() > 1)
            {
                pinfo.setArray(true);
            }
            pinfo.setElementName(
                type.getElementForElementName(elementname).getName());
View Full Code Here

TOP

Related Classes of org.apache.axis.wsdl.wsdl2ws.info.ElementInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.