当前位置: 首页>>代码示例>>C#>>正文


C# XmlRpcSerializer.DeserializeRequest方法代码示例

本文整理汇总了C#中CookComputing.XmlRpc.XmlRpcSerializer.DeserializeRequest方法的典型用法代码示例。如果您正苦于以下问题:C# XmlRpcSerializer.DeserializeRequest方法的具体用法?C# XmlRpcSerializer.DeserializeRequest怎么用?C# XmlRpcSerializer.DeserializeRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CookComputing.XmlRpc.XmlRpcSerializer的用法示例。


在下文中一共展示了XmlRpcSerializer.DeserializeRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Invoke

 public Stream Invoke(Stream requestStream)
 {
     try
       {
     XmlRpcSerializer serializer = new XmlRpcSerializer();
     Type type = this.GetType();
     XmlRpcServiceAttribute serviceAttr = (XmlRpcServiceAttribute)
       Attribute.GetCustomAttribute(this.GetType(),
       typeof(XmlRpcServiceAttribute));
     if (serviceAttr != null)
     {
       if (serviceAttr.XmlEncoding != null)
     serializer.XmlEncoding = Encoding.GetEncoding(serviceAttr.XmlEncoding);
       serializer.UseIntTag = serviceAttr.UseIntTag;
       serializer.UseStringTag = serviceAttr.UseStringTag;
       serializer.UseIndentation = serviceAttr.UseIndentation;
       serializer.Indentation = serviceAttr.Indentation;
     }
     XmlRpcRequest xmlRpcReq
       = serializer.DeserializeRequest(requestStream, this.GetType());
     XmlRpcResponse xmlRpcResp = Invoke(xmlRpcReq);
     Stream responseStream = new MemoryStream();
     serializer.SerializeResponse(responseStream, xmlRpcResp);
     responseStream.Seek(0, SeekOrigin.Begin);
     return responseStream;
       }
       catch (Exception ex)
       {
     XmlRpcFaultException fex;
     if (ex is XmlRpcException)
       fex = new XmlRpcFaultException(0, ((XmlRpcException)ex).Message);
     else if (ex is XmlRpcFaultException)
       fex = (XmlRpcFaultException)ex;
     else
       fex = new XmlRpcFaultException(0, ex.Message);
     XmlRpcSerializer serializer = new XmlRpcSerializer();
     Stream responseStream = new MemoryStream();
     serializer.SerializeFaultResponse(responseStream, fex);
     responseStream.Seek(0, SeekOrigin.Begin);
     return responseStream;
       }
 }
开发者ID:bricel,项目名称:DrutNet,代码行数:42,代码来源:XmlRpcServerProtocol.cs

示例2: Base64Empty

        public void Base64Empty()
        {
            string xml = @"<?xml version=""1.0""?>
            <methodCall>
              <methodName>TestHex</methodName>
              <params>
            <param>
              <value>
            <base64></base64>
              </value>
            </param>
              </params>
            </methodCall>";
              StringReader sr = new StringReader(xml);
              XmlRpcSerializer serializer = new XmlRpcSerializer();
              XmlRpcRequest request = serializer.DeserializeRequest(sr, null);

              Assert.AreEqual(request.args[0].GetType(),  typeof(byte[]),
            "argument is byte[]");
              Assert.AreEqual(request.args[0], new byte[0],
            "argument is zero length byte[]");
        }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:22,代码来源:deserializerequesttest.cs

示例3: Base64

        public void Base64()
        {
            string xml = @"<?xml version=""1.0""?>
            <methodCall>
              <methodName>TestHex</methodName>
              <params>
            <param>
              <value>
            <base64>AQIDBAUGBwg=</base64>
              </value>
            </param>
              </params>
            </methodCall>";
              StringReader sr = new StringReader(xml);
              XmlRpcSerializer serializer = new XmlRpcSerializer();
              XmlRpcRequest request = serializer.DeserializeRequest(sr, null);

              Assert.AreEqual(request.args[0].GetType(), typeof(byte[]),
            "argument is byte[]");
              byte[] ret = (byte[])request.args[0];
              Assert.AreEqual(8, ret.Length, "argument is byte[8]");
              for (int i = 0; i < ret.Length; i++)
            Assert.AreEqual(i+1, ret[i], "members are 1 to 8");
        }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:24,代码来源:deserializerequesttest.cs

