public static string MakeParameter(Parameter p) { string result = ""; string parameterName = LowerFirstChar(p.Name); if (p.HWSType is HWSPrimitiveType) { HWSPrimitiveType primType = p.HWSType as HWSPrimitiveType; if (primType.Type.Equals(typeof(char))) { result = "(primitiveToStr (ord " + parameterName + "))"; } else if (primType.Type.Equals(typeof(bool))) { result = "(lowerFirstChar (primitiveToStr " + parameterName + "))"; } else { result = "(primitiveToStr " + parameterName + ")"; } } else if (p.HWSType is HWSEnumType) { result = "(show " + parameterName + ")"; } else if (p.HWSType is HWSDataTypeType) { result = "(toXml " + parameterName + ")"; } else if (p.HWSType is HWSListType) { HWSListType listType = p.HWSType as HWSListType; if (listType.Parameter.HWSType is HWSPrimitiveType) { result = "(buildPrimitiveXmlList " + parameterName + " \"" + listType.Parameter.Name + "\")"; } else { result = "(buildComplexXmlList " + parameterName + " \"" + listType.Parameter.Name + "\")"; } } else { throw new TypeNotSupportedException(p.HWSType.ToString()); } return(result); }
/// <summary> /// Varre o documento wsdl e monta os data types especificados no mesmo /// </summary> /// <param name="xmlDoc">o documento wsdl</param> /// <param name="xmlns">XmlNamespaceManager</param> /// <returns>a lista de data types</returns> private void MountComplexType(XmlSchemaComplexType complexType) //XmlDocument xmlDoc, XmlNamespaceManager xmlns) { string typeName = ""; ArrayList parameters = new ArrayList(); bool isArray = false; HWSListType listType = null; DataType dataType = null; typeName = complexType.Name; //// tipos ainda nao suportados if (complexType.Particle == null || !typeof(XmlSchemaGroupBase).IsAssignableFrom(complexType.Particle.GetType())) { try { XmlSchemaComplexContentRestriction restriction = complexType.ContentModel.Content as XmlSchemaComplexContentRestriction; XmlSchemaAttribute att = (XmlSchemaAttribute)restriction.Attributes[0]; if (att.RefName.Name == "arrayType") { XmlSchemaAnnotated annotatedSchema = (XmlSchemaAnnotated)att; Parameter param = new Parameter(); param.Name = MakeArrayElementName(att.UnhandledAttributes[0].Value); try { param.HWSType = ConvertType(param.Name); } catch { param.HWSType = new HWSPreType(param.Name); } parameters.Add(param); listType = new HWSListType(typeName, (Parameter)parameters[0]); ListTypes.Add(listType); } } catch (Exception ex) { throw new TypeNotSupportedException(typeName); } } else { XmlSchemaGroupBase atts = (XmlSchemaGroupBase)complexType.Particle; foreach (XmlSchemaElement att in atts.Items) { Parameter param = new Parameter(); param.Name = att.Name; try { param.HWSType = ConvertType(att.SchemaTypeName.Name); } catch { param.HWSType = new HWSPreType(att.SchemaTypeName.Name); } if (att.MaxOccursString != null && att.MaxOccursString.Equals("unbounded")) { isArray = true; } parameters.Add(param); } if (isArray) { listType = new HWSListType(typeName, (Parameter)parameters[0]); ListTypes.Add(listType); } else { dataType = new DataType(typeName, parameters); DataTypes.Add(dataType); } } }