Beispiel #1
0
        public List<WSParameter> GetParameters(Message msg)
        {
            List<WSParameter> parameters = new List<WSParameter>();
            foreach (MessagePart msgpart in msg.Parts)
            {

                XmlQualifiedName typName = msgpart.Element;

                XmlSchemaElement lookup = (XmlSchemaElement)schemas.Find(typName, typeof(XmlSchemaElement));

                if (lookup != null)
                {
                    XmlSchemaComplexType tt = (XmlSchemaComplexType)lookup.SchemaType;

                    XmlSchemaSequence sequence = (XmlSchemaSequence)tt.Particle;
                    //int i = 0;
                    if (sequence != null)
                    {
                        foreach (XmlSchemaElement childElement in sequence.Items)
                        {
                            WSParameter param = new WSParameter();
                            param.Name = childElement.Name;
                            param.TypeName = childElement.SchemaTypeName.Name;
                            param.MinOccurs = childElement.MinOccurs;
                            param.MaxOccurs = childElement.MaxOccurs.ToString();

                            parameters.Add(param);
                            //ParameterAndType.Add(childElement.Name, childElement.SchemaTypeName.Name);
                            //Console.WriteLine("Element: {0} ,{1}", childElement.Name,childElement.SchemaTypeName.Name);
                        }
                    }
                }
            }

            return parameters;
        }
 private void SetParameterDefaultValue(WebServiceToInvoke wsInvoker, WSParameter wSParameter, bool isDebug)
 {
     switch (wSParameter.TypeName)
     {
         case "int":
             mainForm.Log("   " + wSParameter.Name + " - " + wSParameter.TypeName + ":" + DefaultValues.IntDefaultVal, FontStyle.Regular, isDebug);
             wsInvoker.AddParameter(wSParameter.Name, DefaultValues.IntDefaultVal);
             break;
         case "string":
             mainForm.Log("   " + wSParameter.Name + " - " + wSParameter.TypeName + ":" + DefaultValues.StringDefaultVal, FontStyle.Regular, isDebug);
             wsInvoker.AddParameter(wSParameter.Name, DefaultValues.StringDefaultVal);
             break;
         case "double":
             mainForm.Log("   " + wSParameter.Name + " - " + wSParameter.TypeName + ":" + DefaultValues.DoubleDefaultVal, FontStyle.Regular, isDebug);
             wsInvoker.AddParameter(wSParameter.Name, DefaultValues.DoubleDefaultVal);
             break;
         case "decimal":
             mainForm.Log("   " + wSParameter.Name + " - " + wSParameter.TypeName + ":" + DefaultValues.DecimalDefaultVal, FontStyle.Regular, isDebug);
             wsInvoker.AddParameter(wSParameter.Name, DefaultValues.DecimalDefaultVal);
             break;
         case "boolean":
             mainForm.Log("   " + wSParameter.Name + " - " + wSParameter.TypeName + ":" + DefaultValues.BooleanDefaultVal, FontStyle.Regular, isDebug);
             wsInvoker.AddParameter(wSParameter.Name, DefaultValues.BooleanDefaultVal);
             break;
         case "bool":
             mainForm.Log("   " + wSParameter.Name + " - " + wSParameter.TypeName + ":" + DefaultValues.BooleanDefaultVal, FontStyle.Regular, isDebug);
             wsInvoker.AddParameter(wSParameter.Name, DefaultValues.BooleanDefaultVal);
             break;
         default:
             mainForm.Log("   " + wSParameter.Name + " - " + wSParameter.TypeName + ":" + DefaultValues.StringDefaultVal, FontStyle.Regular, isDebug);
             wsInvoker.AddParameter(wSParameter.Name, DefaultValues.StringDefaultVal);
             break;
     }
 }