DeserializeRequest() public method

public DeserializeRequest ( Stream stm, Type svcType ) : CookComputing.XmlRpc.XmlRpcRequest
stm Stream
svcType System.Type
return CookComputing.XmlRpc.XmlRpcRequest
 public Stream Invoke(Stream requestStream)
 {
     try
     {
         XmlRpcSerializer serializer = new XmlRpcSerializer();
         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);
     }
 }
 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);
     }
 }
示例#3
0
        // private methods
        //
        MethodCall DeserializeRequest(
            ITransportHeaders requestHeaders,
            Stream requestStream)
        {
            string           requestUri = (string)requestHeaders["__RequestUri"];
            Type             svcType    = GetServiceType(requestUri);
            XmlRpcSerializer serializer = new XmlRpcSerializer();
            XmlRpcRequest    xmlRpcReq
                = serializer.DeserializeRequest(requestStream, svcType);

            Header[]   headers  = GetChannelHeaders(requestHeaders, xmlRpcReq, svcType);
            MethodCall mthdCall = new MethodCall(headers);

            mthdCall.ResolveMethod();
            return(mthdCall);
        }
        // private methods
        //
        MethodCall DeserializeRequest(
            ITransportHeaders requestHeaders,
            Stream requestStream)
        {
            string           requestUri = (string)requestHeaders["__RequestUri"];
            string           typeName   = GetTypeName(requestUri);
            Type             svcType    = Type.GetType(typeName);
            XmlRpcSerializer serializer = new XmlRpcSerializer();
            XmlRpcRequest    xmlRpcReq
                = serializer.DeserializeRequest(requestStream, svcType);

            // TODO: optimise out two calls to GetRegisteredWellKnownServiceTypes
            Header[]   headers  = GetChannelHeaders(requestHeaders, xmlRpcReq);
            MethodCall mthdCall = new MethodCall(headers);

            mthdCall.ResolveMethod();
            return(mthdCall);
        }
示例#5
0
 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;
       }
 }
        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[]");
        }
        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");
        }
示例#8
0
 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\"");
 }
示例#9
0
 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)
       {
       }
 }
示例#10
0
 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\"");
 }
        public void TwoSpaceString()
        {
            string xml = @"<?xml version=""1.0""?>
            <methodCall><methodName>rtx.EchoString</methodName>
            <params>
            <param><value>  </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(string),
            "argument is string");
              Assert.AreEqual("  ", request.args[0],
            "argument is string containing two spaces");
        }
        public void StringNoStringElement()
        {
            string xml = @"<?xml version=""1.0"" ?>
            <methodCall>
              <methodName>TestString</methodName>
              <params>
            <param>
              <value>test string</value>
            </param>
              </params>
            </methodCall>";
              StringReader sr = new StringReader(xml);
              XmlRpcSerializer serializer = new XmlRpcSerializer();
              XmlRpcRequest request = serializer.DeserializeRequest(sr, null);

              Assert.AreEqual(request.method, "TestString", "method is TestString");
              Assert.AreEqual(request.args[0].GetType(),  typeof(string),
            "argument is string");
              Assert.AreEqual((string)request.args[0], "test string",
            "argument is 'test string'");
        }
 public void NullRequestStream()
 {
     try
       {
     XmlRpcSerializer serializer = new XmlRpcSerializer();
     Stream stm = null;
     XmlRpcRequest request = serializer.DeserializeRequest(stm, null);
     Assert.Fail("Should throw ArgumentNullException");
       }
       catch (ArgumentNullException)
       {
       }
 }
 public void NoParam1()
 {
     try
       {
     string xml = @"<?xml version=""1.0"" ?>
     <methodCall>
       <methodName>MethodNoArgs</methodName>
       <params/>
     </methodCall>";
     StringReader sr = new StringReader(xml);
     XmlRpcSerializer serializer = new XmlRpcSerializer();
     XmlRpcRequest request = serializer.DeserializeRequest(sr, this.GetType());
       }
       catch(Exception ex)
       {
     Console.WriteLine(ex);
       }
 }
        public void DateTimeFormats()
        {
            string xml = @"<?xml version=""1.0"" ?>
            <methodCall>
            <methodName>TestDateTime</methodName>
            <params>
              <param>
            <value><dateTime.iso8601>20020707T11:25:37Z</dateTime.iso8601></value>
              </param>
              <param>
            <value><dateTime.iso8601>20020707T11:25:37</dateTime.iso8601></value>
              </param>
              <param>
            <value><dateTime.iso8601>2002-07-07T11:25:37Z</dateTime.iso8601></value>
              </param>
              <param>
            <value><dateTime.iso8601>2002-07-07T11:25:37</dateTime.iso8601></value>
              </param>
            </params>
            </methodCall>";

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

              Assert.IsTrue(request.args[0] is DateTime, "argument is DateTime");
              DateTime dt0 = (DateTime)request.args[0];
              DateTime dt1 = (DateTime)request.args[1];
              DateTime dt2 = (DateTime)request.args[2];
              DateTime dt3 = (DateTime)request.args[3];

              DateTime dt = new DateTime(2002, 7, 7, 11, 25, 37);
              Assert.AreEqual(dt0, dt, "DateTime WordPress");
              Assert.AreEqual(dt0, dt, "DateTime XML-RPC spec");
              Assert.AreEqual(dt0, dt, "DateTime TypePad");
              Assert.AreEqual(dt0, dt, "DateTime other");
        }
        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");
        }
        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");
        }
