Esempio n. 1
0
        public string Create(SoapClasses soapClass, WebServices webService)
        {
            StringBuilder strgetter = new StringBuilder();
            StringBuilder str       = new StringBuilder();

            str.AppendFormat("package {0};", webService.PackageName).AppendLine().AppendLine();
            str.AppendLine("import java.util.Date;").AppendLine("import java.math.BigDecimal;").AppendLine();
            str.AppendLine(string.Concat("public class ", soapClass.Name, " {")).AppendLine();

            str.AppendFormat("    public {0}(){1}", soapClass.Name, "{}").AppendLine();

            for (int i = 0; i < soapClass.Properties.Count; i++)
            {
                SoapClassProperties property = soapClass.Properties[i];
                if (property.IsEnum)
                {
                    str.AppendFormat("    private String _{0} = {1}; //Enum {2}", property.Name, JavaTypeConverter.InitialToJavaType(property), property.PropertyClassType).AppendLine();

                    strgetter.AppendFormat("     public String get{0}() {1}", property.Name, "{").AppendLine();
                    strgetter.AppendFormat("        return _{0};", property.Name).AppendLine();
                    strgetter.AppendLine("    }").AppendLine();

                    strgetter.AppendFormat("    public void set{0}(String improvable) {1}", property.Name, "{").AppendLine();
                    strgetter.AppendFormat("        this._{0} = improvable;", property.Name).AppendLine();
                    strgetter.AppendLine("    }").AppendLine();
                }
                else if (property.IsArray)
                {
                    str.AppendFormat("    private {0} _{1} = {2}; //array\n", property.PropertyClassType, property.Name, JavaTypeConverter.InitialToJavaType(property)).AppendLine();

                    strgetter.AppendFormat("     public String get{0}() {1}", property.Name, "{").AppendLine();
                    strgetter.AppendFormat("        return _{0};", property.Name).AppendLine();
                    strgetter.AppendLine("    }").AppendLine();

                    strgetter.AppendFormat("    public void set{0}({1} improvable) {2}", property.Name, property.PropertyClassType, "{").AppendLine();
                    strgetter.AppendFormat("        this._{0} = improvable;", property.Name).AppendLine();
                    strgetter.AppendLine("    }").AppendLine();
                }
                else
                {
                    str.AppendFormat("    private {0} _{1} = {2};\n", property.PropertyClassType, property.Name, JavaTypeConverter.InitialToJavaType(property)).AppendLine();

                    strgetter.AppendFormat("     public {0} get{1}() {2}", property.PropertyClassType, property.Name, "{").AppendLine();
                    strgetter.AppendFormat("        return _{0};", property.Name).AppendLine();
                    strgetter.AppendLine("    }").AppendLine();

                    strgetter.AppendFormat("    public void set{0}({1} improvable) {2}", property.Name, property.PropertyClassType, "{").AppendLine();
                    strgetter.AppendFormat("        this._{0} = improvable;", property.Name).AppendLine();
                    strgetter.AppendLine("    }").AppendLine();
                }
            }

            str.Append(strgetter.ToString());


            str.AppendLine("}");
            return(str.ToString());
        }
