CapnSqueakers Posted March 31, 2023 Share Posted March 31, 2023 Good afternoon, I'm very new to php, and have to create a class for SoapServer from a very specific wsdl. I'm trying to create functions in the class for the operation, but the operation's name has a dash in it. I unfortunately cannot change the name of this operation. Say the operation's name is "ProvideDocument-b", how do I create a function in a class to handle this? class MySoapServerClasss { function ProvideDocument-b($data) {} } How can I create a function in my class to handle this operation? Any help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/316073-soapserver-with-operation-name-with-dash/ Share on other sites More sharing options...
Solution requinix Posted March 31, 2023 Solution Share Posted March 31, 2023 You don't, and whoever created that WSDL was dumb to not consider potential situations like this. You can, however, use the magic __call method to intercept calls to methods that don't exist, and create a properly-named method to do the work. class MySoapServerClass { public function __call(string $method, array $args) { return match ($method) { "ProvideDocument-b" => $this->ProvideDocumentB(...$args), }; } private function ProvideDocumentB(...) { ... } } Quote Link to comment https://forums.phpfreaks.com/topic/316073-soapserver-with-operation-name-with-dash/#findComment-1606976 Share on other sites More sharing options...
CapnSqueakers Posted April 3, 2023 Author Share Posted April 3, 2023 Thank you so much! Quote Link to comment https://forums.phpfreaks.com/topic/316073-soapserver-with-operation-name-with-dash/#findComment-1607033 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.