Пример #1
0
        public void TestUnnamedComplexType()
        {
            var ss        = LoadSchema(@"TestData/Schema01.xsd");
            var f         = new XdtoFactory(ss);
            var t         = f.Type(uri: "unnamedComplexType", name: "TheComplexType") as XdtoObjectType;
            var v         = f.Create(t) as XdtoDataObject;
            var p         = t.Properties.Get("Element");
            var pv        = f.Create(p.Type) as XdtoDataObject;
            var var1Value = f.Create(f.Type(XmlNs.xs, "string"), ValueFactory.Create("value of var1"));

            pv.Set("var1", ValueFactory.Create(var1Value));

            v.Set("Element", pv);

            var w = new XmlWriterImpl();

            w.SetString();

            f.WriteXml(w, v, "value");

            var serialized = w.Close().AsString();

            Console.WriteLine(serialized);

            var r = new XmlReaderImpl();

            r.SetString(serialized);

            var checkObject = f.ReadXml(r) as XdtoDataObject;
            var checkValue  = (checkObject.Get("Element") as XdtoDataObject).Get("var1").AsString();

            Console.WriteLine($"got {checkValue}");
        }
Пример #2
0
        public string Handle(string requestBody)
        {
            var reader = new XmlReaderImpl();

            reader.SetString(requestBody);

            var writer = new XmlWriterImpl();

            writer.SetString();

            writer.WriteStartElement("Envelope", xmlns_soap);
            writer.WriteNamespaceMapping("soap", xmlns_soap);
            writer.WriteStartElement("Body", xmlns_soap);

            try
            {
                Handle(reader, writer);
            }
            catch (Exception exc)
            {
                WriteFault(writer, exc.Message);
            }

            writer.WriteEndElement();              // Body
            writer.WriteEndElement();              // Envelope

            var responseText = writer.Close().AsString();

            return(responseText);
        }