App-soapcli
view release on metacpan or search on metacpan
1234567891011121314151617181920NAME
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]
soapcli [--help|-h]
Examples:
$ soapcli calculator-correct.json
$ soapcli -v globalweather.yml globalweather.url
'#GlobalWeatherSoap'
282930313233343536373839404142434445464748
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
7879808182838485868788899091929394959697=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
156157158159160161162163164165166167168169170171172173174175176
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
200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230$wsdl
->addWSDL(
$wsdldom
);
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
236237238239240241242243244245246247248249250251252253254255256
}
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
67891011121314151617181920212223242526=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
363738394041424344454647484950515253545556This 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 1.072 second using v1.01-cache-2.11-cpan-49f99fa48dc )