7 use base qw/Class::Accessor/;
8 __PACKAGE__->mk_accessors( qw/debug/ );
12 use Data::Dump qw/dump/;
16 CWMP::Methods - generate SOAP meesages for CPE
22 my $method = CWMP::Methods->new({ debug => 1 });
28 my $self = $class->SUPER::new( @_ );
30 warn "created XML::Generator object\n" if $self->debug;
37 Used to implement methods which modify just body of soap message.
38 For examples, see source of this module.
42 my $cwmp = [ cwmp => 'urn:dslforum-org:cwmp-1-0' ];
43 my $soap = [ soap => 'http://schemas.xmlsoap.org/soap/envelope/' ];
44 my $xsd = [ xsd => 'http://www.w3.org/2001/XMLSchema-instance' ];
49 my ( $state, $closure ) = @_;
51 confess "no state?" unless ($state);
52 confess "no body closure" unless ( $closure );
54 confess "no ID in state ", dump( $state ) unless ( $state->{ID} );
56 #warn "state used to generate xml = ", dump( $state ) if $self->debug;
58 my $X = XML::Generator->new(':pretty');
60 return $X->Envelope( $soap, { 'soap:encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/" },
62 $X->ID( $cwmp, { mustUnderstand => 1 }, $state->{ID} ),
63 $X->NoMoreRequests( $cwmp, $state->{NoMoreRequests} || 0 ),
65 $X->Body( $soap, $closure->( $X, $state ) ),
73 $method->GetRPCMethods( $state );
78 my ( $self, $state ) = @_;
79 $self->xml( $state, sub {
80 my ( $X, $state ) = @_;
85 =head2 SetParameterValues
87 $method->SetParameterValues( $state, {
93 It doesn't support base64 encoding of values yet.
95 To preserve data, it does support repeatable parametar names.
96 Behaviour on this is not defined in protocol.
100 sub SetParameterValues {
104 confess "SetParameterValues needs parameters" unless @_;
106 my $params = shift || return;
108 warn "# SetParameterValues = ", dump( $params ), "\n" if $self->debug;
110 $self->xml( $state, sub {
111 my ( $X, $state ) = @_;
113 $X->SetParameterValues( $cwmp,
114 $X->ParameterList( $cwmp,
115 $X->ParameterNames( $cwmp,
117 $X->ParameterValueStruct( $cwmp,
118 $X->Name( $cwmp, $_ ),
119 $X->Value( $cwmp, $params->{$_} )
129 =head2 GetParameterValues
131 $method->GetParameterValues( $state, [ 'ParameterName', ... ] );
137 confess "array_mandatory(",dump($v),") isn't ARRAY" unless ref($v) eq 'ARRAY';
141 sub GetParameterValues {
144 my @ParameterNames = _array_param(shift);
145 warn "# GetParameterValues", dump( @ParameterNames ), "\n" if $self->debug;
147 $self->xml( $state, sub {
148 my ( $X, $state ) = @_;
150 $X->GetParameterValues( $cwmp,
151 $X->ParameterNames( $cwmp,
153 $X->string( $xsd, $_ )
160 =head2 GetParameterNames
162 $method->GetParameterNames( $state, [ $ParameterPath, $NextLevel ] );
166 sub GetParameterNames {
167 my ( $self, $state, $param ) = @_;
169 my ( $ParameterPath, $NextLevel ) = _array_param( $param );
170 $ParameterPath ||= '';
172 warn "# GetParameterNames( '$ParameterPath', $NextLevel )\n" if $self->debug;
173 $self->xml( $state, sub {
174 my ( $X, $state ) = @_;
176 $X->GetParameterNames( $cwmp,
177 $X->ParameterPath( $cwmp, $ParameterPath ),
178 $X->NextLevel( $cwmp, $NextLevel ),
183 =head2 GetParameterAttributes
185 $method->GetParameterAttributes( $state, [ $ParametarNames, ... ] );
189 sub GetParameterAttributes {
190 my ( $self, $state, $param ) = @_;
191 my @ParameterNames = _array_param($param);
193 warn "# GetParameterAttributes", dump( @ParameterNames ), "\n" if $self->debug;
195 $self->xml( $state, sub {
196 my ( $X, $state ) = @_;
198 $X->GetParameterAttributes( $cwmp,
199 $X->ParameterNames( $cwmp,
201 $X->string( $xsd, $_ )
210 $method->Reboot( $state );
215 my ( $self, $state ) = @_;
216 $self->xml( $state, sub {
217 my ( $X, $state ) = @_;
223 =head1 Server methods
226 =head2 InformResponse
228 $method->InformResponse( $state );
233 my ( $self, $state ) = @_;
234 $self->xml( $state, sub {
235 my ( $X, $state ) = @_;
236 $X->InformResponse( $cwmp,
237 $X->MaxEnvelopes( $cwmp, 1 )
244 All other methods are unimplemented.