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 $response = CWMP::Methods->new({ debug => 1 });
28 my $self = $class->SUPER::new( @_ );
30 warn "created XML::Generator object\n" if $self->debug;
36 my $cwmp = [ cwmp => 'urn:dslforum-org:cwmp-1-0' ];
37 my $soap = [ soap => 'http://schemas.xmlsoap.org/soap/envelope/' ];
38 my $xsd = [ xsd => 'http://www.w3.org/2001/XMLSchema-instance' ];
42 $response->InformResponse( $state );
47 my ( $self, $state ) = @_;
48 $self->xml( $state, sub {
49 my ( $X, $state ) = @_;
50 $X->InformResponse( $cwmp,
51 $X->MaxEnvelopes( $cwmp, 1 )
58 $response->GetRPCMethods( $state );
63 my ( $self, $state ) = @_;
64 $self->xml( $state, sub {
65 my ( $X, $state ) = @_;
72 $response->Reboot( $state );
77 my ( $self, $state ) = @_;
78 $self->xml( $state, sub {
79 my ( $X, $state ) = @_;
84 =head2 GetParameterNames
86 $response->GetParameterNames( $state, $ParameterPath, $NextLevel );
90 sub GetParameterNames {
91 my ( $self, $state, $ParameterPath, $NextLevel ) = @_;
92 $ParameterPath ||= ''; # all
93 $NextLevel ||= 0; # all
94 warn "# GetParameterNames( '$ParameterPath', $NextLevel )\n" if $self->debug;
95 $self->xml( $state, sub {
96 my ( $X, $state ) = @_;
98 $X->GetParameterNames( $cwmp,
99 $X->ParameterPath( $cwmp, $ParameterPath ),
100 $X->NextLevel( $cwmp, $NextLevel ),
105 =head2 GetParameterValues
107 $response->GetParameterValues( $state, $ParameterNames );
111 sub GetParameterValues {
114 my @ParameterNames = @_;
115 confess "need ParameterNames" unless @ParameterNames;
116 warn "# GetParameterValues", dump( @ParameterNames ), "\n" if $self->debug;
118 $self->xml( $state, sub {
119 my ( $X, $state ) = @_;
121 $X->GetParameterValues( $cwmp,
122 $X->ParameterNames( $cwmp,
124 $X->string( $xsd, $_ )
133 Used to implement methods which modify just body of soap message.
134 For examples, see source of this module.
141 my ( $state, $closure ) = @_;
143 confess "no state?" unless ($state);
144 confess "no body closure" unless ( $closure );
146 confess "no ID in state ", dump( $state ) unless ( $state->{ID} );
148 #warn "state used to generate xml = ", dump( $state ) if $self->debug;
150 my $X = XML::Generator->new(':pretty');
152 return $X->Envelope( $soap, { 'soap:encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/" },
154 $X->ID( $cwmp, { mustUnderstand => 1 }, $state->{ID} ),
155 $X->NoMoreRequests( $cwmp, $state->{NoMoreRequests} || 0 ),
157 $X->Body( $soap, $closure->( $X, $state ) ),