App-soapcli

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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'

README  view on Meta::CPAN

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
    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

78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
=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

156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
        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

200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
$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

236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
    }
    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

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
=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

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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 1.072 second using v1.01-cache-2.11-cpan-49f99fa48dc )