App-soapcli
view release on metacpan or search on metacpan
NAME
soapcli - SOAP client for CLI with YAML and JSON input and output
SYNOPSIS
soapcli [--verbose|-v] [--dump-xml-request|-x] [--json|-j] [--yaml|-y]
data.yml|data.json|{string:"JSON"}|-
[webservice.wsdl|webservice_wsdl.url]
[[http://example.com/endpoint|endpoint.url][#port]] [operation]
soapcli [--help|-h]
Examples:
$ soapcli calculator-correct.json
$ soapcli -y '{add:{x:2,y:2}}' http://soaptest.parasoft.com/calculator.wsdl
$ soapcli -v globalweather.yml globalweather.url '#GlobalWeatherSoap'
This is command-line SOAP client which accepts YAML or JSON document as
an input data.
The first argument is a request data as a JSON string or a name of file
which contains data in JSON or YAML format.
The second argument is an URL address to WSDL data or a filename of
WSDL data file or a file which contains an URL address to WSDL data.
This filename is optional and can be guessed from first argument.
The third argument is an URL address of endpoint with a name of a
webservice port. The URL address of endpoint is optional if is already
a part of WSDL data. The name of port is optional if it is unambiguous
for called method. The name of port should start with # character.
The fourth argument is a name of method. It is optional if a name of
method is already a part of request data.
The result will be dumped as JSON (by default) or YAML.
INSTALLATION
lib/App/soapcli.pm view on Meta::CPAN
=cut
sub new_with_options {
my ($class, %args) = @_;
my $argv = delete $args{argv};
local @ARGV = $argv ? @$argv : @ARGV;
my ($opts, $usage) = Getopt::Long::Descriptive::describe_options(
"$0 %o data.yml [http://schema | schema.url] [endpoint#port] [operation]",
[ 'verbose|v', 'verbose mode with messages trace', ],
[ 'dump-xml-request|x', 'dump request as XML document', ],
[ 'explain|e', 'explain webservice as Perl code', ],
[ 'help|h', 'print usage message and exit', ],
[ 'json|j', 'output result as JSON document', ],
[ 'yaml|y', 'output result as YAML document', ],
);
die $usage->text if $opts->help or @ARGV < 1;
lib/App/soapcli.pm view on Meta::CPAN
my $url = $wsdlsrc =~ m{://} ? $wsdlsrc : slurp($wsdlsrc, {chomp=>1});
chomp $url;
HTTP::Tiny->new->get($url)->{content};
}
elsif ($wsdlsrc =~ /\.wsdl$/ and -f $wsdlsrc) {
slurp($wsdlsrc);
};
} or die "Can not read WSDL data from `$wsdlsrc': $!\n";
my $arg_endpoint = $self->{extra_argv}->[2];
my $request = do {
if ($arg_request =~ /^{/) {
$arg_request =~ s/\n//g;
JSON::PP->new->utf8->relaxed->allow_barekey->decode($arg_request);
}
elsif ($arg_request eq '-') {
YAML::Syck::LoadFile(\*STDIN);
}
lib/App/soapcli.pm view on Meta::CPAN
$wsdl->addWSDL($wsdldom);
$wsdl->addHook(type => '{http://www.w3.org/2001/XMLSchema}hexBinary', before => sub {
my ($doc, $value, $path) = @_;
defined $value or return;
$value =~ m/^[0-9a-fA-F]+$/ or error __x"{path} contains illegal characters", path => $path;
return pack 'H*', $value;
});
my $port = do {
if (defined $arg_endpoint and $arg_endpoint =~ /#(.*)$/) {
$1;
}
else {
undef;
}
};
my $endpoint = do {
if (defined $arg_endpoint and $arg_endpoint !~ /^#/) {
my $url = $arg_endpoint =~ m{://} ? $arg_endpoint : slurp($arg_endpoint, {chomp=>1});
chomp $url;
$url =~ s/^(.*)#(.*)$/$1/;
$url;
}
else {
$wsdl->endPoint(
defined $port ? ( port => $port ) : (),
);
}
};
lib/App/soapcli.pm view on Meta::CPAN
}
else {
my $o = (keys %$request)[0];
$request = $request->{$o};
$o;
}
};
my $http = XML::Compile::Transport::SOAPHTTP->new(
address => $endpoint,
);
$http->userAgent->agent("soapcli/$VERSION");
$http->userAgent->env_proxy;
my $action = eval {
$wsdl->operation(
$operation,
defined $port ? ( port => $port ) : (),
)->soapAction()
script/soapcli.pl view on Meta::CPAN
=head1 SYNOPSIS
B<soapcli>
S<[--verbose|-v]>
S<[--dump-xml-request|-x]>
S<[--json|-j]>
S<[--yaml|-y]>
data.yml|data.json|{string:"JSON"}|-
[webservice.wsdl|webservice_wsdl.url]
[[http://example.com/endpoint|endpoint.url][#port]]
[operation]
B<soapcli>
S<[--help|-h]>
Examples:
$ soapcli calculator-correct.json
$ soapcli -y '{add:{x:2,y:2}}' http://soaptest.parasoft.com/calculator.wsdl
script/soapcli.pl view on Meta::CPAN
This is command-line SOAP client which accepts YAML or JSON document as
an input data.
The first argument is a request data as a JSON string or a name of file which
contains data in JSON or YAML format.
The second argument is an URL address to WSDL data or a filename of WSDL data
file or a file which contains an URL address to WSDL data. This filename is
optional and can be guessed from first argument.
The third argument is an URL address of endpoint with a name of a webservice
port. The URL address of endpoint is optional if is already a part of WSDL
data. The name of port is optional if it is unambiguous for called method. The
name of port should start with C<#> character.
The fourth argument is a name of method. It is optional if a name of method is
already a part of request data.
The result will be dumped as JSON (by default) or YAML.
=cut
( run in 0.758 second using v1.01-cache-2.11-cpan-49f99fa48dc )