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

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


        ArrayList methods = new ArrayList();
        MethodInfo minfo;
    Element element;
    QName qname;
        ParameterInfo pinfo;
    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());
            System.out.println(op.getName()+"operation name .......................&&&&&&&&&&&");
            //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);
          System.out.println(minfoqname.getLocalPart()+"setInputMessage.............?????????????");
          type = this.typeMap.getType(qname);
          boolean wrapped = true; //TODO take this from a commandline argument
          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);
                innerType = type.getElementForElementName(elementname).getType();
                pinfo = new ParameterInfo(innerType,elementname);
                pinfo.setElementName(type.getElementForElementName(elementname).getName());
                if (innerType.getName().equals(CUtils.anyTypeQname))
                  pinfo.setAnyType(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{
           
          }
        }
        }
          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
            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);
                  innerType = type.getElementForElementName(elementname).getType();
                  pinfo = new ParameterInfo(innerType,elementname);
                  pinfo.setElementName(type.getElementForElementName(elementname).getName());
                  if (innerType.getName().equals(CUtils.anyTypeQname))
                    pinfo.setAnyType(true);
                  minfo.addOutputParameter(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
View Full Code Here


     */
    private TypeMap getTypeInfo(String targetLanguage)throws WrapperFault {
        Iterator it = symbolTable.getTypeIndex().values().iterator();
        TypeEntry type;
        Iterator elements;
        Type typedata;

        boolean hasElements;
        while (it.hasNext()) {
            type = (TypeEntry) it.next();
            Node node = type.getNode();
View Full Code Here

      if (type.getRefType() != null){
        return createTypeInfo(type.getRefType(), targetLanguage);
      }
      return null;
    }
    Type typedata = typeMap.getType(type.getQName());   
    if(typedata!= null){
      //type is a inbild type or a already created type
      return typedata; 
    }
    System.out.println("############## the type found =" + type.getQName());
    if (-1 != type.getQName().getLocalPart().indexOf('[')) {/* it seems that this is an array */
      if (null == type.getRefType())throw new WrapperFault("Array type found without a Ref type");
      QName qn = type.getRefType().getQName();
      if (null == qn)throw new WrapperFault("Array type found without a Ref type");
      if (CUtils.isBasicType(qn)) return null;
      QName newqn = new QName(type.getQName().getNamespaceURI(), qn.getLocalPart()+"_Array");
      typedata = new Type(newqn, newqn.getLocalPart(), true, targetLanguage);
      typeMap.addType(newqn, typedata);
    }else {
      typedata = new Type(type.getQName(), type.getQName().getLocalPart(), true, targetLanguage);
      typeMap.addType(type.getQName(), typedata);
    }
     
    Node node = type.getNode();

    Vector restrictdata = null;
    if(type.isSimpleType()){
      //extended types and 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));
      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()){
                System.out.println("Any Type found inside "+ type.getQName().toString());
                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){
View Full Code Here

    if(qname == null){
      Element element = symbolTable.getElement(part.getElementName());
      qname = element.getRefType().getQName();
    }
    TypeEntry tentry = symbolTable.getType(qname);   
    Type type = this.typeMap.getType(qname);
    if(type == null)
      throw new WrapperFault("unregisterd type "+qname+" refered");
    ParameterInfo parainfo =
      new ParameterInfo(type,part.getName());
    parainfo.setElementName(part.getElementName());   
View Full Code Here

    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
View Full Code Here

  /* (non-Javadoc)
   * @see org.apache.axis.wsdl.wsdl2ws.cpp.BasicFileWriter#writePreprocssorStatements()
   */
  protected void writePreprocssorStatements() throws WrapperFault {
    try{
    Type atype;
    Iterator types = this.wscontext.getTypemap().getTypes().iterator();
    writer.write("#include <axis/server/AxisUserAPI.h>\n\n");
    HashSet typeSet = new HashSet();
    for (int i=0;i<attribs.length; i++)
    {
View Full Code Here

      isAllTreatedAsOutParams = true;
    }
    Collection params = minfo.getInputParameterTypes();
 
    String methodName = minfo.getMethodname();
    Type retType = null;
    boolean returntypeissimple = false;
    boolean returntypeisarray = false;
    String outparamTypeName = null;
    if (returntype != null){
      outparamTypeName = WrapperUtils.getClassNameFromParamInfoConsideringArrays(returntype, wscontext);
      retType = wscontext.getTypemap().getType(returntype.getSchemaName());
        if (retType != null){
        returntypeisarray = retType.isArray();
        System.out.println(retType.getLanguageSpecificName()+"LanguageName  .................... ");
        if (CUtils.isSimpleType(retType.getLanguageSpecificName())){
          returntypeissimple = true;
        }
      }
    }
    writer.write("\n/*\n");
    writer.write(" * This method wrap the service method "+ methodName +"\n");
    writer.write(" */\n");
    //method signature
    String paramTypeName;
    boolean typeisarray = false;
    boolean typeissimple = false;
    Type type;
    if (returntype == null){
      writer.write("void");
    }else{
      writer.write(outparamTypeName);
      System.out.println("Output Parameter type Name :"+outparamTypeName);
    }
    writer.write(" "+classname+"::" + methodName + "(");
    ArrayList paramsB = (ArrayList)params;
    for (int i = 0; i < paramsB.size(); i++) {
      paramTypeName = WrapperUtils.getClassNameFromParamInfoConsideringArrays((ParameterInfo)paramsB.get(i), wscontext);
      if (i>0) writer.write(", ");
      writer.write(paramTypeName+" Value"+i);
    }
    // Multiples parameters so fill the methods prototype
    ArrayList paramsC = (ArrayList)minfo.getOutputParameterTypes();
    if ( isAllTreatedAsOutParams ) {
      String currentParaTypeName;
      for (int i = 0; i < paramsC.size(); i++) {
        type = wscontext.getTypemap().getType(((ParameterInfo)paramsC.get(i)).getSchemaName());
        writer.write(", AXIS_OUT_PARAM  "+WrapperUtils.getClassNameFromParamInfoConsideringArrays((ParameterInfo)paramsC.get(i),wscontext)+" *OutValue"+i);
      }
    }
    writer.write(")\n{\n");
    if (returntype != null){
      writer.write("\t");
      if(returntypeisarray){
        //for arrays
        writer.write(outparamTypeName+" RetArray = {NULL, 0};\n");
      }else if(!returntypeissimple){
        writer.write(outparamTypeName+" pReturn = NULL;\n");
        //for complex types
      }else{
        //for simple types
        writer.write(outparamTypeName+" Ret;\n");
        //TODO initialize return parameter appropriately.
      }
    }
    String channelSecurityType = (WrapperConstants.CHANNEL_SECURITY_SSL.equals(wscontext.getWrapInfo().getChannelSecurity()))?
                    "SSL_CHANNEL" : "NORMAL_CHANNEL";

    //writer.write("\tchar* cFaultcode;\n");
    //writer.write("\tchar* cFaultstring;\n");
    //writer.write("\tchar* cFaultactor;\n");
    writer.write("\tconst char* pcCmplxFaultName;\n");
    writer.write("\ttry\n\t{");       
    writer.write("\n\t\tif (AXIS_SUCCESS != m_pCall->initialize(CPP_RPC_PROVIDER, "+channelSecurityType +")) \n\t\t\treturn ");//damitha
    if (returntype != null){
      writer.write((returntypeisarray?"RetArray":returntypeissimple?"Ret":"pReturn")+";\n");
    }
    else{
      writer.write(";\n");
    }
    writer.write("\t\tm_pCall->setTransportProperty(SOAPACTION_HEADER , \""+minfo.getSoapAction()+"\");\n");
    writer.write("\t\tm_pCall->setSOAPVersion(SOAP_VER_1_1);\n"); //TODO check which version is it really.
    writer.write("\t\tm_pCall->setOperation(\""+minfo.getMethodname()+"\", \""+wscontext.getWrapInfo().getTargetNameSpaceOfWSDL()+"\");\n");
    writer.write("\t\tapplyUserPreferences();\n");
    for (int i = 0; i < paramsB.size(); i++) {
      type = wscontext.getTypemap().getType(((ParameterInfo)paramsB.get(i)).getSchemaName());
      if (type != null){
        paramTypeName = type.getLanguageSpecificName();
        typeisarray = type.isArray();
      }
      else {
        paramTypeName = ((ParameterInfo)paramsB.get(i)).getLangName();
        typeisarray = false;
      }
      typeissimple = CUtils.isSimpleType(paramTypeName);
      if(typeisarray){
        //arrays
        QName qname = WrapperUtils.getArrayType(type).getName();
        String containedType = null;
        if (CUtils.isSimpleType(qname)){
          containedType = CUtils.getclass4qname(qname);
          writer.write("\tm_pCall->addBasicArrayParameter(");     
          writer.write("(Axis_Array*)(&Value"+i+"), "+CUtils.getXSDTypeForBasicType(containedType)+", \""+((ParameterInfo)paramsB.get(i)).getParamName()+"\"");         
        }
        else{
          containedType = qname.getLocalPart();
          writer.write("\tm_pCall->addCmplxArrayParameter(");     
          writer.write("(Axis_Array*)(&Value"+i+"), (void*)Axis_Serialize_"+containedType+", (void*)Axis_Delete_"+containedType+", (void*) Axis_GetSize_"+containedType+", \""+((ParameterInfo)paramsB.get(i)).getParamName()+"\", Axis_URI_"+containedType);
        }
      }else if(typeissimple){
        //for simple types 
        writer.write("\t\tm_pCall->addParameter(");     
        writer.write("(void*)&Value"+i+", \"" + ((ParameterInfo)paramsB.get(i)).getParamName()+"\", "+CUtils.getXSDTypeForBasicType(paramTypeName));
      }else{
        //for complex types
        writer.write("\tm_pCall->addCmplxParameter(");     
        writer.write("Value"+i+", (void*)Axis_Serialize_"+paramTypeName+", (void*)Axis_Delete_"+paramTypeName+", \"" + ((ParameterInfo)paramsB.get(i)).getParamName()+"\", Axis_URI_"+paramTypeName);
      }
      writer.write(");\n");
    }
    writer.write("\t\tif (AXIS_SUCCESS == m_pCall->invoke())\n\t\t{\n");
    writer.write("\t\t\tif(AXIS_SUCCESS == m_pCall->checkMessage(\""+minfo.getOutputMessage().getLocalPart()+"\", \""+wscontext.getWrapInfo().getTargetNameSpaceOfWSDL()+"\"))\n\t\t\t{\n");
       
    if ( isAllTreatedAsOutParams) {
      String currentParamName;
      String currentParaType;
      for (int i = 0; i < paramsC.size(); i++) {
        ParameterInfo currentType = (ParameterInfo)paramsC.get(i);
        type = wscontext.getTypemap().getType(currentType.getSchemaName());
        if (type != null){
          currentParaType = type.getLanguageSpecificName();
          typeisarray = type.isArray();
        }
        else {
          currentParaType = ((ParameterInfo)paramsC.get(i)).getLangName();
          typeisarray = false;
        }
View Full Code Here

   */
  protected void writeGlobalCodes() throws WrapperFault {
    Iterator types = wscontext.getTypemap().getTypes().iterator();
    HashSet typeSet = new HashSet();
    String typeName;
    Type type;
    try {
      while(types.hasNext()){
        type = (Type)types.next();
        if (type.isArray()) continue;
        typeName = type.getLanguageSpecificName();
        if (typeName.startsWith(">")) continue;
        typeSet.add(typeName);
      }
      Iterator itr = typeSet.iterator();
      while(itr.hasNext())
View Full Code Here

  /* (non-Javadoc)
   * @see org.apache.axis.wsdl.wsdl2ws.cpp.BasicFileWriter#writePreprocssorStatements()
   */
  protected void writePreprocssorStatements() throws WrapperFault {
    try{
    Type atype;
    Iterator types = this.wscontext.getTypemap().getTypes().iterator();
    writer.write("#include <axis/server/AxisUserAPI.h>\n\n");
    HashSet typeSet = new HashSet();
    for (int i=0;i<attribs.length; i++)
    {
View Full Code Here

  /* (non-Javadoc)
   * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writePreprocssorStatements()
   */
  protected void writePreprocssorStatements() throws WrapperFault {
    try{
      Type atype;
      Iterator types = this.wscontext.getTypemap().getTypes().iterator();
      HashSet typeSet = new HashSet();
      writer.write("#include <axis/server/AxisUserAPI.h>\n");
      writer.write("#include \"AxisServiceException.h\" \n\n");
      String typeName = null;
      while(types.hasNext()){
        atype = (Type)types.next();
        if (atype.getLanguageSpecificName().startsWith(">")) continue;
        typeName = WrapperUtils.getLanguageTypeName4Type(atype);
        if (null != typeName) typeSet.add(typeName);

      }   
      Iterator itr = typeSet.iterator();
View Full Code Here

TOP

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

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.