Esempio n. 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <param name="type"></param>
 /// <param name="soapAction"></param>
 /// <param name="parameters"></param>
 public Function(string name, HWSType hwsType, string soapAction, ArrayList parameters)
 {
     this.Name       = name;
     this.HWSType    = hwsType;
     this.SoapAction = soapAction;
     this.Parameters = parameters;
 }
Esempio n. 2
0
        private static String MakeFunctionResult(Function function)
        {
            String indent = "\n" + TAB;
            String result = indent + "return ";

            HWSType hwsType = function.HWSType;

            if (hwsType is HWSPrimitiveType &&
                ((HWSPrimitiveType)hwsType).Type.Equals(typeof(void)))
            {
                result += "()";
            }
            else
            {
                result += "$ " + hwsType.HaskellReturnCode + " strResult";
            }
            return(result);
        }
Esempio n. 3
0
        public static string MakeDataTypeParameterDefinition(DataType dt, int index)
        {
            Parameter     p        = dt.Parameters[index] as Parameter;
            StringBuilder sbuilder = new StringBuilder();

            sbuilder.Append(IdentLevel(3));
            sbuilder.Append(LowerFirstChar(dt.Name) + UpperFirstChar(p.Name));
            sbuilder.Append(" = ");



            HWSType hwsType = p.HWSType;

            sbuilder.Append(hwsType.HaskellReturnCode);
            sbuilder.Append(" $ ");
            sbuilder.Append("headStr $ getNodeValues str \"" + p.Name + "\"");

            return(sbuilder.ToString());
        }
Esempio n. 4
0
 public Parameter(string name, HWSType hwsType)
 {
     this.Name    = name;
     this.HWSType = hwsType;
 }
Esempio n. 5
0
        /// <summary>
        /// Converte uma string em formato wsdl em um tipo basico da linguagem
        /// ex: "s:string" -> string
        /// </summary>
        /// <param name="stringType">tipo em formato string</param>
        /// <returns>tipo convertido</returns>
        private HWSType ConvertType(string stringType)
        {
            HWSType result = null;

            stringType = stringType.Substring(stringType.IndexOf(":") + 1);

            switch (stringType)
            {
            case "int":
                result = new HWSPrimitiveType(typeof(int));
                break;

            case "double":
                result = new HWSPrimitiveType(typeof(double));
                break;

            case "long":
                result = new HWSPrimitiveType(typeof(long));
                break;

            case "string":
                result = new HWSPrimitiveType(typeof(string));
                break;

            case "char":
                result = new HWSPrimitiveType(typeof(char));
                break;

            case "float":
                result = new HWSPrimitiveType(typeof(float));
                break;

            case "void":
                result = new HWSPrimitiveType(typeof(void));
                break;

            case "boolean":
                result = new HWSPrimitiveType(typeof(bool));
                break;

            case "base64Binary":                     //TODO: interpret this value correctly
                result = new HWSPrimitiveType(typeof(string));
                break;

            default:
                bool found = false;
                foreach (Enumeration en in this.enumerations)
                {
                    if (stringType.Equals(en.Name))
                    {
                        result = new HWSEnumType(stringType);
                        found  = true;
                        break;
                    }
                }

                foreach (DataType data in this.dataTypes)
                {
                    if (stringType.Equals(data.Name))
                    {
                        bool hasParameters = data.Parameters.Count > 0;
                        result = new HWSDataTypeType(stringType, hasParameters);
                        found  = true;
                        break;
                    }
                }

                foreach (HWSListType listType in this.listTypes)
                {
                    if (stringType.Equals(listType.Name))
                    {
                        result = listType;
                        found  = true;
                        break;
                    }
                }

                if (!found)
                {
                    throw new TypeNotSupportedException(stringType);
                }
                break;
            }
            return(result);
        }
Esempio n. 6
0
        /// <summary>
        /// Monta as funcoes do servico
        /// </summary>
        /// <param name="servDesc">descricao do servico</param>
        private void MountFunctions(ServiceDescription servDesc)
        {
            string  funName    = "";
            HWSType returnType = null;

            foreach (PortType port in servDesc.PortTypes)
            {
                foreach (Operation op in port.Operations)
                {
                    ArrayList parameters = new ArrayList();
                    funName = op.Name;

                    //mensagem que descreve as entradas da operacao
                    Message msgIn = servDesc.Messages[op.Messages.Input.Message.Name];

                    foreach (MessagePart part in msgIn.Parts)
                    {
                        //se for um element (padrao VS), o tipo da funcao
                        //esta' definido junto aos complex types
                        if (part.Element != null && !part.Element.IsEmpty)
                        {
                            //busca entre as definicoes dos types
                            foreach (XmlSchema s in servDesc.Types.Schemas)
                            {
                                for (int i = 0; i < s.Items.Count; ++i)
                                {
                                    if (s.Items[i].GetType().Equals(typeof(XmlSchemaElement)))
                                    {
                                        XmlSchemaElement e = (XmlSchemaElement)s.Items[i];

                                        if (e.Name.Equals(part.Element.Name))
                                        {
                                            XmlSchemaSequence seq = (XmlSchemaSequence)((XmlSchemaComplexType)e.SchemaType).Particle;

                                            if (seq != null)
                                            {
                                                foreach (XmlSchemaElement param in seq.Items)
                                                {
                                                    Parameter p = new Parameter();
                                                    p.Name    = param.Name;
                                                    p.HWSType = ConvertType(param.SchemaTypeName.Name);
                                                    parameters.Add(p);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        //para os tipos definidos diretamente na mensagem
                        else
                        {
                            Parameter p = new Parameter();
                            p.Name    = part.Name;
                            p.HWSType = ConvertType(part.Type.Name);
                            parameters.Add(p);
                        }
                    }

                    //mensagem que descreve o retorno da operacao
                    Message msgOut = servDesc.Messages[op.Messages.Output.Message.Name];

                    foreach (MessagePart part in msgOut.Parts)
                    {
                        //se for um element (padrao VS), o tipo da funcao
                        //esta' definido junto aos complex types
                        if (part.Element != null && !part.Element.IsEmpty)
                        {
                            //busca entre as definicoes dos types
                            foreach (XmlSchema s in servDesc.Types.Schemas)
                            {
                                for (int i = 0; i < s.Items.Count; ++i)
                                {
                                    if (s.Items[i].GetType().Equals(typeof(XmlSchemaElement)))
                                    {
                                        XmlSchemaElement e = (XmlSchemaElement)s.Items[i];

                                        if (e.Name.Equals(part.Element.Name))
                                        {
                                            XmlSchemaComplexType seq         = (XmlSchemaComplexType)e.SchemaType;
                                            XmlSchemaSequence    seqParticle = null;
                                            if (seq != null)
                                            {
                                                seqParticle = (XmlSchemaSequence)seq.Particle;
                                            }


                                            if (seqParticle != null)
                                            {
                                                //sempre havera' apenas 1 elemento, afinal, e' o tipo de retorno
                                                foreach (XmlSchemaElement param in seqParticle.Items)
                                                {
                                                    returnType = ConvertType(param.SchemaTypeName.Name);
                                                }
                                            }
                                            else
                                            {
                                                returnType = new HWSPrimitiveType(typeof(void));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        //para os tipos definidos diretamente na mensagem
                        else
                        {
                            returnType = ConvertType(part.Type.Name);
                        }
                    }

                    Function function = new Function(funName, returnType, null, parameters);

                    if (SetSoapActionInFunction(servDesc, function))
                    {
                        this.functions.Add(function);
                    }
                }
            }
        }