Esempio n. 2
0
        private void CreateComplexClass(SoapClasses complexClass)
        {
            if (complexClasses.Contains(complexClass.Name))
            {
                return;
            }

            if (complexClass.IsEnum)
            {
                CreateEnum(complexClass);
                return;
            }
            else if (complexClass.IsArray)
            {
                CreateArrayClass(complexClass);
                return;
            }

            StringBuilder propText   = new StringBuilder();
            StringBuilder propinfstr = new StringBuilder();
            StringBuilder setpropstr = new StringBuilder();
            StringBuilder getpropstr = new StringBuilder();
            string        complexstr = FileHelper.GetManifestResourceStream("SoapComplexTypeClassTemplate");

            complexstr = complexstr.Replace("%%DATE%%", DateTime.Now.ToString()).Replace("%%PACKAGENAME%%", WebService.PackageName);
            complexstr = complexstr.Replace("%%CLASSNAME%%", complexClass.Name).Replace("%%PROPCOUNT%%", complexClass.Properties.Count.ToString());

            for (int i = 0; i < complexClass.Properties.Count; i++)
            {
                SoapClassProperties property = complexClass.Properties[i];

                propinfstr.AppendFormat("           case {0}:", i).AppendLine();
                propinfstr.AppendFormat("                info.name = \"{0}\";", property.Name).AppendLine();
                propinfstr.AppendFormat("                info.type = {0};", JavaTypeConverter.ClassTypeRetrievalString(property)).AppendLine();
                propinfstr.AppendLine("                break;");

                getpropstr.AppendFormat("           case {0}:", i).AppendLine();
                getpropstr.AppendFormat("                return {0};", property.Name).AppendLine();

                setpropstr.AppendFormat("           case {0}:", i).AppendLine();
                setpropstr.AppendLine("                if (value.toString().equalsIgnoreCase(\"anyType{}\")) {");
                setpropstr.AppendFormat("                    {0} = {1};", property.Name, JavaTypeConverter.InitialToJavaType(property)).AppendLine("                }");
                setpropstr.AppendLine("                else {");

                if (property.IsEnum)
                {
                    propText.AppendFormat("     public String {0} = {1}; //Enum {2}", property.Name, JavaTypeConverter.InitialToJavaType(property), property.PropertyClassType);
                    setpropstr.AppendFormat("                    {0} = value.toString();", property.Name).AppendLine();
                }
                else if (property.IsArray)
                {
                    propText.AppendFormat("     public {0} {1} = {2}; //array\n", property.PropertyClassType, property.Name, JavaTypeConverter.InitialToJavaType(property));
                    setpropstr.AppendFormat("                  {0} = {1};", property.Name, JavaTypeConverter.InitialToJavaType(property)).AppendLine();
                    setpropstr.AppendFormat("                  SoapObject prp = (SoapObject)value; ").AppendLine();
                    setpropstr.AppendFormat("                  {0}.loadSoapObject(prp); ", property.Name).AppendLine();
                }
                else
                {
                    propText.AppendFormat("     public {0} {1} = {2};\n", property.PropertyClassType, property.Name, JavaTypeConverter.InitialToJavaType(property));
                    if (property.IsComplexType)
                    {
                        setpropstr.AppendFormat("	                {0} = new {1}(); ", property.Name, property.PropertyClassType).AppendLine();
                        setpropstr.AppendFormat("                    {0}.loadSoapObject((SoapObject) value);", property.Name).AppendLine();
                    }
                    else
                    {
                        setpropstr.AppendFormat("	                {0} = {1}; ", property.Name, JavaTypeConverter.ConvertorForJavaType(property)).AppendLine();
                    }
                }

                setpropstr.AppendLine("                }").AppendLine("                break;");

                if (property.IsComplexType)
                {
                    SoapClasses _complexClass = WebService.SoapClasses.Where(x => x.Name == property.PropertyClassType).FirstOrDefault();
                    if (_complexClass != null)
                    {
                        CreateComplexClass(_complexClass);
                    }
                }
            }

            complexstr = complexstr.Replace("%%PROPERTIES%%", propText.ToString()).Replace("%%GETPROPERTY%%", getpropstr.ToString());
            complexstr = complexstr.Replace("%%SETPROP%%", setpropstr.ToString()).Replace("%%GETPROPINFO%%", propinfstr.ToString());


            using (FileHelper file = new FileHelper(string.Concat(ProjectFolder, complexClass.Name, ".java")))
            {
                file.WriteLine(complexstr.ToString());
                file.Close();
            }
            Utility.WriteTrace(string.Format("{0}.java Oluşturuldu", complexClass.Name));
            complexClasses.Add(complexClass.Name);

            complexClass.Output = true;
            complexClass.Save();
        }
