1 |
|
/* |
2 |
|
* DotGNU XmlRpc implementation |
3 |
|
* |
4 |
|
* Copyright (C) 2002 netFluid Technology Ltd |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
8 |
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
* (at your option) any later version. |
10 |
|
* |
11 |
|
* This program is distributed in the hope that it will be useful, |
12 |
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
* GNU General Public License for more details. |
15 |
|
* |
16 |
|
* You should have received a copy of the GNU General Public License |
17 |
|
* along with this program; if not, write to the Free Software |
18 |
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
|
* |
20 |
|
* $Revision$ $Date$ |
21 |
|
* |
22 |
|
* -------------------------------------------------------------------------- |
23 |
|
*/ |
24 |
|
using System; |
25 |
|
using System.Xml; |
26 |
|
using System.IO; |
27 |
|
using DotGNU.XmlRpc.Serialization.Formatters; |
28 |
|
|
29 |
|
namespace DotGNU.XmlRpc |
30 |
|
{ |
31 |
|
// protocol testbed |
32 |
|
|
33 |
|
public class XmlRpcTester |
34 |
|
{ |
35 |
|
public XmlRpcTester( string fileName ) |
36 |
|
{ |
37 |
|
MethodCallFormatter call = new MethodCallFormatter(); |
38 |
|
|
39 |
|
// Turn the xmlrpc stream into a XmlRpcMethod Object |
40 |
|
Console.Out.WriteLine( "Running test: {0}", fileName ); |
41 |
|
FileStream fs = new FileStream( fileName, FileMode.Open ); |
42 |
|
XmlRpcMethod method = (XmlRpcMethod)call.Deserialize( fs ); |
43 |
|
Console.Out.WriteLine( method ); |
44 |
|
|
45 |
|
// Now convert it back using the c# serialization mechanism |
46 |
|
MemoryStream ms = new MemoryStream(); |
47 |
|
call.Serialize( ms, method ); |
48 |
|
ms.Seek( 0, 0 ); |
49 |
|
StreamReader sr = new StreamReader( ms ); |
50 |
|
Console.Out.WriteLine( sr.ReadToEnd() ); |
51 |
|
|
52 |
|
// Create and fire a bogus response |
53 |
|
XmlRpcResponse resp = new XmlRpcResponse(); |
54 |
|
int i = 1234567890; |
55 |
|
resp.Add( i ); |
56 |
|
|
57 |
|
MethodResponseFormatter response = new MethodResponseFormatter(); |
58 |
|
ms = new MemoryStream(); |
59 |
|
response.Serialize( ms, resp ); |
60 |
|
StreamReader sr2 = new StreamReader( ms ); |
61 |
|
ms.Seek( 0, 0 ); |
62 |
|
Console.Out.WriteLine( sr2.ReadToEnd() ); |
63 |
|
|
64 |
|
// Convert the response back into an XmlRpcResponse object |
65 |
|
ms.Seek( 0, 0 ); |
66 |
|
XmlRpcResponse r = (XmlRpcResponse)response.Deserialize( ms ); |
67 |
|
Console.Out.WriteLine( r ); |
68 |
|
} |
69 |
|
|
70 |
|
public static void Main( string[] args ) |
71 |
|
{ |
72 |
|
XmlRpcTester test = new XmlRpcTester( args[0] ); |
73 |
|
} |
74 |
|
} |
75 |
|
} |