Subject: | Confusion over class vs module |
Date: | Tue, 18 Oct 2016 17:30:28 +0100 |
To: | "bug-SOAP-Lite [...] rt.cpan.org" <bug-SOAP-Lite [...] rt.cpan.org> |
From: | Daniel Beardsmore <daniel [...] trustnetworks.co.uk> |
Per the SOAP::Server documentation:
"The routines may be useful to understand if an application wishes to subclass SOAP::Server::Parameters and inherit from the new class instead."
Upon checking the source, SOAP::Server::Parameters has no constructor and appears to never be instantiated in the first place. The modules that you specify with dispatch_to/dispatch_with are called with the first parameter given as the name of the module as a plain scalar string, instead of a blessed object reference.
I was trying to find some way to pass in some callback parameters into the class that is created behind the scenes by this line:
SOAP::Transport::HTTP::CGI->dispatch_with({'http://some.domain.com/' => 'SomeSOAPHandlerModule'})->handle;
That is, I want the resulting methods to have access to one or more class properties that allow it to have clean access to the "outside world", i.e. break the encapsulation barrier, such a callback method for triggering logging.
I was intending to hook into its constructor, or hook some callback, or anything, only to find that when ->handle executes, it simply calls the functions inside SomeSOAPHandlerModule as plain old functions. Take the C2FService example:
package C2FService;
.....
sub c2f {
my $self = shift;
.....
}
Here, $self isn't an object of class C2FService, but simply a scalar string "C2FService".
Looking at the dispatch code (find_target and handle) in SOAP::Lite, I'm not even clear on whether SOAP::Server::Parameters was ever at any point *intended* to be instantiated, as the documentation refers to the modules called by ->handle "module" and "class" variously. SOAP::Server::Parameters is also documented thus:
"The class provides two subroutines (not methods),"
For this to be true, it would need to be a class and have a constructor or an ISA, and it has neither.
Some clean-up and/or rethinking is in order to provide some clarity in terms of using the terms "module" (a namespace), "class" and "object" correctly and consistently and in line with how SOAP::Lite actually functions.