Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^3: SOAP Modules (OO or not?)

by perrin (Chancellor)
on Jul 01, 2007 at 13:54 UTC ( #624302=note: print w/replies, xml ) Need Help??

in reply to Re^2: SOAP Modules (OO or not?)
in thread SOAP Modules (OO or not?)

When SOAP dispatches to my module and method, the first thing passed to that method is the name of module, which leads me to think that it is being called in an OO context, and so i should bless it once i get inside.

When a method receives a class name, not a blessed reference, it is being called as a class method. If you want to use OO features like inheritance, you can continue to call the other subs as class methods. You don't need to though.

sub foo { my $class = shift; $class->bar(); # call bar() as a class method }

I'm not talking about treating it like an object when I pass it back through SOAP, although that would work fine too, so where's the harm?

That actually wouldn't work at all unless you did a lot of crazy workarounds. The XML serialization that SOAP uses is intentionally language-agnostic, so it has no way to represent the concept of something being blessed into a class.

Replies are listed 'Best First'.
Re^4: SOAP Modules (OO or not?)
by Cagao (Monk) on Jul 01, 2007 at 15:00 UTC
    Hmmmm, as for sending an object back, maybe it doesn't know what class it is, but it doesn't need to for what i'm doing. I want people to be able to build a structure in the XML, say, to represent a customer, with an array of phone numbers, etc. I've been able to received such a structure, and put it directly in a hashref in the method, and then make some changes, and send back the hashref, which gets represented fine in the XML being sent back.

      maybe it doesn't know what class it is, but it doesn't need to for what i'm doing

      If it doesn't know what kind of object it is, you aren't doing OO programming. That's a basic requirement. What you're talking about -- sending complex data structures back and forth -- is not OO. There is no object, no behaviors tied to it, no inheritance, no encapsulation, etc.

      It sounds like SOAP is working fine for you, but try not to confuse the issue by attempting to jam OO stuff where it doesn't fit. There's no reason to do that bless stuff you have in there now.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://624302]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2021-10-17 20:27 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (72 votes). Check out past polls.