1 package CWMP::Response;
7 use base qw/Class::Accessor/;
8 __PACKAGE__->mk_accessors( qw/debug/ );
12 use Data::Dump qw/dump/;
16 CWMP::Response - generate SOAP meesage for response
22 my $response = CWMP::Response->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/" ];
41 $response->InformResponse( $state );
46 my ( $self, $state ) = @_;
47 $self->xml( $state, sub {
48 my ( $X, $state ) = @_;
49 $X->InformResponse( $cwmp,
50 $X->MaxEnvelopes( $cwmp, 1 )
57 $response->GetRPCMethods( $state );
62 my ( $self, $state ) = @_;
63 $self->xml( $state, sub {
64 my ( $X, $state ) = @_;
71 $response->Reboot( $state );
76 my ( $self, $state ) = @_;
77 $self->xml( $state, sub {
78 my ( $X, $state ) = @_;
83 =head2 GetParameterNames {
85 $response->GetParameterNames( $state, $ParameterPath, $NextLevel );
89 sub GetParameterNames {
90 my ( $self, $state, $ParameterPath, $NextLevel ) = @_;
91 $ParameterPath ||= ''; # all
92 $NextLevel ||= 0; # all
93 warn "# GetParameterNames( '$ParameterPath', $NextLevel )\n" if $self->debug;
94 $self->xml( $state, sub {
95 my ( $X, $state ) = @_;
97 $X->GetParameterNames( $cwmp,
98 $X->ParameterPath( $cwmp, $ParameterPath ),
99 $X->NextLevel( $cwmp, $NextLevel ),
104 =head2 GetParameterValues {
106 $response->GetParameterValues( $state, $ParameterPath, $NextLevel );
110 sub GetParameterValues {
111 my ( $self, $state, $ParameterPath, $NextLevel ) = @_;
112 $ParameterPath ||= ''; # all
113 $NextLevel ||= 0; # all
114 warn "# GetParameterValues( '$ParameterPath', $NextLevel )\n" if $self->debug;
115 $self->xml( $state, sub {
116 my ( $X, $state ) = @_;
118 $X->GetParameterValues( $cwmp,
119 $X->ParameterPath( $cwmp, $ParameterPath ),
120 $X->NextLevel( $cwmp, $NextLevel ),
127 Used to implement methods which modify just body of soap message.
128 For examples, see source of this module.
135 my ( $state, $closure ) = @_;
137 confess "no state?" unless ($state);
138 confess "no body closure" unless ( $closure );
140 confess "no ID in state ", dump( $state ) unless ( $state->{ID} );
142 #warn "state used to generate xml = ", dump( $state ) if $self->debug;
144 my $X = XML::Generator->new(':pretty');
146 return $X->Envelope( $soap, { 'soap:encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/" },
148 $X->ID( $cwmp, { mustUnderstand => 1 }, $state->{ID} ),
149 $X->NoMoreRequests( $cwmp, $state->{NoMoreRequests} || 0 ),
151 $X->Body( $soap, $closure->( $X, $state ) ),