コード例 #1
0
        private static IXmlRpcRequest Parse(String xmlrpcRequest)
        {
            XmlTextReader           reader = new XmlTextReader(new MemoryStream(Encoding.UTF8.GetBytes(xmlrpcRequest)));
            XmlRpcRequestSerializer parser = new XmlRpcRequestSerializer();

            return(parser.ReadRequest(reader, null, new TypeSerializerFactory()));
        }
コード例 #2
0
        private IXmlRpcRequest GetRequest(IXmlRpcStreamRequestConfig config, Stream inputStream)
        {
            XmlRpcRequestSerializer parser = new XmlRpcRequestSerializer();

            return(parser.ReadRequest(new XmlTextReader(inputStream), config, TypeSerializerFactory));
        }
コード例 #3
0
        public void ParseXmlRpcRequest()
        {
            String        xmlrpcRequest = @"<methodCall>
        <methodName>sample</methodName>
        <params>
            <param><value>eW91IGNhbid0IHJlYWQgdGhpcyE=</value></param>
            <param><value><i4>3</i4></value></param>
            <param><value><int>-7</int></value></param>
            <param><value><i8>1234567890</i8></value></param>
            <param><value><boolean>1</boolean></value></param>
            <param><value><boolean>false</boolean></value></param>
            <param><value><string>hello xmlrpc</string></value></param>
            <param><value><double>-3.145</double></value></param>
            <param><value><dateTime.iso8601>19980717T14:08:55</dateTime.iso8601></value></param>
            <param><value><base64>eW91IGNhbid0IHJlYWQgdGhpcyE=</base64></value></param>
            <param><value>
                <array>
                   <data>
                      <value><i4>12</i4></value>
                      <value><string>Egypt</string></value>
                      <value><boolean>0</boolean></value>
                      <value><i4>-31</i4></value>
                    </data>
                </array>
            </value></param>
            <param><value>
                <struct>
                    <member>
                        <name>lowerBound</name>
                        <value><i4>18</i4></value>
                    </member>
                    <member>
                        <name>upperBound</name>
                        <value><i4>139</i4></value>
                    </member>
                </struct>
            </value></param>
        </params>
    </methodCall>";
            XmlTextReader reader        = new XmlTextReader(new MemoryStream(Encoding.UTF8.GetBytes(xmlrpcRequest)));
            //IXmlRpcRequest request = new XmlRpcRequestSerializer(null, new TypeFactory(), reader);
            XmlRpcRequestSerializer parser  = new XmlRpcRequestSerializer();
            IXmlRpcRequest          request = parser.ReadRequest(reader, null, new TypeSerializerFactory());

            Assert.IsEqualTo(request.MethodName, "sample");
            Assert.IsEqualTo(request.Parameters[0], "eW91IGNhbid0IHJlYWQgdGhpcyE=");
            Assert.IsEqualTo(request.Parameters[1], 3);
            Assert.IsEqualTo(request.Parameters[2], -7);
            Assert.IsEqualTo(request.Parameters[3], 1234567890L);
            Assert.IsEqualTo(request.Parameters[4], true);
            Assert.IsEqualTo(request.Parameters[5], false);
            Assert.IsEqualTo(request.Parameters[6], "hello xmlrpc");
            Assert.IsEqualTo(request.Parameters[7], -3.145D);
            Assert.IsEqualTo(request.Parameters[8], new DateTime(1998, 7, 17, 14, 8, 55));
            Assert.IsSequenceEqualTo((Byte[])request.Parameters[9], Convert.FromBase64String("eW91IGNhbid0IHJlYWQgdGhpcyE="));

            Object[] array = (Object[])request.Parameters[10];
            Assert.IsEqualTo(array[0], 12);
            Assert.IsEqualTo(array[1], "Egypt");
            Assert.IsEqualTo(array[2], false);
            Assert.IsEqualTo(array[3], -31);

            IDictionary <String, Object> map = (IDictionary <String, Object>)request.Parameters[11];

            Assert.IsEqualTo(map["lowerBound"], 18);
            Assert.IsEqualTo(map["upperBound"], 139);
            //Assert.IsEqualTo(request.Parameters[10],);
        }