Re: [SOAP] PHP array problem <ns4:item>

From: Date: Thu, 27 Nov 2003 14:09:18 +0000
Subject: Re: [SOAP] PHP array problem <ns4:item>
References: 1 2  Groups: php.soap 
Request: Send a blank email to php-soap+get-1179@lists.php.net to get a copy of this message
I've created an object for each message and then created an array of these objects. Unfortunately we still get the same problem as the PEAR library forces an <item> tag if the array key is either blank or numeric. I'm not sure whether I understood Mikes suggestion......... My code snippet is //////////////////////////////////////////////////////////////////////////// ////////////////////////////////// class messagesubmission { var $originator; // originator mobile number var $recipient; // recipient mobile number var $body; // text message var $type; // message type var $validityperiod; // message type function messagesubmission ($aa) { foreach ($aa as $k=>$v) $this->$k = $aa[$k]; } }// end of class function readMessage() { // create message 1 $message = array('originator' => 'originatorno', 'recipient' => 'recipentno', 'body' => 'This is a test message 1', 'type' => 'Text', 'validityperiod' => '10'); $MyObjectArray[][messagesubmission] = createMessageObject($message); // create message 2 $message = array('originator' => 'originatorno', 'recipient' => 'recipentno', 'body' => 'This is a test message 2', 'type' => 'Text', 'validityperiod' => '10'); $MyObjectArray[][messagesubmission] = createMessageObject($message); return $MyObjectArray; } function createMessageObject($message) { return new messagesubmission($message); } $messages = readMessage(); //////////////////////////////////////////////////////////////////////////// ////////////////////////////////// Any help would be very welcome. Andy E "Mike Carter" <mikeatwork@ukonline.co.uk> wrote in message news:11054A7BC9A71245BCBB991757932573100FE6@mail.koa.uk.com... > > > > -----Original Message----- > > From: Thomas Ashbee [mailto:thomas@merinet.com] > > Sent: 25 November 2003 13:06 > > To: soap@lists.php.net > > Subject: [SOAP] PHP array problem <ns4:item> > > > > How do i stop the <ns4:item> being inserted in to the request > > > > > > $message_array = array( > > array('originator' => 'originatorno', > > 'recipient' => 'recipentno', > > 'body' => 'This is a test > > message', > > 'type' => 'Text', > > 'validityperiod' => '10'), > > array('originator' => 'originatorno', > > 'recipient' => 'recipentno', > > 'body' => 'This is a test > > message', > > 'type' => 'Text', > > 'validityperiod' => '10') > > ); > > > > $secondarray = array('messagesubmission' => $message_array); > > > > Use objects rather than nested arrays to put your attributes in. I use a > stdClass like: > $req = new StdClass; > $req->originator = 'originatorno'; > $req->recipient = 'recipentno'; > Etc... > Then add this class to the parent class (if your nesting things) before > submitting it to the webservice. > > Regards, > > > > Mike C. > > > ________________________________________________________________________ > This email has been scanned for all viruses by the MessageLabs Email > Security System. For more information on a proactive email security > service working around the clock, around the globe, visit > http://www.messagelabs.com > ________________________________________________________________________

« previous php.soap (#1179) next »