Serializing objects for transportation over SOAP

From: Date: Thu, 27 Apr 2006 09:43:07 +0000
Subject: Serializing objects for transportation over SOAP
References: 1 2 3 4  Groups: php.soap 
Request: Send a blank email to php-soap+get-2252@lists.php.net to get a copy of this message
Hi there , I have a quick question for the group on PEAR:SOAP which you might be able to help me with. I have a library of custom DataMapper objects which I access through static calls. e.g. ================================ $invoiceCollection = InvoiceCollectionMapper::FindForDate('20060504'); ================================ I want to use these Mappers on a couple of other sites thru a webservice. In order to transport these object instances over SOAP, I've serialized them at the server end, and unserialized them on the client end. To look after this serialization, I created a wrapper around my InvoiceCollectionMapper : ================================= class SOAP_InvoiceCollectionMapper { function FindForDate($aDate) {
    $result = InvoiceCollectionMapper::FindForDate($aDate);
    return serialize($result);
} } ================================== My server looks like so: ================================== $server = new SOAP_Server(); $soapInvoiceCollectionMapper = new SOAP_InvoiceCollectionMapper(); $server->addObjectMap($soapInvoiceCollectionMapper,'urn:soapInvoiceCollectionMapper'); ================================== This is working fine! BUT..... I have a lot a datamappers, any they contain new methods all the time. Having create a new wrapper for each of them, and each new methods is a pain in the chops. Which brings me to my question..... Is it possible to have PEAR::SOAP do this serialization and unserialization in the PEARSERVER and PEARCLIENT objects? e.g.. $server->SerializeEnvelopeContents(true); Perhaps there is already functionality to handle this in the library already, that would be ace! Otherwise, would anyone have any suggestions on how to handle this elegantly? Thanks for your help! Kind Regards, Karl Glennon

« previous php.soap (#2252) next »