line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Correios::SIGEP::Common; |
2
|
2
|
|
|
2
|
|
14
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
59
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
50
|
|
4
|
2
|
|
|
2
|
|
1113
|
use XML::Compile::WSDL11; |
|
2
|
|
|
|
|
654076
|
|
|
2
|
|
|
|
|
103
|
|
5
|
2
|
|
|
2
|
|
1012
|
use XML::Compile::SOAP11; # <-- loads the soap namespace |
|
2
|
|
|
|
|
44127
|
|
|
2
|
|
|
|
|
65
|
|
6
|
2
|
|
|
2
|
|
1080
|
use XML::Compile::Transport::SOAPHTTP; # <-- sends messages over HTTP |
|
2
|
|
|
|
|
87506
|
|
|
2
|
|
|
|
|
76
|
|
7
|
2
|
|
|
2
|
|
18
|
use LWP::UserAgent; # <-- see "Note" on build_transport(); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
49
|
|
8
|
2
|
|
|
2
|
|
1676
|
use File::ShareDir; |
|
2
|
|
|
|
|
57462
|
|
|
2
|
|
|
|
|
1083
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub call { |
11
|
0
|
|
|
0
|
0
|
0
|
my ($self, $operation, $params) = @_; |
12
|
0
|
|
|
|
|
0
|
my $call = compiled_client($self, $operation); |
13
|
0
|
|
|
|
|
0
|
return process_return($self, $operation, $call->($params)); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub process_return { |
17
|
0
|
|
|
0
|
0
|
0
|
my ($self, $operation, $return, $trace) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
0
|
if ($self->{debug}) { |
20
|
0
|
|
|
|
|
0
|
$trace->printErrors; |
21
|
0
|
|
|
|
|
0
|
$trace->printRequest; |
22
|
0
|
|
|
|
|
0
|
$trace->printResponse; |
23
|
|
|
|
|
|
|
} |
24
|
0
|
0
|
|
|
|
0
|
if (exists $return->{parameters}{return}) { |
|
|
0
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
return $return->{parameters}{return}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
elsif (exists $return->{parameters}{$operation}) { |
28
|
0
|
0
|
|
|
|
0
|
if (exists $return->{parameters}{$operation}{resultado_solicitacao}) { |
29
|
0
|
|
|
|
|
0
|
return $return->{parameters}{$operation}{resultado_solicitacao}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
0
|
|
|
|
|
0
|
return $return->{parameters}{$operation}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
else { |
36
|
0
|
|
|
|
|
0
|
return $return; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub compiled_client { |
41
|
0
|
|
|
0
|
0
|
0
|
my ($self, $operation) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
0
|
my $key = '_compiled' . $operation; |
44
|
0
|
0
|
|
|
|
0
|
if (!$self->{$key}) { |
45
|
|
|
|
|
|
|
$self->{$key} = $self->{wsdl}->compileClient( |
46
|
|
|
|
|
|
|
operation => $operation, |
47
|
|
|
|
|
|
|
transport => $self->{transport}, |
48
|
0
|
|
|
|
|
0
|
); |
49
|
|
|
|
|
|
|
} |
50
|
0
|
|
|
|
|
0
|
return $self->{$key}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# FIXME: (fixed in XML::Compile::SOAP 3.07) |
54
|
|
|
|
|
|
|
# Use of uninitialized value $ns in hash element at XML/Compile/Cache.pm line 125. |
55
|
|
|
|
|
|
|
# Use of uninitialized value $ns in hash element at XML/Compile/Cache.pm line 134. |
56
|
|
|
|
|
|
|
# Use of uninitialized value $ns in concatenation (.) or string at XML/Compile/Cache.pm line 135. |
57
|
|
|
|
|
|
|
# Use of uninitialized value in string eq at XML/Compile/Cache.pm line 166. |
58
|
|
|
|
|
|
|
# Use of uninitialized value $ns in string eq at XML/Compile/Cache.pm line 166. |
59
|
|
|
|
|
|
|
sub build_transport { |
60
|
5
|
|
|
5
|
0
|
15
|
my ($self) = @_; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $local_file = File::ShareDir::dist_file( |
63
|
|
|
|
|
|
|
'WWW-Correios-SIGEP', |
64
|
|
|
|
|
|
|
$self->{wsdl_local_file} |
65
|
5
|
|
|
|
|
36
|
); |
66
|
5
|
|
|
|
|
975
|
$self->{wsdl} = XML::Compile::WSDL11->new( $local_file ); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
############################################################ |
69
|
|
|
|
|
|
|
### Note: |
70
|
|
|
|
|
|
|
### ----- |
71
|
|
|
|
|
|
|
### Of course Correios does *NOT* have a valid certificate, |
72
|
|
|
|
|
|
|
### Otherwise we'd be able to skip all this and just do: |
73
|
|
|
|
|
|
|
### |
74
|
|
|
|
|
|
|
### my $call = $wsdl->compileClient( 'method' ); |
75
|
|
|
|
|
|
|
### |
76
|
|
|
|
|
|
|
### but if we do that we get: |
77
|
|
|
|
|
|
|
### "Can't connect to apphom.correios.com.br:443 (certificate verify failed)" |
78
|
|
|
|
|
|
|
### |
79
|
|
|
|
|
|
|
### which is why we need to customize our transport here :( |
80
|
5
|
50
|
|
|
|
1709408
|
my @timeout = $self->{timeout} ? (timeout => $self->{timeout}) : (); |
81
|
5
|
|
|
|
|
71
|
my $ua = LWP::UserAgent->new( |
82
|
|
|
|
|
|
|
@timeout, |
83
|
|
|
|
|
|
|
ssl_opts => { verify_hostname => 0 }, |
84
|
|
|
|
|
|
|
# $self->{usuario}, $self->{senha} |
85
|
|
|
|
|
|
|
); |
86
|
5
|
50
|
|
|
|
4733
|
$ua->credentials( @{$self->{ua_auth}} ) if exists $self->{ua_auth}; |
|
0
|
|
|
|
|
0
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$self->{transport} = XML::Compile::Transport::SOAPHTTP->new( |
89
|
|
|
|
|
|
|
address => $self->{wsdl}->endPoint, |
90
|
5
|
|
|
|
|
37
|
@timeout, |
91
|
|
|
|
|
|
|
user_agent => $ua |
92
|
|
|
|
|
|
|
)->compileClient(); |
93
|
|
|
|
|
|
|
|
94
|
5
|
50
|
|
|
|
3469
|
if ($self->{precompile}) { |
95
|
0
|
|
|
|
|
0
|
foreach my $operation (@{$self->{precompile}}) { |
|
0
|
|
|
|
|
0
|
|
96
|
0
|
|
|
|
|
0
|
compiled_client($self, $operation); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
5
|
|
|
|
|
24
|
return $self; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
42; |