Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.8 KiB

  1. #!/bin/env perl
  2. #!d:\perl\bin\perl.exe
  3. # -- XMLRPC::Lite -- soaplite.com -- Copyright (C) 2001 Paul Kulchenko --
  4. use strict;
  5. use XMLRPC::Lite;
  6. use Data::Dumper; $Data::Dumper::Terse = 1; $Data::Dumper::Indent = 1;
  7. @ARGV or die "Usage: $0 endpoint [commands...]\n";
  8. my $proxy = shift;
  9. my %can;
  10. my $xmlrpc = XMLRPC::Lite->proxy($proxy)->on_fault(sub{});
  11. print STDERR "Usage: method[(parameters)]\n> ";
  12. while (defined($_ = shift || <>)) {
  13. next unless /\w/;
  14. my($method, $parameters) = /^\s*([.\w]+)(.*)/;
  15. $can{$method} = $xmlrpc->can($method) unless exists $can{$method};
  16. my $res = $method =~ /\./ ? eval "\$xmlrpc->call(\$method, $parameters)" : eval "\$xmlrpc->$_";
  17. $@ ? print(STDERR join "\n", "--- SYNTAX ERROR ---", $@, '') :
  18. $can{$method} && !UNIVERSAL::isa($res => 'XMLRPC::SOM')
  19. ? print(STDERR join "\n", "--- METHOD RESULT ---", $res || '', '') :
  20. defined($res) && $res->fault ? print(STDERR join "\n", "--- XMLRPC FAULT ---", @{$res->fault}{'faultCode', 'faultString'}, '') :
  21. !$xmlrpc->transport->is_success ? print(STDERR join "\n", "--- TRANSPORT ERROR ---", $xmlrpc->transport->status, '') :
  22. print(STDERR join "\n", "--- XMLRPC RESULT ---", Dumper($res->paramsall), '')
  23. } continue {
  24. print STDERR "\n> ";
  25. }
  26. __END__
  27. =head1 NAME
  28. XMLRPCsh.pl - Interactive shell for XMLRPC calls
  29. =head1 SYNOPSIS
  30. perl XMLRPCsh.pl http://betty.userland.com/RPC2
  31. > examples.getStateName(2)
  32. > examples.getStateNames(1,2,3,7)
  33. > examples.getStateList([1,9])
  34. > examples.getStateStruct({a=>1, b=>24})
  35. > Ctrl-D (Ctrl-Z on Windows)
  36. or
  37. # all parameters after uri will be executed as methods
  38. perl XMLRPCsh.pl http://betty.userland.com/RPC2 examples.getStateName(2)
  39. > Ctrl-D (Ctrl-Z on Windows)
  40. =head1 DESCRIPTION
  41. XMLRPCsh.pl is a shell for making XMLRPC calls. It takes one parameter,
  42. endpoint (actually it will tell you about it if you try to run it).
  43. Additional commands can follow.
  44. After that you'll be able to run any methods of XMLRPC::Lite, like autotype,
  45. readable, etc. You can run it the same way as you do it in
  46. your Perl script. You'll see output from method, result of XMLRPC call,
  47. detailed info on XMLRPC faulure or transport error.
  48. For full list of available methods see documentation for XMLRPC::Lite.
  49. Along with methods of XMLRPC::Lite you'll be able (and that's much more
  50. interesting) run any XMLRPC methods you know about on remote server and
  51. see processed results. You can even switch on debugging (with call
  52. something like: C<on_debug(sub{print@_})>) and see XMLRPC code with
  53. headers sent and recieved.
  54. =head1 COPYRIGHT
  55. Copyright (C) 2000 Paul Kulchenko. All rights reserved.
  56. =head1 AUTHOR
  57. Paul Kulchenko (paulclinger@yahoo.com)
  58. =cut