Esempio n. 3
0
        private void CreateArrayClass(SoapClasses arrClass)
        {
            try
            {
                string arraystr = FileHelper.GetManifestResourceStream("ArrayObjectTemplate");
                arraystr = arraystr.Replace("%%DATE%%", DateTime.Now.ToString()).Replace("%%PACKAGENAME%%", WebService.PackageName);
                arraystr = arraystr.Replace("%%NAMESPACE%%", WebService.NameSpace).Replace("%%CLASSNAME%%", arrClass.Name);
                arraystr = arraystr.Replace("%%ELEMENTTYPE%%", JavaTypeConverter.ToElementJavaType(arrClass.ElementType)).Replace("%%ELEMENTTYPEDESC%%", JavaTypeConverter.ArrayElementTypeDesc(arrClass.ElementType));

                StringBuilder loadstr = new StringBuilder();
                if (arrClass.ElementType == "char")
                {
                    loadstr.AppendLine("                if (property.getProperty(loop) instanceof SoapPrimitive) {");
                    loadstr.AppendLine("                    SoapPrimitive pi = (SoapPrimitive) property.getProperty(loop);");
                    loadstr.AppendLine("                    int intchar = Integer.valueOf(pi.toString());");
                    loadstr.AppendLine("                    this.add((char) intchar);");
                    loadstr.AppendLine("                }");
                }
                else if (arrClass.ElementType == "Integer")
                {
                    loadstr.AppendLine("                if (property.getProperty(loop) instanceof SoapPrimitive) {");
                    loadstr.AppendLine("                    SoapPrimitive pi = (SoapPrimitive) property.getProperty(loop);");
                    loadstr.AppendLine("                    Integer item = Integer.valueOf(pi.toString());");
                    loadstr.AppendLine("                    this.add(item);");
                    loadstr.AppendLine("                }");
                }
                else if (arrClass.ElementType == "String")
                {
                    loadstr.AppendLine("                if (property.getProperty(loop) instanceof SoapPrimitive) {");
                    loadstr.AppendLine("                    SoapPrimitive pi = (SoapPrimitive) property.getProperty(loop);");
                    loadstr.AppendLine("                    String item = pi.toString();");
                    loadstr.AppendLine("                    this.add(item);");
                    loadstr.AppendLine("                }");
                }
                else if (arrClass.ElementType == "BigDecimal")
                {
                    loadstr.AppendLine("                if (property.getProperty(loop) instanceof SoapPrimitive) {");
                    loadstr.AppendLine("                    SoapPrimitive pi = (SoapPrimitive) property.getProperty(loop);");
                    loadstr.AppendLine("                    BigDecimal item = BigDecimal.valueOf(Double.parseDouble(pi.toString()));");
                    loadstr.AppendLine("                    this.add(item);");
                    loadstr.AppendLine("                }");
                }
                else if (arrClass.ElementType == "Object")
                {
                    loadstr.AppendLine("                if (property.getProperty(loop) != null) {");
                    loadstr.AppendLine("                    this.add((Object) property.getProperty(loop));");
                    loadstr.AppendLine("                }");
                }
                else
                {
                    loadstr.AppendLine("                if (property.getProperty(loop) instanceof SoapObject) {");
                    loadstr.AppendLine("                    SoapObject so = (SoapObject) property.getProperty(loop);");
                    loadstr.AppendFormat("                  {0} item = new {0}(); \n", arrClass.ElementType);
                    loadstr.AppendLine("                    item.loadSoapObject(so);");
                    loadstr.AppendLine("                    this.add(item);");
                    loadstr.AppendLine("                }");

                    SoapClasses elementClass = WebService.SoapClasses.Where(x => x.Name == arrClass.ElementType).FirstOrDefault();
                    if (elementClass != null)
                    {
                        CreateComplexClass(elementClass);
                    }
                }

                arraystr = arraystr.Replace("%%LOADSOAPOBJECTS%%", loadstr.ToString());

                using (FileHelper file = new FileHelper(string.Concat(ProjectFolder, arrClass.Name, ".java")))
                {
                    file.Write(arraystr);
                }
                Utility.WriteTrace(string.Format("{0}.java Oluşturuldu", arrClass.Name));
                complexClasses.Add(arrClass.Name);
            }
            catch (Exception exc)
            {
                Utility.Hata(exc);
            }
        }