示例4: InvalidXml

 public void InvalidXml()
 {
     try
       {
     string xml = @"<?xml version=""1.0"" ?>
     <methodCall> </duffMmethodCall>";
     StringReader sr = new StringReader(xml);
     XmlRpcSerializer serializer = new XmlRpcSerializer();
     XmlRpcRequest request = serializer.DeserializeRequest(sr, null);
     Assert.Fail("Should throw XmlRpcIllFormedXmlException");
       }
       catch(XmlRpcIllFormedXmlException)
       {
       }
 }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:15,代码来源:deserializerequesttest.cs

示例5: ISO_8859_1

 public void ISO_8859_1()
 {
     using(Stream stm = new FileStream("../iso-8859-1_request.xml",
       FileMode.Open, FileAccess.Read))
       {
     XmlRpcSerializer serializer = new XmlRpcSerializer();
     XmlRpcRequest request = serializer.DeserializeRequest(stm, null);
     Assert.AreEqual(request.args[0].GetType(), typeof(string),
       "argument is string");
     Assert.AreEqual((string)request.args[0], "hæ hvað segirðu þá",
       "argument is 'hæ hvað segirðu þá'");
       }
 }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:13,代码来源:deserializerequesttest.cs

示例6: ZeroInteger

        public void ZeroInteger()
        {
            string xml = @"<?xml version=""1.0"" ?>
            <methodCall>
              <methodName>TestInt</methodName>
              <params>
            <param>
              <value><i4>0</i4></value>
            </param>
              </params>
            </methodCall>";
              StringReader sr = new StringReader(xml);
              XmlRpcSerializer serializer = new XmlRpcSerializer();
              XmlRpcRequest request = serializer.DeserializeRequest(sr, null);

              Assert.IsTrue(request.method == "TestInt", "method is TestInt");
              Assert.AreEqual(request.args[0].GetType(), typeof(int),
            "argument is int");
              Assert.AreEqual((int)request.args[0], 0, "argument is 0");
        }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:20,代码来源:deserializerequesttest.cs

示例7: DeserializeObjectInvalidParams

 public void DeserializeObjectInvalidParams()
 {
     string xml =
     @"<?xml version=""1.0""?>
     <methodCall>
       <methodName>Bar</methodName>
       <params>
     <param>
       <value>
     <string>string one</string>
       </value>
     </param>
     <param>
       <value>
     <i4>2</i4>
       </value>
     </param>
       </params>
     </methodCall>";
       StringReader sr = new StringReader(xml);
       XmlRpcSerializer serializer = new XmlRpcSerializer();
       try
       {
     XmlRpcRequest request = serializer.DeserializeRequest(sr,
       this.GetType());
     Assert.Fail("Should detect invalid type of parameter #2");
       }
       catch(XmlRpcTypeMismatchException)
       {
       }
 }
开发者ID:bricel,项目名称:DrutNet,代码行数:31,代码来源:paramstest.cs

示例8: OverflowInteger

 public void OverflowInteger()
 {
     try
       {
     string xml = @"<?xml version=""1.0"" ?>
     <methodCall>
       <methodName>TestInt</methodName>
       <params>
     <param>
       <value><i4>99999999999999999999</i4></value>
     </param>
       </params>
     </methodCall>";
     StringReader sr = new StringReader(xml);
     XmlRpcSerializer serializer = new XmlRpcSerializer();
     XmlRpcRequest request = serializer.DeserializeRequest(sr, null);
       }
       catch(Exception ex)
       {
     string s = ex.Message;
       }
 }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:22,代码来源:deserializerequesttest.cs

