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 confess "GetParameterValues need ParameterNames" unless @ParameterNames;
146 warn "# GetParameterValues", dump( @ParameterNames ), "\n" if $self->debug;
148 $self->xml( $state, sub {
149 my ( $X, $state ) = @_;
151 $X->GetParameterValues( $cwmp,
152 $X->ParameterNames( $cwmp,
154 $X->string( $xsd, $_ )
161 =head2 GetParameterNames
163 $method->GetParameterNames( $state, [ $ParameterPath, $NextLevel ] );
167 sub GetParameterNames {
168 my ( $self, $state, $param ) = @_;
170 my ( $ParameterPath, $NextLevel ) = _array_param( $param );
171 $ParameterPath ||= '';
173 warn "# GetParameterNames( '$ParameterPath', $NextLevel )\n" if $self->debug;
174 $self->xml( $state, sub {
175 my ( $X, $state ) = @_;
177 $X->GetParameterNames( $cwmp,
178 $X->ParameterPath( $cwmp, $ParameterPath ),
179 $X->NextLevel( $cwmp, $NextLevel ),
186 $method->Reboot( $state );
191 my ( $self, $state ) = @_;
192 $self->xml( $state, sub {
193 my ( $X, $state ) = @_;
199 =head1 Server methods
202 =head2 InformResponse
204 $method->InformResponse( $state );
209 my ( $self, $state ) = @_;
210 $self->xml( $state, sub {
211 my ( $X, $state ) = @_;
212 $X->InformResponse( $cwmp,
213 $X->MaxEnvelopes( $cwmp, 1 )
220 All other methods are unimplemented.