Ejemplo n.º 1
0
        public TestClassSimple MethodWithoutParameters()
        {
            TestClassSimple
                InputTestClassSimple  = new TestClassSimple(),
                OutputTestClassSimple = new TestClassSimple();

            try
            {
                string
                    param = Context.Request.QueryString["param"];

                StreamReader
                    StreamReader = new StreamReader(Context.Request.InputStream, Encoding.UTF8);

                XmlSerializer
                    XmlSerializer = new XmlSerializer(InputTestClassSimple.GetType());

                InputTestClassSimple = (TestClassSimple)XmlSerializer.Deserialize(StreamReader);

                int
                    delta = 100;

                OutputTestClassSimple.FInt      = InputTestClassSimple.FInt * delta;
                OutputTestClassSimple.FDecimal  = InputTestClassSimple.FDecimal * delta;
                OutputTestClassSimple.FDateTime = InputTestClassSimple.FDateTime.AddYears(delta);
                OutputTestClassSimple.FString   = InputTestClassSimple.FString + " " + InputTestClassSimple.FString + (!string.IsNullOrEmpty(param) ? " \"" + param + "\"" : string.Empty);
            }
            catch (Exception eException)
            {
                OutputTestClassSimple.FString = eException.GetType().FullName + Environment.NewLine + "Message: " + eException.Message + Environment.NewLine + "StackTrace:" + Environment.NewLine + eException.StackTrace;
            }

            return(OutputTestClassSimple);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            try
            {
                                #if TEST_METHODS
                ServiceI
                    ServiceI = new ServiceI();

                                        #if TEST_HELO_WORD
                Console.WriteLine(ServiceI.HeloWord());
                                        #endif

                                        #if TEST_DO_SMTH_WITH_TEST_CLASS_SIMPLE
                TestClassSimple
                    TestClassSimpleIn = new TestClassSimple(),
                    TestClassSimpleOut;

                TestClassSimpleOut = ServiceI.DoSmthWithTestClassSimple(TestClassSimpleIn);
                                        #endif

                                        #if TEST_DO_SMTH_WITH_TEST_CLASS
                TestClass
                    TestClassIn = new TestClass(),
                    TestClassOut;

                TestClassIn.ListTestClassSimple = new TestClassSimple[] { new TestClassSimple() };

                TestClassOut = ServiceI.DoSmthWithTestClass(TestClassIn);
                                        #endif

                                        #if TEST_SAVE_XML
                bool
                    Result = ServiceI.SaveXml("test", CreateXmlDocument());

                Console.WriteLine(Result.ToString().ToLower());
                                        #endif
                                #elif TEST_BASIC_AUTHENTICATION
                TestBasicAuthentication();
                                #elif TEST_HELO_WORD_LOW
                TestHeloWordLow();
                                #elif TEST_DO_SMTH_WITH_TEST_CLASS_SIMPLE_LOW
                DoSmthWithTestClassSimpleLow();
                                #elif TEST_METHOD_WITHOUT_PARAMETERS_LOW
                TestMethodWithoutParametersLow();
                                #endif
            }
            catch (Exception eException)
            {
                Console.WriteLine(eException.GetType().FullName + Environment.NewLine + "Message: " + eException.Message + Environment.NewLine + "StackTrace:" + Environment.NewLine + eException.StackTrace);
            }
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        public TestClassSimple DoSmthWithTestClassSimple(TestClassSimple TestClassSimple)
        {
            TestClassSimple
                OutputTestClassSimple = new TestClassSimple();

            Context.Request.InputStream.Seek(0, SeekOrigin.Begin);

            StreamReader
                StreamReader = new StreamReader(Context.Request.InputStream, Encoding.UTF8);

            string
                tmpString = StreamReader.ReadToEnd().Trim();

            return(OutputTestClassSimple);
        }
Ejemplo n.º 4
0
        static void TestMethodWithoutParametersLow()
        {
            WebRequest
                request = WebRequest.Create(ConfigurationManager.AppSettings["URL"] + "/MethodWithoutParameters?param=ParamValue");

            request.ContentType = "text/xml";
            request.Method      = "POST";

            XmlDocument
                doc = CreateXmlDocument();

            byte[]
            bytes = System.Text.Encoding.UTF8.GetBytes(doc.InnerXml);

            request.ContentLength = bytes.Length;

            Stream
                os = request.GetRequestStream();

            os.Write(bytes, 0, bytes.Length);
            os.Close();

            WebResponse
                response = request.GetResponse();

            StreamReader
                sr = new StreamReader(response.GetResponseStream());

                                #if !USE_SERIALIZE
            string
                result = sr.ReadToEnd().Trim();

            doc = new XmlDocument();
            doc.LoadXml(result);

            XmlNodeList
                nodes = doc.GetElementsByTagName("TestClassSimple");

            for (int i = 0; i < nodes.Count; ++i)
            {
                for (int j = 0; j < nodes[i].ChildNodes.Count; ++j)
                {
                    Console.WriteLine("\"{0}\"=\"{1}\"", nodes[i].ChildNodes[j].Name, nodes[i].ChildNodes[j].FirstChild.Value);
                }
            }
                                #else
            TestClassSimple
                TestClassSimple = new TestClassSimple();

            XmlSerializer
                XmlSerializer = new XmlSerializer(TestClassSimple.GetType());

            TestClassSimple.FInt      = 999;
            TestClassSimple.FDecimal  = 999.99m;
            TestClassSimple.FDateTime = DateTime.Now;
            TestClassSimple.FString   = "Test Тест";

            string
                FileName = Path.GetFullPath(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar + "TestClassSimple.xml");

            if (File.Exists(FileName))
            {
                File.Delete(FileName);
            }

            StreamWriter
                sw = new StreamWriter(FileName, false, Encoding.UTF8);

            XmlSerializer.Serialize(sw, TestClassSimple);
            sw.Close();

            FileName = Path.GetFullPath(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar + "TestClassSimpleFromService.xml");

            StreamReader
                StreamReader = new StreamReader(FileName, Encoding.UTF8);

            TestClassSimple = new TestClassSimple();
            TestClassSimple = (TestClassSimple)XmlSerializer.Deserialize(StreamReader);

            TestClassSimple = new TestClassSimple();
            TestClassSimple = (TestClassSimple)XmlSerializer.Deserialize(sr);
                                #endif
        }