| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package promessaging::MRS; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
87633
|
use SOAP::Lite; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use XML::Simple; |
|
5
|
|
|
|
|
|
|
use strict; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use 5.008003; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use warnings; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require Exporter; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
|
16
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
|
17
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# This allows declaration use promessaging::MRS ':all'; |
|
20
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
|
21
|
|
|
|
|
|
|
# will save memory. |
|
22
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
|
23
|
|
|
|
|
|
|
envelope get_xml MSISDNResolve getError get_xml_request get_xml_response MRSinfo |
|
24
|
|
|
|
|
|
|
) ] ); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
29
|
|
|
|
|
|
|
envelope get_xml MSISDNResolve getError get_xml_request get_xml_response MRSinfo |
|
30
|
|
|
|
|
|
|
); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION = '1.01'; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# location of the WSDL-description of the SOAP-service |
|
36
|
|
|
|
|
|
|
my $wsdl = "http://www.promessaging.net/End2EndMRS.wsdl"; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# serializer class |
|
40
|
|
|
|
|
|
|
BEGIN { |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
package My::Serializer; |
|
43
|
|
|
|
|
|
|
@My::Serializer::ISA = 'SOAP::Serializer'; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub envelope { |
|
46
|
|
|
|
|
|
|
my $self = shift; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$self->{'xml_request'} = $self->SUPER::envelope(@_); |
|
49
|
|
|
|
|
|
|
return ( $self->{'xml_request'} ); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub get_xml { |
|
53
|
|
|
|
|
|
|
my $self = shift; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
return ( $self->{'xml_request'} ); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# constructor, no parameters needed |
|
60
|
|
|
|
|
|
|
sub new { |
|
61
|
|
|
|
|
|
|
my $class = shift; |
|
62
|
|
|
|
|
|
|
my $self = {}; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$self->{'error'} = ""; |
|
65
|
|
|
|
|
|
|
$self->{'xml_response'} = ""; |
|
66
|
|
|
|
|
|
|
eval { |
|
67
|
|
|
|
|
|
|
if ( |
|
68
|
|
|
|
|
|
|
!( |
|
69
|
|
|
|
|
|
|
$self->{'soapservice'} = |
|
70
|
|
|
|
|
|
|
new SOAP::Lite->service($wsdl)->outputxml('true') |
|
71
|
|
|
|
|
|
|
->on_fault( sub { return; } ) |
|
72
|
|
|
|
|
|
|
) |
|
73
|
|
|
|
|
|
|
) |
|
74
|
|
|
|
|
|
|
{ |
|
75
|
|
|
|
|
|
|
return (0); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
$self->{'soapservice'}->serializer( My::Serializer->new ); |
|
78
|
|
|
|
|
|
|
}; |
|
79
|
|
|
|
|
|
|
if ($@) { |
|
80
|
|
|
|
|
|
|
return(0); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
bless $self, $class; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub MSISDNResolve { |
|
87
|
|
|
|
|
|
|
my $self = shift; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# my ( $msisdn, $userid, $password, $serviceprofile, $max_retries, |
|
90
|
|
|
|
|
|
|
# $interval_timeout, $interval_na ) = @_; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my ($userid, $password, $serviceprofile, $msisdn, $max_retries, $interval_timeout, $interval_na) = @_; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $soapservice = $self->{'soapservice'}; |
|
96
|
|
|
|
|
|
|
$self->{'error'} = ""; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my $retry = 0; |
|
99
|
|
|
|
|
|
|
my $result; |
|
100
|
|
|
|
|
|
|
my $interval; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
if ( !defined( $max_retries ) ) { |
|
103
|
|
|
|
|
|
|
$max_retries = 0; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
if ( !defined( $interval_timeout ) ) { |
|
106
|
|
|
|
|
|
|
# default: 0 seconds because immediately retry is allowed |
|
107
|
|
|
|
|
|
|
$interval_timeout = 0; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
if ( !defined( $interval_na ) ) { |
|
110
|
|
|
|
|
|
|
# default: 300 seconds (5 minutes) |
|
111
|
|
|
|
|
|
|
$interval_na = 300; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
while ( $retry <= $max_retries ) { |
|
115
|
|
|
|
|
|
|
if ( $retry > 0 ) { |
|
116
|
|
|
|
|
|
|
sleep $interval; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
my $answer; |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
eval { |
|
122
|
|
|
|
|
|
|
$answer = $self->{'soapservice'}->MSISDNResolve( $userid, |
|
123
|
|
|
|
|
|
|
$password, |
|
124
|
|
|
|
|
|
|
$serviceprofile, |
|
125
|
|
|
|
|
|
|
$msisdn ); |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
if ( substr( $answer, 0, 5 ) eq "
|
|
128
|
|
|
|
|
|
|
$self->{'xml_response'} = $answer; |
|
129
|
|
|
|
|
|
|
my $xs = new XML::Simple( suppressempty => "" ); |
|
130
|
|
|
|
|
|
|
my $parsed = $xs->XMLin($answer); |
|
131
|
|
|
|
|
|
|
my $xmlbody = $parsed->{'SOAP-ENV:Body'}; |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
if ( defined( $xmlbody->{'SOAP-ENV:Fault'} ) ) { |
|
134
|
|
|
|
|
|
|
my $fault = $xmlbody->{'SOAP-ENV:Fault'}; |
|
135
|
|
|
|
|
|
|
my $faultcode = $fault->{'faultcode'}; |
|
136
|
|
|
|
|
|
|
$result = $fault; |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
if ( $faultcode == 91 ) { |
|
139
|
|
|
|
|
|
|
$interval = $interval_timeout; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
elsif ( $faultcode == 99 ) { |
|
142
|
|
|
|
|
|
|
$interval = $interval_na; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
else { |
|
145
|
|
|
|
|
|
|
last; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
elsif ( defined( $xmlbody->{'SOAP-ENV:MSISDNResolveResponse'} ) ) { |
|
150
|
|
|
|
|
|
|
$result->{"response"} = |
|
151
|
|
|
|
|
|
|
$xmlbody->{'SOAP-ENV:MSISDNResolveResponse'}; |
|
152
|
|
|
|
|
|
|
last; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
else { |
|
155
|
|
|
|
|
|
|
$self->{'error'} = "no Fault or MSISDNResolveResponse in XML"; |
|
156
|
|
|
|
|
|
|
$interval = $interval_na; |
|
157
|
|
|
|
|
|
|
$result = -1; |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
else { |
|
161
|
|
|
|
|
|
|
chomp $answer; |
|
162
|
|
|
|
|
|
|
$self->{'error'} = $answer; |
|
163
|
|
|
|
|
|
|
$interval = $interval_na; |
|
164
|
|
|
|
|
|
|
$result = -2; |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
}; |
|
167
|
|
|
|
|
|
|
if ($@) { |
|
168
|
|
|
|
|
|
|
$self->{'error'} = $@; |
|
169
|
|
|
|
|
|
|
$interval = $interval_na; |
|
170
|
|
|
|
|
|
|
$result = -3; |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$retry++; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
return ($result); |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub getError { |
|
180
|
|
|
|
|
|
|
my $self = shift; |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
return ( $self->{'error'} ); |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub get_xml_request { |
|
186
|
|
|
|
|
|
|
my $self = shift; |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
return ( $self->{'soapservice'}->serializer->get_xml ); |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub get_xml_response { |
|
192
|
|
|
|
|
|
|
my $self = shift; |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
return ( $self->{'xml_response'} ); |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# just to show basic functionality |
|
198
|
|
|
|
|
|
|
sub MRSinfo { |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
print "\nThis shows that you installed MRS.pm succesfully!\n"; |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
} |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# Preloaded methods go here. |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
1; |
|
207
|
|
|
|
|
|
|
__END__ |