File: xmlrpc_test.pl

package info (click to toggle)
kamailio 4.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 56,100 kB
  • sloc: ansic: 552,832; xml: 166,484; sh: 8,659; makefile: 7,676; sql: 6,235; perl: 3,487; yacc: 3,428; python: 1,457; cpp: 1,219; php: 1,047; java: 449; pascal: 194; cs: 40; awk: 27
file content (67 lines) | stat: -rw-r--r-- 1,209 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/perl

# perl script for sending an xmlrpc command to ser's xmlrpc module,
# extra verbose output
# Usage:  perl xmlrpc_test.pl command [params...]
#
# History:
# --------
#  2009-07-13  initial version (andrei)
#
#

use strict;
use warnings;

use XMLRPC::Lite;

	my $rpc=shift @ARGV;
	my @rpc_params=@ARGV;
	my $k;
	my %r;
	my $i;

	if (!defined $rpc) {
		die "Usage: $0 rpc_command [args..]";
	}

# actual rpc call

	my($rpc_call) = XMLRPC::Lite
		-> proxy("http://127.0.0.1:5060") -> call($rpc, @rpc_params);
	
	my $res= $rpc_call->result;

# extra verbose result printing (could be skipped)

	if (!defined $res){
		print "fault{\n";
		$res=$rpc_call->fault;
		%r=%{$res};
		foreach $k (sort keys %r) {
			print("\t$k: $r{$k}\n");
		}
		print "}\n";
		exit -1;
	}
	if (ref($res) eq "HASH"){
		print("{\n");
		%r=%{$res};
		foreach $k (keys %r) {
			print("\t$k: ",  $r{$k}, "\n");
		}
		print("}\n");
	} elsif (ref($res) eq "ARRAY"){
		print "[\n";
		for ($i=0; $i<@{$res}; $i++){
			print "\t${$res}[$i]\n";
		}
		print "]\n";
	}elsif (ref($res) eq "SCALAR"){
		print "${$res}\n";
	}elsif (!ref($res)){
		print "$res\n";
	}else{
		print("ERROR: reference to ", ref($res), " not handled\n");
	}