Esempio n. 4
0
        private string CreateMethods()
        {
            string        methodstrorj = FileHelper.GetManifestResourceStream("MethodTemplate");
            StringBuilder strmethods   = new StringBuilder();
            var           functions    = WebService.Functions.Where(x => x.Output == true).ToList();

            for (int loop = 0; loop < functions.Count; loop++)
            {
                keysRegister    = new List <string>();
                registerStrings = new StringBuilder();

                var    webfunc   = functions[loop];
                string methodstr = methodstrorj.Replace("%%METHODNAME%%", webfunc.Name).Replace("%%OUTPUT%%", webfunc.OutputType).Replace("%%INPUT%%", webfunc.InputType);

                SoapClasses paramClass = WebService.SoapClasses.Where(x => x.Name == webfunc.InputType).FirstOrDefault();

                #region InputClass
                if (paramClass != null)
                {
                    StringBuilder propText    = new StringBuilder();
                    StringBuilder propinfstr  = new StringBuilder();
                    StringBuilder setpropstr  = new StringBuilder();
                    StringBuilder getpropstr  = new StringBuilder();
                    StringBuilder soappropstr = new StringBuilder();
                    string        paramstr    = FileHelper.GetManifestResourceStream("ParameterClassTemplate");
                    paramstr = paramstr.Replace("%%DATE%%", DateTime.Now.ToString()).Replace("%%PACKAGENAME%%", WebService.PackageName);
                    paramstr = paramstr.Replace("%%CLASSNAME%%", paramClass.Name).Replace("%%SOAPMETHODNAME%%", webfunc.Name);
                    paramstr = paramstr.Replace("%%NAMESPACE%%", WebService.NameSpace).Replace("%%SOAPMETHODNAME%%", webfunc.Name);
                    paramstr = paramstr.Replace("%%PROPCOUNT%%", paramClass.Properties.Count.ToString());

                    webfunc.RegisterClasses = paramClass.Name;
                    keysRegister.Add(paramClass.Name);
                    registerStrings.AppendLine(paramClass.RegisterText);
                    GetRegisterClasses(paramClass, webfunc);
                    CreateComplexClass(paramClass);

                    for (int i = 0; i < paramClass.Properties.Count; i++)
                    {
                        SoapClassProperties property = paramClass.Properties[i];

                        soappropstr.AppendFormat("\t\tPropertyInfo p{0} = new PropertyInfo();", i).AppendLine();
                        soappropstr.AppendFormat("\t\tp{1}.setName(\"{0}\");", property.Name, i).AppendLine();
                        soappropstr.AppendFormat("\t\tp{1}.setValue({0});", property.Name, i).AppendLine();
                        soappropstr.AppendFormat("\t\tp{1}.setType({0}.class);", property.PropertyClassType, i);
                        soappropstr.AppendFormat("\t\tp{0}.setNamespace(NAMESPACE);", i).AppendLine();
                        soappropstr.AppendFormat("\t\trequest.addProperty(p{0});", i).AppendLine().AppendLine();

                        propinfstr.AppendFormat("           case {0}:", i).AppendLine();
                        propinfstr.AppendFormat("                info.name = \"{0}\";", property.Name).AppendLine();
                        propinfstr.AppendFormat("                info.type = {0};", JavaTypeConverter.ClassTypeRetrievalString(property)).AppendLine();
                        propinfstr.AppendLine("                break;");

                        getpropstr.AppendFormat("           case {0}:", i).AppendLine();
                        getpropstr.AppendFormat("                return {0};", property.Name).AppendLine();

                        setpropstr.AppendFormat("           case {0}:", i).AppendLine();
                        setpropstr.AppendLine("                if (value.toString().equalsIgnoreCase(\"anyType{}\")) {");
                        setpropstr.AppendFormat("                    {0} = {1};", property.Name, JavaTypeConverter.InitialToJavaType(property)).AppendLine("                }");
                        setpropstr.AppendLine("                else {");

                        if (property.IsEnum)
                        {
                            propText.AppendFormat("     public String {0} = {1}; //Enum {2}", property.Name, JavaTypeConverter.InitialToJavaType(property), property.PropertyClassType);
                            setpropstr.AppendFormat("                    {0} = value.toString();", property.Name).AppendLine();
                        }
                        else if (property.IsArray)
                        {
                            setpropstr.AppendFormat("                  {0} = {1};", property.Name, JavaTypeConverter.InitialToJavaType(property)).AppendLine();
                            setpropstr.AppendFormat("                  SoapObject prp = (SoapObject)value; ").AppendLine();
                            setpropstr.AppendFormat("                  {0}.loadSoapObject(prp); ", property.Name).AppendLine();
                        }
                        else
                        {
                            propText.AppendFormat("     public {0} {1} = {2};\n", property.PropertyClassType, property.Name, JavaTypeConverter.InitialToJavaType(property));
                            setpropstr.AppendFormat("	                {0} = {1}; ", property.Name, JavaTypeConverter.ConvertorForJavaType(property)).AppendLine();
                        }

                        if (property.IsComplexType)
                        {
                            SoapClasses complexClass = WebService.SoapClasses.Where(x => x.Name == property.PropertyClassType).FirstOrDefault();
                            if (complexClass != null)
                            {
                                if (complexClass != null && !complexClass.IsEnum && !keysRegister.Contains(complexClass.Name))
                                {
                                    complexClass.Output = true;
                                    complexClass.Save();
                                    webfunc.RegisterClasses = string.Format("{0};{1}", webfunc.RegisterClasses, complexClass.Name);
                                    webfunc.Save();
                                    keysRegister.Add(complexClass.Name);
                                    registerStrings.AppendLine(complexClass.RegisterText);
                                    GetRegisterClasses(complexClass, webfunc);
                                }

                                CreateComplexClass(complexClass);
                            }
                        }

                        setpropstr.AppendLine("                }").AppendLine("                break;");
                    }

                    paramstr = paramstr.Replace("%%PROPERTIES%%", propText.ToString()).Replace("%%GETPROPERTY%%", getpropstr.ToString());
                    paramstr = paramstr.Replace("%%SETPROP%%", setpropstr.ToString()).Replace("%%GETPROPINFO%%", propinfstr.ToString());
                    paramstr = paramstr.Replace("%%SOAPPROPERTIES%%", soappropstr.ToString());


                    using (FileHelper file = new FileHelper(string.Concat(ProjectFolder, paramClass.Name, ".java")))
                    {
                        file.Write(paramstr);
                        file.Close();
                    }

                    Utility.WriteTrace(string.Format("{0}.java Oluşturuldu", paramClass.Name));
                    complexClasses.Add(paramClass.Name);

                    paramClass.Output = true;
                    paramClass.Save();
                }
                #endregion

                #region ReturnClass
                SoapClasses returnClass = WebService.SoapClasses.Where(x => x.Name == webfunc.OutputType).FirstOrDefault();

                if (returnClass != null)
                {
                    StringBuilder propinfstr = new StringBuilder();
                    StringBuilder setpropstr = new StringBuilder();
                    StringBuilder getpropstr = new StringBuilder();
                    StringBuilder propText   = new StringBuilder();
                    string        returnstr  = FileHelper.GetManifestResourceStream("ResponseTemplate");
                    returnstr = returnstr.Replace("%%DATE%%", DateTime.Now.ToString()).Replace("%%PACKAGENAME%%", WebService.PackageName);
                    returnstr = returnstr.Replace("%%CLASSNAME%%", returnClass.Name);
                    returnstr = returnstr.Replace("%%PROPCOUNT%%", returnClass.Properties.Count.ToString());


                    if (returnClass.Properties.Count > 0)
                    {
                        SoapClassProperties property = returnClass.Properties[0];


                        returnstr = returnstr.Replace("%%RESULTPROPNAME%%", property.Name);
                        returnstr = returnstr.Replace("%%RESULTPROPTYPE%%", property.PropertyClassType);
                        returnstr = returnstr.Replace("%%GETPROPINFO%%", JavaTypeConverter.ClassTypeRetrievalString(property));
                        returnstr = returnstr.Replace("%%RESULTPROPTYPE%%", property.PropertyClassType);
                        returnstr = returnstr.Replace("%%SETPROP%%", JavaTypeConverter.ConvertorForJavaType(property));

                        if (property.IsComplexType)
                        {
                            SoapClasses complexClass = WebService.SoapClasses.Where(x => x.Name == property.PropertyClassType).FirstOrDefault();
                            if (complexClass != null)
                            {
                                CreateComplexClass(complexClass);
                            }

                            StringBuilder loadobjstr = new StringBuilder();
                            loadobjstr.AppendFormat("		{0} = new {1}();", property.Name, property.PropertyClassType).AppendLine();
                            loadobjstr.AppendFormat("		{0}.loadSoapObject(property);", property.Name).AppendLine();
                            returnstr = returnstr.Replace("%%LOADSOAPOBJECT%%", loadobjstr.ToString());
                        }
                        else
                        {
                            returnstr = returnstr.Replace("%%LOADSOAPOBJECT%%", "");
                        }
                    }
                    else
                    {
                        returnstr = returnstr.Replace("%%RESULTPROPNAME%%", "");
                        returnstr = returnstr.Replace("%%RESULTPROPTYPE%%", "");
                        returnstr = returnstr.Replace("%%GETPROPINFO%%", "");
                        returnstr = returnstr.Replace("%%RESULTPROPNAME%%", "").Replace("%%GETPROPINFO%%", "");
                        returnstr = returnstr.Replace("%%RESULTPROPTYPE%%", "");
                    }

                    methodstr = methodstr.Replace("%%REGISTERCLASS%%", registerStrings.ToString());
                    strmethods.Append(methodstr);

                    using (FileHelper file = new FileHelper(string.Concat(ProjectFolder, returnClass.Name, ".java")))
                    {
                        file.Write(returnstr);
                        file.Close();
                    }
                    Utility.WriteTrace(string.Format("{0}.java Oluşturuldu", returnClass.Name));
                    complexClasses.Add(returnClass.Name);

                    returnClass.Output = true;
                    returnClass.Save();
                }
                #endregion
            }

            return(strmethods.ToString());
        }
