Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Blessed Objects and RPC

by submersible_toaster (Chaplain)
on Oct 02, 2003 at 03:00 UTC ( #295798=perlquestion: print w/replies, xml ) Need Help??

submersible_toaster has asked for the wisdom of the Perl Monks concerning the following question:

Reading up on SOAP and XML-RPC this week, one thing that I could not gleen was how to pass blessed objects in a similar manner.

For example:  $server->call( 'some_method' , @args ); Is just fine while @args contains data that fits into the XML-RPC types, structs, arrays, strings, ints, etc. However if I wished to pass an object, what then? I appreciate that Storable could be used to serialize the object, but then any methods that use objects would need to be aware of that and de-serialize the args upon receipt.

The question ? Is there a module I have overlooked that allows passing blessed objects to remote methods ?


I can't believe it's not psellchecked

Replies are listed 'Best First'.
Re: Blessed Objects and RPC
by perrin (Chancellor) on Oct 02, 2003 at 05:59 UTC
    To put it simply, SOAP has nothing to do with object-oriented programming. It is a way to present a (very slow) functional interface to external systems. You should treat it as such, and make the API very coarse-grained so that you can reduce the number of calls it will take to get things done. Yes, the performance is bad enough that you have to care about things like that.

    To maintain state, think of it more like a typical web browser interaction. Give clients a cookie, or a session ID or something that you can use to re-establish the current state of a multi-part interaction on the server side.

    If you want something lightweight that does allow objects to be passed, there are some older RPC mechanisms on CPAN that are faster, simpler, and more capable. However, they are Perl-specific, they still just pass things by serializing with Storable, and they have mostly been abandoned in favor of more general standards like SOAP.

Re: Blessed Objects and RPC
by Zaxo (Archbishop) on Oct 02, 2003 at 04:01 UTC

    Objects are usually passed around with some sort of IDL (Interface Definition Language) describing their public interface. The SOAP search seems to have at least some modules which appear to address that. You might also check CORBA to see what's available there.

    After Compline,
    Zaxo

      I am actually not to sure if there is a full featured Perl ORB (CORBA) around - actually I was looking for one a year ago ... Your design really depends what you are planing to do. Loose coupling of 2 processes (lightwight) SOAP might not be the worst idea (well, you can serialize the object on you own and send it via 'text message' or as attachment ...). If you are going to start with CORBA (which definitly is a good thing) take your time ;) Best regards Hartwig
Re: Blessed Objects and RPC
by submersible_toaster (Chaplain) on Oct 02, 2003 at 04:37 UTC

    Update: I should be shot for reading FUD on the web instead of knuckling down and examining POD and modules. perrin's point is well taken , SOAP is slow. For the purposes of my current design this could be a problem. Thanking you all for sharing virtue and excersising patience.

    Thanking Zaxo, I will endevour to explain myself better. I anticipate problems with this idea, please pick holes in it.

    To pass blessed objects between two remote perl processes, the sender (given a blessed object) determines what package it has been blessed into, and sends the package name and the serialized data via some transport (like SOAP or XML-RPC) that copes nicely with strings, calling the remote method 'rebless'

    The recieving side receives the SOAP data, calls the rebless method passing the two arguments. Rebless would de-serialize the data, and bless it into the named package.

    Of course this sort of thing has major limitations , like the consistancy of packages being installed or at the correct version. File handles are another one that would break if passed in this way

    I realise now, just how many things I've overlooked. Damn. I guess its time to change design.


    I can't believe it's not psellchecked
Re: Blessed Objects and RPC
by petesmiley (Friar) on Oct 02, 2003 at 15:31 UTC
    look here

    Edit
    I misread your question. I have not needed to do this I suppose the info from other posters will be more helpful.

    smiles

    Update: I have not had time to check. Have you tried it with SOAP::Lite? I'm not sure if SOAP::Serializer will do it automagically or not.

      You're correct petesmiley , SOAP::Lite does far more than I think I even need, see my update above for that realization. Why I didn't go straight to CPAN is something I will admonish myself about for a while. ++


      I can't believe it's not psellchecked

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://295798]
Approved by rob_au
Front-paged by Kanji
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2019-05-26 16:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (153 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!