| 1 | #!/usr/bin/env perl | ||
| 2 | #!d:\perl\bin\perl.exe | ||
| 3 | # | ||
| 4 | # Filename: stubmaker.pl | ||
| 5 | # Authors: Byrne Reese <byrne at majordojo dot com> | ||
| 6 | # Paul Kulchenko | ||
| 7 | # | ||
| 8 | # Copyright (C) 2005 Byrne Reese | ||
| 9 | # | ||
| 10 | # Usage: | ||
| 11 | # stubmaker.pl -[vd] <WSDL URL> | ||
| 12 | ################################################### | ||
| 13 | |||
| 14 | use SOAP::Lite; | ||
| 15 | use Getopt::Long; | ||
| 16 | |||
| 17 | my $VERBOSE = 0; | ||
| 18 | my $DIRECTORY = "."; | ||
| 19 | GetOptions( | ||
| 20 | 'd=s' => \$DIRECTORY, | ||
| 21 | 'v' => \$VERBOSE, | ||
| 22 | help => sub { HELP_MESSAGE(); }, | ||
| 23 | version => sub { VERSION_MESSAGE(); exit(0); }, | ||
| 24 | ) or HELP_MESSAGE(); | ||
| 25 | |||
| 26 | HELP_MESSAGE() unless $ARGV[0]; | ||
| 27 | |||
| 28 | my $WSDL_URL = shift; | ||
| 29 | |||
| 30 | print "Writing stub files...\n" if $VERBOSE; | ||
| 31 | my %services = %{SOAP::Schema->schema_url($WSDL_URL) | ||
| 32 | ->cache_ttl(1) | ||
| 33 | ->cache_dir($DIRECTORY) | ||
| 34 | ->parse() | ||
| 35 | ->load | ||
| 36 | ->services}; | ||
| 37 | Carp::croak "More than one service in service description. Service and port names have to be specified\n" | ||
| 38 | if keys %services > 1; | ||
| 39 | |||
| 40 | sub VERSION_MESSAGE { | ||
| 41 | print "$0 $SOAP::Lite::VERSION (C) 2005 Byrne Reese.\n"; | ||
| 42 | } | ||
| 43 | |||
| 44 | sub HELP_MESSAGE { | ||
| 45 | VERSION_MESSAGE(); | ||
| 46 | print <<EOT; | ||
| 47 | usage: $0 -[options] <WSDL URL> | ||
| 48 | options: | ||
| 49 | -v Verbose Outputbe quiet | ||
| 50 | -d <dirname> Output directory | ||
| 51 | EOT | ||
| 52 | exit 0; | ||
| 53 | } | ||
| 54 | |||
| 55 | __END__ |