lib/WSDL/Generator/Binding.pm

filter: Statementstmt 26.9% 14 / 52 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 36.3% 4 / 11 Podpod 85.7% 6 / 7 totaltotal 27.2% 24 / 88 CC 11 SCAR 33.9
CC
11
Cov
20%
generate
72.0
get_message
6.0
get_porttype
6.0
CRAP 29.6
« lib/WSDL/Generator/Base.pm ↑ Summary lib/WSDL/Generator.pm »
1 =pod
2  
3 =head1 NAME
4  
5 WSDL::Generator::Binding - Generate wsdl messages and portType for WSDL::Generator
6  
7 =head1 SYNOPSIS
8  
9 use WSDL::Generator::Binding;
10 my $param = { 'services' => 'AcmeTravelCompany',
11 'service_name' => 'Book_a_Flight' };
12 my $bind = WSDL::Generator::Binding->new($param);
13 $bind->add_request('GetPrice');
14 $bind->add_response('GetPrice');
15 print $bind->get_message->to_string;
16 print $bind->get_porttype->to_string;
17 print $bind->get_binding->to_string;
18  
19 =cut
20 package WSDL::Generator::Binding;
21  
22 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use base qw(WSDL::Generator::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 1 our $VERSION = '0.01';
28  
29 =pod
30  
31 =head1 CONSTRUCTOR
32  
33 =head2 new($param)
34  
35 $param = { 'services' => 'AcmeTravelCompany',
36 'service_name' => 'Book_a_Flight' };
37 $param is optional.
38 Returns WSDL::Generator::Binding object
39  
40 =cut
41 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
42 0 my ($class, $param) = @_;
43 my $self = { 'services' => $param->{services},
44 'service_name' => $param->{service_name},
45 0 'methods' => {} };
46 0 return bless $self => $class;
47 }
48  
49 =pod
50  
51 =head1 METHODS
52  
53 =head2 add_request($method)
54  
55 Adds a method with its request for binding
56  
57 =cut
58 0 ▶sub add_request : method {
Subroutine add_request: not called CC=1 SCAR=6.9
Pod documented
59 0 my ($self, $method) = @_;
60 0 $self->{methods}->{$method}->{request} = $method.'Request';
61 }
62  
63 =pod
64  
65 =head2 add_reponse($method)
66  
67 Adds a method with its response for binding
68  
69 =cut
70 0 ▶sub add_response : method {
Subroutine add_response: not called CC=1 SCAR=6.9
Pod undocumented
71 0 my ($self, $method) = @_;
72 0 $self->{methods}->{$method}->{response} = $method.'Response';
73 }
74  
75 =pod
76  
77 =head2 generate($param)
78  
79 $param = { 'services' => 'AcmeTravelCompany',
80 'service_name' => 'Book_a_Flight' };
81 $param is optional.
82 Prepare a wsdl structure ready to be fetched
83  
84 =cut
85 0 ▶sub generate : method {
Subroutine generate: not called CC=8 SCAR=42.8
Pod documented
86 0 my ($self, $param) = @_;
87 0 my @message = ();
88 0 my @porttype = ();
89 0 my @binding = ();
90 0 ▶ $self->{service_name} = $param->{service_name} if (exists $param->{service_name});
Branch: 1 branch
BranchTrueFalseTotal
if exists $param->{"service_name"} 0 0 0
91 0 ▶ $self->{services} = $param->{services} if (exists $param->{services});
Branch: 1 branch
BranchTrueFalseTotal
if exists $param->{"services"} 0 0 0
92 0 ▶ $self->{service_name} or return carp 'No service defined';
Branch: 1 branch
BranchTrueFalseTotal
$self->{"service_name"} or return carp("No service defined") 0 0 0
93 0 ▶ $self->{services} or return carp 'No services name defined';
Branch: 1 branch
BranchTrueFalseTotal
$self->{"services"} or return carp("No services name defined") 0 0 0
94 0 foreach my $method (sort keys %{$self->{methods}} ) {
95 0 push @message, @{$self->get_wsdl_element( { wsdl_type => 'MESSAGE',
96 methodRe => $method.'Request',
97 type => $self->{methods}->{$method}->{request},
98 0 ▶ } ) if ($self->{methods}->{$method}->{request})};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"methods"}{$method}{"request"} 0 0 0
99 0 push @message, @{$self->get_wsdl_element( { wsdl_type => 'MESSAGE',
100 methodRe => $method.'Response',
101 type => $self->{methods}->{$method}->{response},
102 0 ▶ } ) if ($self->{methods}->{$method}->{response})};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"methods"}{$method}{"response"} 0 0 0
103 0 push @porttype, @{$self->get_wsdl_element( { wsdl_type => 'PORTTYPE_OPERATION',
104 method => $method,
105 request => $method.'Request',
106 response => $method.'Response',
107 } )};
108 0 push @binding, @{$self->get_wsdl_element( { wsdl_type => 'BINDING_OPERATION',
109 method => $method,
110 definition_name => $self->{service_name},
111 0 } )};
112 }
113 0 $self->{message} = bless \@message => ref($self);
114 0 $self->{binding} = $self->get_wsdl_element( { wsdl_type => 'BINDING',
115 binding_operation => \@binding,
116 %$self,
117 } );
118 0 $self->{porttype} = $self->get_wsdl_element( { wsdl_type => 'PORTTYPE',
119 porttype_operation => \@porttype,
120 %$self,
121 } );
122 0 return $self;
123 }
124  
125  
126 =pod
127  
128 =head2 get_message()
129  
130 Returns WSDL message object
131  
132 =cut
133 0 ▶sub get_message : method {
Subroutine get_message: not called CC=2 SCAR=17.9
Pod documented
134 0 my $self = shift;
135 0 ▶ exists $self->{message} or $self->generate;
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{"message"} or $self->generate 0 0 0
136 0 return $self->{message};
137 }
138  
139  
140 =pod
141  
142 =head2 get_porttype()
143  
144 Returns WSDL porttype object
145  
146 =cut
147 0 ▶sub get_porttype : method {
Subroutine get_porttype: not called CC=2 SCAR=17.9
Pod documented
148 0 my $self = shift;
149 0 ▶ exists $self->{porttype} or $self->generate;
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{"porttype"} or $self->generate 0 0 0
150 0 return $self->{porttype};
151 }
152  
153  
154 =pod
155  
156 =head2 get_binding()
157  
158 Returns WSDL binding object
159  
160 =cut
161 0 ▶sub get_binding : method {
Subroutine get_binding: not called CC=2 SCAR=17.9
Pod documented
162 0 my $self = shift;
163 0 ▶ exists $self->{binding} or $self->generate;
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{"binding"} or $self->generate 0 0 0
164 0 return $self->{binding};
165 }
166  
167 1 1;
168  
169 =pod
170  
171 =head1 SEE ALSO
172  
173 WSDL::Generator
174  
175 =head1 AUTHOR
176  
177 "Pierre Denis" <pdenis@fotango.com>
178  
179 =head1 COPYRIGHT
180  
181 Copyright (C) 2001, Fotango Ltd - All rights reserved.
182 This is free software. This software may be modified and/or distributed under the same terms as Perl itself.
183  
184 =cut
« lib/WSDL/Generator/Base.pm ↑ Summary lib/WSDL/Generator.pm »