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