示例#18
0
 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");
 }
示例#19
0
        public void DeserializeParamsEmpty()
        {
            string xml =
            @"<?xml version=""1.0""?>
            <methodCall>
              <methodName>Foo</methodName>
              <params/>
            </methodCall>";
              StringReader sr = new StringReader(xml);
              XmlRpcSerializer serializer = new XmlRpcSerializer();
              XmlRpcRequest request = serializer.DeserializeRequest(sr, this.GetType());

              Assert.AreEqual(request.method, "Foo", "method is Foo");
              Assert.AreEqual(request.args[0].GetType(),  typeof(object[]),
            "argument is obj[]");
              Assert.AreEqual((request.args[0] as object[]).Length, 0,
            "argument is empty array of object");
        }
 public void MissingMethodName()
 {
     try
       {
     string xml = @"<?xml version=""1.0"" ?>
     <methodCall>
       <params>
     <param>
       <value>test string</value>
     </param>
       </params>
     </methodCall>";
     StringReader sr = new StringReader(xml);
     XmlRpcSerializer serializer = new XmlRpcSerializer();
     XmlRpcRequest request = serializer.DeserializeRequest(sr, null);
       }
       catch(Exception ex)
       {
     // TODO: should return InvalidXmlRpc
     string s = ex.Message;
       }
 }
 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;
       }
 }
        public void DateTimeLocales()
        {
            CultureInfo oldci = Thread.CurrentThread.CurrentCulture;
              try
              {
            foreach (string locale in Utils.GetLocales())
            {
              try
              {
            CultureInfo ci = new CultureInfo(locale);
            Thread.CurrentThread.CurrentCulture = ci;
            if (ci.LCID == 0x401    // ar-SA  (Arabic - Saudi Arabia)
              || ci.LCID == 0x465   // div-MV (Dhivehi - Maldives)
              || ci.LCID == 0x41e)  // th-TH  (Thai - Thailand)
              break;

            DateTime dt = new DateTime(1900, 01, 02, 03, 04, 05);
            while (dt < DateTime.Now)
            {
              Stream stm = new MemoryStream();
              XmlRpcRequest req = new XmlRpcRequest();
              req.args = new Object[] { dt };
              req.method = "Foo";
              XmlRpcSerializer ser = new XmlRpcSerializer();
              ser.SerializeRequest(stm, req);
              stm.Position = 0;

              XmlRpcSerializer serializer = new XmlRpcSerializer();
              XmlRpcRequest request = serializer.DeserializeRequest(stm, null);

              Assert.IsTrue(request.args[0] is DateTime,
                "argument is DateTime");
              DateTime dt0 = (DateTime)request.args[0];
              Assert.AreEqual(dt0, dt, "DateTime argument 0");
              dt += new TimeSpan(100, 1, 1, 1);
            }
              }
              catch (Exception ex)
              {
              Assert.Fail(String.Format("unexpected exception {0}: {1}",
                locale, ex.Message));
              }
            }
              }
              finally
              {
            Thread.CurrentThread.CurrentCulture = oldci;
              }
        }
 public void NoParam2()
 {
     string xml = @"<?xml version=""1.0"" ?>
     <methodCall>
       <methodName>MethodNoArgs</methodName>
       <params>
       </params>
     </methodCall>";
       StringReader sr = new StringReader(xml);
       XmlRpcSerializer serializer = new XmlRpcSerializer();
       XmlRpcRequest request = serializer.DeserializeRequest(sr, this.GetType());
       //Console.WriteLine("");
 }
 public void EmptyRequestStream()
 {
     try
       {
     StringReader sr = new StringReader("");
     XmlRpcSerializer serializer = new XmlRpcSerializer();
     XmlRpcRequest request = serializer.DeserializeRequest(sr, null);
     Assert.Fail("Should throw XmlRpcIllFormedXmlException");
       }
       catch(XmlRpcIllFormedXmlException)
       {
       }
 }
 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;
       }
 }
 public void InvalidInteger()
 {
     try
       {
     string xml = @"<?xml version=""1.0"" ?>
     <methodCall>
       <methodName>TestInt</methodName>
       <params>
     <param>
       <value><i4>12kiol</i4></value>
     </param>
       </params>
     </methodCall>";
     StringReader sr = new StringReader(xml);
     XmlRpcSerializer serializer = new XmlRpcSerializer();
     XmlRpcRequest request = serializer.DeserializeRequest(sr, null);
     Assert.Fail("Invalid integer should cause exception");
       }
       catch(Exception ex)
       {
     string s = ex.Message;
       }
 }
        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");
        }
