WebSite-PHP Framework PHP
Multi language
Simple Ajax mode
No HTML, no JavaScript
URL rewriting
Mail sending
Sitemap - RSS - Web service
Download WebSite-PHP FrameWork now
 


Loading
 


Webservice client with object

Tutorials

>

Tutorial Webservice

>

Webservice client with object


Helloworld-02-client: Tutorial of the composant Webservice of the PHP FrameWork WebSite-PHP.

Webservice client with object:

stdClass Object
(
    [text] => It's my object
    [sub_object] => stdClass Object
        (
            [sub_text] => It's my object [sub_object]
        )

)

It's my object [sub_object]


Go back to tutorial of the componant Webservice



Source code

Source code


File: /pages/tutorials/webservice/helloworld-02-client.php

<?php
/* 
 * Use: http://YOUR_DOMAIN/tutorials/webservice/
 *         helloworld-02-client.html
 */

require_once(dirname(__FILE__)."/MySoapableObject.class.php");

class 
Helloworld02Client extends Page {
    public function 
InitializeComponent() {
        
parent::$PAGE_TITLE "Webservice client with object";
        
        
// Init webservice
        
$client = new WebSitePhpSoapClient(
                    
$this->getBaseLanguageURL().
                    
"/tutorials/webservice/".
                    
"helloworld-02-server.wsdl?wsdl");
        
        
// test with a complex object
        
$my_obj = new MySoapableObject();
        
$my_obj->setText("It's my object");
        
$obj_echo $client->echoObject(
                new 
SoapVar($my_objSOAP_ENC_OBJECT));
        
$sub_text $client->getObjectSubText(
                new 
SoapVar($my_objSOAP_ENC_OBJECT));
        
        
// display result message
        
$this->render = new Object($obj_echo"<br/>"
                            
$sub_text);
    }
}
?>


Go back to tutorial of the componant Webservice


Source code

Source code


MySoapableObject:
File: /pages/tutorials/webservice/MySoapableObject.class.php

<?php
require_once(dirname(__FILE__)."/MySubSoapableObject.class.php");

class 
MySoapableObject {
    private 
$text "";
    private 
$sub_object null;
    
    public function 
setText($txt) {
        
$this->text $txt;
        
$this->sub_object = new MySubSoapableObject();
        
$this->sub_object->setSubText($txt." [sub_object]");
    }
    
    public function 
getText() {
        return 
$this->text;
    }
    
    public function 
getSubObject() {
        return 
$this->sub_object;
    }

?>


MySubSoapableObject:
File: /pages/tutorials/webservice/MySubSoapableObject.class.php

<?php
class MySubSoapableObject {
    private 
$sub_text "";
    
    public function 
setSubText($txt) {
        
$this->sub_text $txt;
    }
    
    public function 
getSubText() {
        return 
$this->sub_text;
    }

?>


Share

 


Copyright © 2009-2017 WebSite-PHP Framework PHP
Home Documentation Download Quick start Tutorials Wiki Issue Tracker