Esempio n. 5
0
        public void Parse()
        {
            UriBuilder uriBuilder = new UriBuilder(webserv.Url);

            uriBuilder.Query = "WSDL";
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uriBuilder.Uri);

            webRequest.ContentType = "text/xml;charset=\"utf-8\"";
            webRequest.Method      = "GET";
            webRequest.Accept      = "text/xml";

            ServiceDescription serviceDescription;

            using (WebResponse response = webRequest.GetResponse())
            {
                using (Stream stream = response.GetResponseStream())
                {
                    serviceDescription = ServiceDescription.Read(stream);
                }
            }

            var oldfuncs = (from q in new XPQuery <WebFunctions>(XpoDefault.Session)
                            where q.Service.Oid == webserv.Oid
                            select q).ToList();



            if (serviceDescription != null && serviceDescription.Services.Count > 0)
            {
                ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
                importer.ProtocolName = "Soap11";
                importer.AddServiceDescription(serviceDescription, null, null);
                importer.Style = ServiceDescriptionImportStyle.Client;
                importer.CodeGenerationOptions = CodeGenerationOptions.GenerateProperties;

                Service service = serviceDescription.Services[0];

                this.Namespace   = serviceDescription.TargetNamespace;
                this.ServiceName = service.Name;

                webserv.ServiceName = service.Name;
                webserv.NameSpace   = serviceDescription.TargetNamespace;
                webserv.UpdateDate  = DateTime.Now;

                for (int i = webserv.SoapClasses.Count - 1; i >= 0; i--)
                {
                    webserv.SoapClasses[i].Delete();
                }

                #region Operation
                List <string> operationNames = new List <string>();
                //Loop through the port types in the service description and list all of the
                //web service's operations and each operations input/output

                PortType portType = serviceDescription.PortTypes[0];
                //foreach (PortType portType in serviceDescription.PortTypes)
                {
                    int FunctionIndex = 0;
                    this.Functions = new List <WebFunctions>();
                    foreach (Operation operation in portType.Operations)
                    {
                        WebFunctions newFunc = new WebFunctions();
                        newFunc.Service = webserv;
                        var oldfunc = oldfuncs.Where(x => x.Name == operation.Name).FirstOrDefault();
                        if (oldfunc != null)
                        {
                            newFunc.Output = oldfunc.Output;
                        }
                        newFunc.Name       = operation.Name;
                        newFunc.SoapAction = this.Namespace + operation.Name;
                        operationNames.Add(operation.Name);

                        foreach (var message in operation.Messages)
                        {
                            if (message is OperationInput)
                            {
                                foreach (Message messagePart in serviceDescription.Messages)
                                {
                                    if (messagePart.Name != ((OperationMessage)message).Message.Name)
                                    {
                                        continue;
                                    }

                                    foreach (MessagePart part in messagePart.Parts)
                                    {
                                        newFunc.InputType = part.Element.Name;
                                    }
                                }
                            }
                            if (message is OperationOutput)
                            {
                                foreach (Message messagePart in serviceDescription.Messages)
                                {
                                    if (messagePart.Name != ((OperationMessage)message).Message.Name)
                                    {
                                        continue;
                                    }

                                    foreach (MessagePart part in messagePart.Parts)
                                    {
                                        newFunc.OutputType = part.Element.Name;
                                    }
                                }
                            }
                        }
                        newFunc.Save();
                        this.Functions.Add(newFunc);
                        FunctionIndex++;
                    }
                } //End listing of types

                for (int i = oldfuncs.Count - 1; i >= 0; i--)
                {
                    oldfuncs[i].Delete();
                }

                #endregion

                #region Types

                Types     types     = serviceDescription.Types;
                XmlSchema xmlSchema = types.Schemas[0];

                foreach (object item in xmlSchema.Items)
                {
                    XmlSchemaComplexType _complexType  = item as System.Xml.Schema.XmlSchemaComplexType;
                    XmlSchemaElement     schemaElement = item as XmlSchemaElement;
                    XmlSchemaComplexType complexType   = item as XmlSchemaComplexType;

                    if (schemaElement != null && JavaTypeConverter.IsComplexType(schemaElement.Name))
                    {
                        SoapClasses newClass = this.GetClass(schemaElement.Name);
                        newClass.Name           = schemaElement.Name;
                        newClass.Service        = webserv;
                        newClass.Type           = ClassType.Unknown;
                        newClass.SuperClassType = string.Empty;
                        newClass.Output         = false;

                        if (_complexType != null)
                        {
                            XmlSchemaContentModel   model   = _complexType.ContentModel;
                            XmlSchemaComplexContent complex = model as XmlSchemaComplexContent;
                            if (complex != null)
                            {
                                XmlSchemaComplexContentExtension extension = complex.Content as XmlSchemaComplexContentExtension;
                                if (extension != null)
                                {
                                    newClass.SuperClassType = extension.BaseTypeName.Name;
                                }
                            }
                        }

                        XmlSchemaType        schemaType        = schemaElement.SchemaType;
                        XmlSchemaComplexType schemaComplexType = schemaType as XmlSchemaComplexType;


                        if (schemaComplexType != null)
                        {
                            XmlSchemaParticle particle = schemaComplexType.Particle;
                            XmlSchemaSequence sequence = particle as XmlSchemaSequence;
                            if (sequence != null)
                            {
                                foreach (XmlSchemaElement childElement in sequence.Items)
                                {
                                    SoapClassProperties newProp = new SoapClassProperties(XpoDefault.Session);
                                    newProp.Name = childElement.Name;

                                    newProp.PropertyClassType = childElement.SchemaTypeName.Name;
                                    newProp.IsArray           = childElement.SchemaTypeName.Name.StartsWith("ArrayOf");
                                    newClass.Properties.Add(newProp);
                                }
                            }
                        }

                        newClass.Save();
                        //this.ComplexTypes.Add(newClass);
                    }
                    else if (complexType != null)
                    {
                        OutputElements(complexType.Particle, complexType.Name);

                        if (complexType.Particle == null)
                        {
                            GetProperties(xmlSchema, complexType.Name);
                        }
                    }
                }

                #region enums
                foreach (object xItem in xmlSchema.SchemaTypes.Values)
                {
                    XmlSchemaSimpleType item2 = xItem as XmlSchemaSimpleType;
                    if (item2 != null)
                    {
                        GetEnum(xmlSchema, item2.Name);
                    }
                }
                #endregion

                #endregion
            }

            webserv.Save();
        }
