note 100829 added to soapclient.soapcall

From: Date: Wed, 10 Nov 2010 07:06:12 +0000
Subject: note 100829 added to soapclient.soapcall
Groups: php.notes 
Request: Send a blank email to php-notes+get-173893@lists.php.net to get a copy of this message
I was integrating a local warehouse system with a SOAP to our system and noticed some things. 1) Service uses "dot-namespacing" (fe. Item.Price) I classmapped this to Item_Price and used magical __get() and __set() to strip off 'Item.' from variable names. Works like a charm. Example: <Item.Price>1.52</Item.Price> <?php class Item_Price { public $price; public function __get($field) { $field = str_replace('Item.', '', $field); return $this->$field; } public function __set($field, $value) { $field = str_replace('Item.', '', $field); $this->$field = $value; } ?> 2) I noticed that classmapping a segment with attributes and value is possible. Class uses variables as attributes and $_ is the value. Example: <?php class Foo { public $item = 'Bar'; public $_ = 'Value here'; } ?> Turns to <Foo item="Bar">Value here</Foo> Example of using classes with soapcalls: <?php $client = ExtendSoapClient::getInstance(); $foo = new Foo(); $response = $client->sendFoo($foo); ?> Posted these since I think the documentation is lacking and very obsolete. Hopefully someone's burden eases. ---- Server IP: 69.147.83.197 Probable Submitter: 83.145.241.157 ---- Manual Page -- http://www.php.net/manual/en/soapclient.soapcall.php Edit -- https://master.php.net/note/edit/100829 Del: integrated -- https://master.php.net/note/delete/100829/integrated Del: useless -- https://master.php.net/note/delete/100829/useless Del: bad code -- https://master.php.net/note/delete/100829/bad+code Del: spam -- https://master.php.net/note/delete/100829/spam Del: non-english -- https://master.php.net/note/delete/100829/non-english Del: in docs -- https://master.php.net/note/delete/100829/in+docs Del: other reasons-- https://master.php.net/note/delete/100829 Reject -- https://master.php.net/note/reject/100829 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173893) next »