示例9: StructProperties

        public void StructProperties()
        {
            string xml = @"<?xml version=""1.0""?>
            <methodCall>
              <methodName>Foo</methodName>
              <params>
            <param>
              <value>
            <struct>
              <member>
            <name>member1</name>
            <value>
              <i4>1</i4>
            </value>
              </member>
              <member>
            <name>member2</name>
            <value>
              <i4>2</i4>
            </value>
              </member>
              <member>
            <name>member-3</name>
            <value>
              <i4>3</i4>
            </value>
              </member>
              <member>
            <name>member-4</name>
            <value>
              <i4>4</i4>
            </value>
              </member>
            </struct>
              </value>
            </param>
              </params>
            </methodCall>";

              StringReader sr = new StringReader(xml);
              XmlRpcSerializer serializer = new XmlRpcSerializer();
              XmlRpcRequest request = serializer.DeserializeRequest(sr, null);

              Assert.AreEqual(request.args[0].GetType(), typeof(XmlRpcStruct),
            "argument is XmlRpcStruct");
              XmlRpcStruct xrs = (XmlRpcStruct)request.args[0];
              Assert.IsTrue(xrs.Count == 4, "XmlRpcStruct has 4 members");
              Assert.IsTrue(xrs.ContainsKey("member1") && (int)xrs["member1"] == 1,
            "member1");
              Assert.IsTrue(xrs.ContainsKey("member2") && (int)xrs["member2"] == 2,
            "member2");
              Assert.IsTrue(xrs.ContainsKey("member-3") && (int)xrs["member-3"] == 3,
            "member-3");
              Assert.IsTrue(xrs.ContainsKey("member-4") && (int)xrs["member-4"] == 4,
            "member-4");
        }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:56,代码来源:deserializerequesttest.cs

示例10: MissingParams

 public void MissingParams()
 {
     try
       {
     string xml = @"<?xml version=""1.0"" ?>
     <methodCall>
       <methodName>TestString</methodName>
     </methodCall>";
     StringReader sr = new StringReader(xml);
     XmlRpcSerializer serializer = new XmlRpcSerializer();
     XmlRpcRequest request = serializer.DeserializeRequest(sr, null);
       }
       catch(Exception ex)
       {
     string s = ex.Message;
       }
 }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:17,代码来源:deserializerequesttest.cs

示例11: DeserializeObjectParamsStrings

 public void DeserializeObjectParamsStrings()
 {
     string xml =
     @"<?xml version=""1.0""?>
     <methodCall>
       <methodName>Bar</methodName>
       <params>
     <param>
       <value>
     <string>one</string>
       </value>
     </param>
     <param>
       <value>
     <string>two</string>
       </value>
     </param>
       </params>
     </methodCall>";
       StringReader sr = new StringReader(xml);
       XmlRpcSerializer serializer = new XmlRpcSerializer();
       XmlRpcRequest request = serializer.DeserializeRequest(sr, this.GetType());
       Assert.AreEqual(request.method, "Bar", "method is Foo");
       Assert.AreEqual(request.args[0].GetType(), typeof(string[]),
     "argument is string[]");
       Assert.AreEqual((string[])request.args[0], new string[] { "one", "two" },
     "argument is params array \"one\", \"two\"");
 }
开发者ID:bricel,项目名称:DrutNet,代码行数:28,代码来源:paramstest.cs

示例12: Blakemore

        public void Blakemore()
        {
            string xml = @"<?xml version=""1.0""?>
            <methodCall><methodName>rtx.useArrayOfStruct</methodName>
            <params>
            <param><value><array>
            <data><value>
            <struct><member><name>detail</name><value><string>elephant</string></value></member><member><name>number</name><value><int>76</int></value></member></struct>
            </value></data>
            <data><value>
            <struct><member><name>detail</name><value><string>rhino</string></value></member><member><name>number</name><value><int>33</int></value></member></struct>
            </value></data>
            <data><value>
            <struct><member><name>detail</name><value><string>porcupine</string></value></member><member><name>number</name><value><int>106</int></value></member></struct>
            </value></data>
            </array></value></param>
            </params></methodCall>";

              StringReader sr = new StringReader(xml);
              XmlRpcSerializer serializer = new XmlRpcSerializer();
              XmlRpcRequest request = serializer.DeserializeRequest(sr, GetType());

              Assert.AreEqual(request.args[0].GetType(), typeof(simple[]),
            "argument is simple[]");
              Assert.IsTrue((request.args[0] as simple[]).Length == 1,
            "argument is simple[] of length 1");
        }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:27,代码来源:deserializerequesttest.cs

