root/capture-mod/trunk/client.pl

Revision 1764, 2.5 kB (checked in by xkovah, 3 months ago)

code as of last friday

  • Property svn:executable set to *
Line 
1 #!perl
2
3 use Data::Dumper;
4
5 use SOAP::Lite +trace => 'all';
6 #use SOAP::Lite;
7 use SOAP::Lite::Packager;
8 use MIME::Entity;
9 use MIME::Base64;
10
11 #test with a binary file
12 open(A, $ARGV[0]) or die "Can't open $ARGV[0]\n";
13 $fullfile = "";
14 while(<A>){
15     $fullfile .= $_;
16 }
17 $encoded = encode_base64($fullfile, "");
18 #print "$fullfile\n";
19 #print "$encoded\n";
20 @statz = stat($ARGV[0]);
21 $decodedLength = $statz[7];
22 if(length($fullfile) != $decodedLength){
23 print "What tha...\n";
24 }
25 $encodedLength = length($encoded);
26 print "File size = " . $statz[7] . "\n";
27 print "Base64 size = $encodedLength\n";
28
29 #my $ent = build MIME::Entity
30 #   Type    => "application/exe",
31 #   Path    => $ARGV[0],
32 #   Filename => $ARGV[0],
33 #   Disposition => "attachment";
34
35 $fileNameSOAP = SOAP::Data->name(fileName => $ARGV[0]);
36 $waitFileSOAP = SOAP::Data->name(waitTime => 15);
37 $dataSOAP = SOAP::Data->name(data => $encoded);
38 $encodedLengthSOAP = SOAP::Data->name(encodedLength => $encodedLength);
39 $decodedLengthSOAP = SOAP::Data->name(decodedLength => $decodedLength);
40
41 $pingDataA = SOAP::Data->name(a => "http://www.cnn.com");
42
43 $calcDataA = SOAP::Data->name(a => $ARGV[0]);
44 $calcDataB = SOAP::Data->name(b => 2);
45
46 $structData = SOAP::Data->name(a => "a");
47
48 #$res = SOAP::Lite
49 #    -> proxy('http://192.168.0.131:1234/')
50 #    -> ns('capture')
51 #    -> ping($pingDataA)
52 #    -> result;
53
54
55 #$res = SOAP::Lite
56 #    -> proxy('http://192.168.0.131:1234/')
57 #    -> ns('capture')
58 #    -> junks($structData)
59 #    -> result;
60
61 print "\ncalling client setup\n\n";
62 #    -> packager(SOAP::Lite::Packager::MIME->new)
63 #    -> parts([$ent])
64 $client = SOAP::Lite
65     -> proxy('http://192.168.0.131:1234/')
66     -> ns('capture');
67
68 #print "\ncalling sendFileBase64\n\n";
69 #$result = $client->sendFileBase64($fileNameSOAP, $dataSOAP, $encodedLengthSOAP, $decodedLengthSOAP);
70 #print "Result is $result\n";
71 print "\ncalling receiveFileBase64\n\n";
72 $som = $client->receiveFileBase64($fileNameSOAP);
73 #$result = $client->sendMIME(31337);
74
75 #print Dumper($result);
76
77 #print "calling junks\n";
78 #$res = SOAP::Lite
79 #    -> proxy('http://192.168.0.131:1234/')
80 #    -> ns('capture');
81
82 #my $som = $res->junks($structData);
83
84 $encodedDataFromServer = $som->result;
85 $fileFromServer = decode_base64($encodedDataFromServer);
86 open(BLA, ">serverfile.exe");
87 print BLA $fileFromServer;
88 close(BLA);
89
90 #print "ns__myStruct.first = " . $som->result . "\n";
91 #print "ns__myStruct.last = " . ($som->paramsout)[0] . "\n";
92
93 #my @params = $som->paramsall;
94 #foreach $param (@params){
95 #    print "$param\n";
96 #
97 #}
98
99
100
101
102
103
104
105
106
107
108
Note: See TracBrowser for help on using the browser.