Esempio n. 6
0
        private void OutputElements(XmlSchemaParticle particle, string name)
        {
            SoapClasses newClass = this.GetClass(name);

            newClass.Name    = name;
            newClass.Type    = ClassType.Unknown;
            newClass.IsArray = name.StartsWith("ArrayOf");
            newClass.Output  = false;

            XmlSchemaSequence sequence = particle as XmlSchemaSequence;
            XmlSchemaChoice   choice   = particle as XmlSchemaChoice;
            XmlSchemaAll      all      = particle as XmlSchemaAll;

            if (sequence != null)
            {
                for (int i = 0; i < sequence.Items.Count; i++)
                {
                    XmlSchemaElement  childElement  = sequence.Items[i] as XmlSchemaElement;
                    XmlSchemaSequence innerSequence = sequence.Items[i] as XmlSchemaSequence;
                    XmlSchemaChoice   innerChoice   = sequence.Items[i] as XmlSchemaChoice;
                    XmlSchemaAll      innerAll      = sequence.Items[i] as XmlSchemaAll;

                    if (childElement != null)
                    {
                        SoapClassProperties newProp = new SoapClassProperties(XpoDefault.Session);
                        newProp.Name = childElement.Name;

                        newProp.PropertyClassType = childElement.SchemaTypeName.Name;
                        newProp.IsArray           = childElement.SchemaTypeName.Name.StartsWith("ArrayOf");
                        newClass.Properties.Add(newProp);
                        newClass.ElementType = JavaTypeConverter.ToElementJavaType(childElement.SchemaTypeName.Name);
                    }
                    else
                    {
                        OutputElements(sequence.Items[i] as XmlSchemaParticle, name);
                    }
                }
            }
            else if (choice != null)
            {
                for (int i = 0; i < choice.Items.Count; i++)
                {
                    XmlSchemaElement  childElement  = choice.Items[i] as XmlSchemaElement;
                    XmlSchemaSequence innerSequence = choice.Items[i] as XmlSchemaSequence;
                    XmlSchemaChoice   innerChoice   = choice.Items[i] as XmlSchemaChoice;
                    XmlSchemaAll      innerAll      = choice.Items[i] as XmlSchemaAll;

                    if (childElement != null)
                    {
                        SoapClassProperties newProp = new SoapClassProperties(XpoDefault.Session);
                        newProp.Name = childElement.Name;
                        newProp.PropertyClassType = childElement.SchemaTypeName.Name;
                        newProp.IsArray           = childElement.SchemaTypeName.Name.StartsWith("ArrayOf");
                        newClass.Properties.Add(newProp);
                    }
                    else
                    {
                        OutputElements(choice.Items[i] as XmlSchemaParticle, name);
                    }
                }
            }
            else if (all != null)
            {
                for (int i = 0; i < all.Items.Count; i++)
                {
                    XmlSchemaElement  childElement  = all.Items[i] as XmlSchemaElement;
                    XmlSchemaSequence innerSequence = all.Items[i] as XmlSchemaSequence;
                    XmlSchemaChoice   innerChoice   = all.Items[i] as XmlSchemaChoice;
                    XmlSchemaAll      innerAll      = all.Items[i] as XmlSchemaAll;

                    if (childElement != null)
                    {
                        SoapClassProperties newProp = new SoapClassProperties(XpoDefault.Session);
                        newProp.Name = childElement.Name;

                        newProp.PropertyClassType = childElement.SchemaTypeName.Name;
                        newProp.IsArray           = childElement.SchemaTypeName.Name.StartsWith("ArrayOf");
                        newClass.Properties.Add(newProp);
                    }
                    else
                    {
                        OutputElements(all.Items[i] as XmlSchemaParticle, name);
                    }
                }
            }
            newClass.Save();
            //this.ComplexTypes.Add(newClass);
        }