示例#28
0
 public void DeserializeMassimo()
 {
     StringReader sr = new StringReader(massimoRequest);
       XmlRpcSerializer serializer = new XmlRpcSerializer();
       XmlRpcRequest request = serializer.DeserializeRequest(sr, this.GetType());
       Assert.AreEqual(request.method, "Send_Param", "method is Send_Param");
       Assert.AreEqual(typeof(string), request.args[0].GetType(),
     "argument is string");
       Assert.AreEqual(typeof(object[]), request.args[1].GetType(),
     "argument is object[]");
 }
        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");
        }
 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 þá'");
       }
 }
 // private methods
 //
 MethodCall DeserializeRequest(
   ITransportHeaders requestHeaders, 
   Stream requestStream)
 {
   string requestUri = (string) requestHeaders["__RequestUri"];
   Type svcType = GetServiceType(requestUri);
   XmlRpcSerializer serializer = new XmlRpcSerializer();
   XmlRpcRequest xmlRpcReq 
     = serializer.DeserializeRequest(requestStream, svcType);
   Header[] headers = GetChannelHeaders(requestHeaders, xmlRpcReq, svcType);
   MethodCall mthdCall = new MethodCall(headers);
   mthdCall.ResolveMethod();
   return mthdCall;
 }
 public void MissingMethodCall()
 {
     try
       {
     string xml = @"<?xml version=""1.0"" ?> <elem/>";
     StringReader sr = new StringReader(xml);
     XmlRpcSerializer serializer = new XmlRpcSerializer();
     XmlRpcRequest request = serializer.DeserializeRequest(sr, null);
     Assert.Fail("Should throw XmlRpcInvalidXmlRpcException");
       }
       catch(XmlRpcInvalidXmlRpcException)
       {
       }
 }
 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)
       {
       }
 }
示例#34
0
 public void DeserializeObjectParamsInsufficientParams()
 {
     string xml =
     @"<?xml version=""1.0""?>
     <methodCall>
       <methodName>Foo1</methodName>
       <params>
       </params>
     </methodCall>";
       StringReader sr = new StringReader(xml);
       XmlRpcSerializer serializer = new XmlRpcSerializer();
       XmlRpcRequest request = serializer.DeserializeRequest(sr, this.GetType());
 }