private  IXmlRpcRequest GetRequest(IXmlRpcStreamRequestConfig config, Stream inputStream)
 {
     XmlRpcRequestSerializer parser = new XmlRpcRequestSerializer();
     return parser.ReadRequest(inputStream, config, TypeSerializerFactory);
 }
Пример #2
0
 public void WriteXmlRpcRequest()
 {
     XmlRpcRequest request = new XmlRpcRequest("examples.getStateName", new Object[] { 41, "32" });
     StringBuilder sb = new StringBuilder();
     XmlTextWriter writer = new XmlTextWriter(new StringWriter(sb));
     XmlRpcRequestSerializer serializer = new XmlRpcRequestSerializer();
     serializer.WriteRequest(writer, request, null, new TypeSerializerFactory());//.WriteRequest(writer, request, null, new TypeSerializerFactory());
     Assert.IsEqualTo(sb.ToString(), @"<?xml version=""1.0"" encoding=""utf-16""?><methodCall><methodName>examples.getStateName</methodName><params><param><value><i4>41</i4></value></param><param><value><string>32</string></value></param></params></methodCall>");
 }
Пример #3
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());
 }
Пример #4
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],);
        }