示例13: Class

        public void Class()
        {
            string xml = @"<?xml version=""1.0""?>
            <methodCall>
              <methodName>TestClassMethod</methodName>
              <params>
            <param>
              <value>
            <struct>
              <member>
            <name>_int</name>
            <value>
              <i4>456</i4>
            </value>
              </member>
              <member>
            <name>_string</name>
            <value>
              <string>Test Class</string>
            </value>
              </member>
            </struct>
              </value>
            </param>
              </params>
            </methodCall>";

              StringReader sr = new StringReader(xml);
              XmlRpcSerializer serializer = new XmlRpcSerializer();
              XmlRpcRequest request = serializer.DeserializeRequest(sr, GetType());

              Assert.AreEqual(request.args[0].GetType(), typeof(TestClass),
            "argument is TestClass");
            //      XmlRpcStruct xrs = (XmlRpcStruct)request.args[0];
            //      Assert.IsTrue(xrs.Count == 4, "XmlRpcStruct has 4 members");
            //      Assert.IsTrue(xrs.ContainsKey("member1") && (int)xrs["member1"] == 1,
            //        "member1");
            //      Assert.IsTrue(xrs.ContainsKey("member2") && (int)xrs["member2"] == 2,
            //        "member2");
            //      Assert.IsTrue(xrs.ContainsKey("member-3") && (int)xrs["member-3"] == 3,
            //        "member-3");
            //      Assert.IsTrue(xrs.ContainsKey("member-4") && (int)xrs["member-4"] == 4,
            //        "member-4");
        }
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:44,代码来源:deserializerequesttest.cs

示例14: DeserializeObjectParams1

 public void DeserializeObjectParams1()
 {
     string xml =
     @"<?xml version=""1.0""?>
     <methodCall>
       <methodName>Foo1</methodName>
       <params>
     <param>
       <value>
     <i4>5678</i4>
       </value>
     </param>
     <param>
       <value>
     <i4>1</i4>
       </value>
     </param>
     <param>
       <value>
     <string>one</string>
       </value>
     </param>
       </params>
     </methodCall>";
       StringReader sr = new StringReader(xml);
       XmlRpcSerializer serializer = new XmlRpcSerializer();
       XmlRpcRequest request = serializer.DeserializeRequest(sr, this.GetType());
       Assert.AreEqual(request.method, "Foo1", "method is Foo");
       Assert.AreEqual((int)request.args[0], 5678, "first argument is int");
       Assert.AreEqual(request.args[1].GetType(),  typeof(object[]),
     "argument is object[]");
       Assert.AreEqual((object[])request.args[1], new object[] { 1, "one" },
     "second argument is params array 1, \"one\"");
 }
开发者ID:bricel,项目名称:DrutNet,代码行数:34,代码来源:paramstest.cs

示例15: DeserializeZeroParameters

 public void DeserializeZeroParameters()
 {
     string xml =
     @"<?xml version=""1.0""?>
     <methodCall>
       <methodName>FooZeroParameters</methodName>
       <params />
     </methodCall>";
       StringReader sr = new StringReader(xml);
       XmlRpcSerializer serializer = new XmlRpcSerializer();
       XmlRpcRequest request = serializer.DeserializeRequest(sr,
     this.GetType());
       Assert.AreEqual(request.method, "FooZeroParameters",
     "method is FooZeroParameters");
       Assert.AreEqual(0, request.args.Length, "no arguments");
 }
开发者ID:bricel,项目名称:DrutNet,代码行数:16,代码来源:paramstest.cs


注:本文中的CookComputing.XmlRpc.XmlRpcSerializer.DeserializeRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。