Thread: [PHP-SOAP-DEV] Proposed overriding ser/deser
Status: Alpha
Brought to you by:
rodif_bl
From: brad l. <rod...@ya...> - 2002-05-05 15:29:52
|
I have been doing some thining on how to do this... And i think it would be pretty cool if i could incorperate domxml. Standard function handing: $soap_server->map("namespace:type", "to_xml", "to_zval"); function to_xml_before($zval) { return $modified_zval; } function to_xml($zval) { $xmldom_node = new DomElement($zval->name); $xmldom_node->set_content($zval->value); return $xmldom_node; } function to_xml_after($xmldom_node) { $xmldom_node->first_child()->unlink_node(); return $xmldom_node; } ------------- function to_zval_before($xmldom_node) { return $xmldom_node->first_child()->unlink_node(); } function to_zval($xmldom_node) { $zval->data = $xmldom_node->first_child()->get_content(); return $zval; } function to_zval_after($zval) { $zval->connection = db_connect($zval->db, $zval->username, $zval->passwd); - or - unset($zval->unwanted_field); - or - $obj = new OtherObject($zval->value); return $obj; } Class manipulation. $soap_server->map("namespace:type", "class", MAP_CLASS_INSTANCE (default) | MAP_CLASS_CONVERT); MAP_CLASS_INSTANCE: class myType { function to_xml_before() { unset($this->unwanted); } function to_xml() { $xmldom_node = new DomElement($this->name); $xmldom_node->set_content($this->value); return $xmldom_node; } function to_xml_after($xmldom_node) { $xmldom_node->first_child()->unlink_node(); return $xmldom; } function to_zval_before($dom_node) { $xmldom_node->first_child()->unlink_node(); return $xmldom; } function to_zval($xmldom_node) { $this->data = $xmldom_node->get_contents(); } function to_zval_after() { unlink($this->data); } } MAP_CLASS_CONVERT: class myType { function to_xml_before($zval) { return $modified_zval; } function to_xml($zval) { $xmldom_node = new DomElement($zval->name); $xmldom_node->set_content($zval->value); return $xmldom_node; } function to_xml_after($xmldom_node) { $xmldom_node->first_child()->unlink_node(); return $xmldom_node; } function to_zval_before($xmldom_node) { return $xmldom_node->first_child()->unlink_node(); } function to_zval($xmldom_node) { $zval->data = $xmldom_node->first_child()->get_content(); return $zval; } function to_zval_after($zval) { $zval->connection = db_connect($zval->db, $zval->username, $zval->passwd); - or - unset($zval->unwanted_field); - or - $obj = new OtherObject($zval->value); return $obj; } } Basically the difference between MAP_CLASS_INSTANCE and MAP_CLASS_CONVERT is the instance treats the class as the type thats being converted and the class_convert treats the class as just a "conversion" class. $soap_server->autoMap(true/false); This will tell the server to "automap" types. Meaning if while serializing/deseralizing "someType" and there is an existing php class called "someType" then it ill try and call the corrisponding functions. I was looking into the domxml extension. The extension will need some changes for my needs and some other issues that dont currently work right now. like: $xml = new DomElement("asdf"); doesn't really give you a new DomElement(); you have to do: $xml = new DomElement("asfd"); $real_xml = $xml->domelement("asdf"); it looks like the constructors aren't working. I know how to fix them its just a matter of getting in the changes. the extension could still handle the to_xml_before() and to_zval_after() with out domxml changes or if domxml isn't even compiled in. - Brad __________________________________________________ Do You Yahoo!? Yahoo! Health - your guide to health and wellness http://health.yahoo.com |
From: phpsurf <ph...@if...> - 2002-05-05 22:21:43
|
I had a quick look to this, and I'm not sure I really understood what's in your mind in the difference between MAP_CLASS_INSTANCE and MAP_CLASS_CONVERT ! :) my only wish would be, for the class convert, that the convertion methods are not carried by the class itself but by another class which would just act as a transformer ... nut maybe that's what you meant ! > > Basically the difference between MAP_CLASS_INSTANCE and > MAP_CLASS_CONVERT is > the instance treats the class as the type thats being converted and the > class_convert treats the class as just a "conversion" class. > > $soap_server->autoMap(true/false); > > This will tell the server to "automap" types. Meaning if > while serializing/deseralizing "someType" and there is an > existing php class called "someType" then it ill try and call > the corrisponding functions. > > > I was looking into the domxml extension. The extension will need > some changes > for my needs and some other issues that dont currently work right now. > like: > > $xml = new DomElement("asdf"); > > doesn't really give you a new DomElement(); > you have to do: > > $xml = new DomElement("asfd"); > $real_xml = $xml->domelement("asdf"); > > it looks like the constructors aren't working. I know how to fix > them its just > a matter of getting in the changes. > > the extension could still handle the > to_xml_before() > and > to_zval_after() > with out domxml changes or if domxml isn't even compiled in. > > > - Brad > > > __________________________________________________ > Do You Yahoo!? > Yahoo! Health - your guide to health and wellness > http://health.yahoo.com > > _______________________________________________________________ > > Have big pipes? SourceForge.net is looking for download mirrors. We supply > the hardware. You get the recognition. Email Us: ban...@so... > _______________________________________________ > Phpsoaptoolkit-development mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phpsoaptoolkit-development ______________________________________________________________________________ ifrance.com, l'email gratuit le plus complet de l'Internet ! vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP... http://www.ifrance.com/_reloc/email.emailif |
From: brad l. <rod...@ya...> - 2002-05-05 23:17:37
|
--- phpsurf <ph...@if...> wrote: > I had a quick look to this, and I'm not sure I really understood what's in > your mind in the difference between MAP_CLASS_INSTANCE and MAP_CLASS_CONVERT > ! :) > > my only wish would be, for the class convert, that the convertion methods > are not carried by the class itself but by another class which would just > act as a transformer ... nut maybe that's what you meant ! Yeah... MAP_CLASS_CONVERT would act as a transformer.. and MAP_CLASS_INSTANCE would act on its own class attributes. The MAP_CLASS_CONVERT would just be a class wrapper around the to_xml* and to_zval* functions. and the MAP_CLASS_INSTANCE would have the to_xml* to_zval* defined as member along with other normal methods. So you would acually need an instance of the class. - Brad - > > > > > Basically the difference between MAP_CLASS_INSTANCE and > > MAP_CLASS_CONVERT is > > the instance treats the class as the type thats being converted and the > > class_convert treats the class as just a "conversion" class. > > > > $soap_server->autoMap(true/false); > > > > This will tell the server to "automap" types. Meaning if > > while serializing/deseralizing "someType" and there is an > > existing php class called "someType" then it ill try and call > > the corrisponding functions. > > > > > > I was looking into the domxml extension. The extension will need > > some changes > > for my needs and some other issues that dont currently work right now. > > like: > > > > $xml = new DomElement("asdf"); > > > > doesn't really give you a new DomElement(); > > you have to do: > > > > $xml = new DomElement("asfd"); > > $real_xml = $xml->domelement("asdf"); > > > > it looks like the constructors aren't working. I know how to fix > > them its just > > a matter of getting in the changes. > > > > the extension could still handle the > > to_xml_before() > > and > > to_zval_after() > > with out domxml changes or if domxml isn't even compiled in. > > > > > > - Brad > > > > > > __________________________________________________ > > Do You Yahoo!? > > Yahoo! Health - your guide to health and wellness > > http://health.yahoo.com > > > > _______________________________________________________________ > > > > Have big pipes? SourceForge.net is looking for download mirrors. We supply > > the hardware. You get the recognition. Email Us: ban...@so... > > _______________________________________________ > > Phpsoaptoolkit-development mailing list > > Php...@li... > > https://lists.sourceforge.net/lists/listinfo/phpsoaptoolkit-development > > > ______________________________________________________________________________ > ifrance.com, l'email gratuit le plus complet de l'Internet ! > vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP... > http://www.ifrance.com/_reloc/email.emailif > > > > _______________________________________________________________ > > Have big pipes? SourceForge.net is looking for download mirrors. We supply > the hardware. You get the recognition. Email Us: ban...@so... > _______________________________________________ > Phpsoaptoolkit-development mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phpsoaptoolkit-development __________________________________________________ Do You Yahoo!? Yahoo! Health - your guide to health and wellness http://health.yahoo.com |