Welcome Guest, Not a member yet? Register   Sign In
Nusoap in Code Igniter 1.5.4
#5

[eluser]Wades[/eluser]
Thanks Leonardo Radoiu
but I have some question about your script here, could you explain it when you have time?
following are my test code according to your's

server.php
Code:
<?php
class Server extends Controller {

    function Server()
    {
        parent::Controller();    
                
        $this->load->library("Nusoaplib");
        
        $this->nusoap_server = new soap_server();
        $this->nusoap_server->configureWSDL("Server", "urn:Server");
        
        $this->nusoap_server->wsdl->addComplexType(
            "MemberRecordset",
            "complexType",
            "array",
            "",
            "SOAP-ENC:Array",
            array(
                "id"=>array("name"=>"id", "type"=>"xsd:int"),
                "firstname"=>array("name"=>"firstname", "type"=>"xsd:string"),
                "lastname"=>array("name"=>"lastname", "type"=>"xsd:string")
            )
        );    
        
        $this->nusoap_server->register(
            "test",
            array(
                "id" => "xsd:int",
            ),
            array("return"=>"tns:MemberRecordset"),
            "urn:Server",
            "urn:Server#test",
            "rpc",
            "encoded",
            "Get member's info"
        );
    }
    
    function server_test()
    {
        function test($member_id)
        {
            $row['id'] = '1';
            $row['firstname'] = 'fn';
            $row['lastname'] = 'ln';
            return $row;
        }
        
        $this->nusoap_server->service(file_get_contents("php://input"));
    }
}
?>

client.php
Code:
<?php
class Client extends Controller {

    function Client()
    {
        parent::Controller();    
        $this->load->library("Nusoaplib");
    }
    
    function index()
    {
        $id = $this->uri->segment(3);

        $this->nusoap_client = new nusoap_client(base_url()."/server/server_test");
        
        if($this->nusoap_client->fault)
        {
            $text = 'Error: '.$this->nusoap_client->fault;
        }
        else
        {
            if ($this->nusoap_client->getError())
            {
                $text = 'Error: '.$this->nusoap_client->getError();
            }
            else
            {
                $row = $this->nusoap_client->call(
                    'test',
                    array($id)
                );
                
                if(count($row) > 0 && is_array($row)) {
                    $text = "The member's name is ".$row['firstname']." ".$row['lastname'];
                } else {
                    $text = "There is no such member with ID ".$id;
                }
            }
        }
        
        echo $text;
    }
}
?>

the first question is that the return value in the client,
as you can see, it should return
Code:
$row['id'] = '1';
$row['firstname'] = 'fn';
$row['lastname'] = 'ln';
however, in the client class, i get this error
Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined index: firstname
Filename: controllers/client.php
when I
Code:
var_dump($row)
, the value are
Code:
array(3) { [0]=> string(1) "1" [1]=> string(2) "fn" [2]=> string(2) "ln" }
so I hope you can explain the code and how could I make it correct so that
Code:
$row['firstname']
can work in the client class
Code:
$this->nusoap_server->wsdl->addComplexType(
            "MemberRecordset",
            "complexType",
            "array",
            "",
            "SOAP-ENC:Array",
            array(
                "id"=>array("name"=>"id", "type"=>"xsd:int"),
                "firstname"=>array("name"=>"firstname", "type"=>"xsd:string"),
                "lastname"=>array("name"=>"lastname", "type"=>"xsd:string")
            )
        );

the second question I have is that when I change
Code:
$this->nusoap_server->configureWSDL("Server", "urn:Server");
to
Code:
$this->nusoap_server->configureWSDL("ss", "urn:ss");
it still work, no error, so I'm curiously about this

Greatly appreciated!!!


Messages In This Thread
Nusoap in Code Igniter 1.5.4 - by El Forum - 08-29-2007, 02:58 PM
Nusoap in Code Igniter 1.5.4 - by El Forum - 09-12-2007, 06:42 PM
Nusoap in Code Igniter 1.5.4 - by El Forum - 09-13-2007, 03:10 PM
Nusoap in Code Igniter 1.5.4 - by El Forum - 09-14-2007, 04:54 AM
Nusoap in Code Igniter 1.5.4 - by El Forum - 11-19-2007, 06:31 AM
Nusoap in Code Igniter 1.5.4 - by El Forum - 12-06-2007, 11:59 AM
Nusoap in Code Igniter 1.5.4 - by El Forum - 12-06-2007, 02:27 PM
Nusoap in Code Igniter 1.5.4 - by El Forum - 04-09-2008, 10:13 PM
Nusoap in Code Igniter 1.5.4 - by El Forum - 04-09-2008, 11:28 PM
Nusoap in Code Igniter 1.5.4 - by El Forum - 05-04-2008, 04:34 AM
Nusoap in Code Igniter 1.5.4 - by El Forum - 05-04-2008, 10:34 AM
Nusoap in Code Igniter 1.5.4 - by El Forum - 11-25-2008, 12:56 AM
Nusoap in Code Igniter 1.5.4 - by El Forum - 04-13-2010, 08:31 AM
Nusoap in Code Igniter 1.5.4 - by El Forum - 04-13-2010, 09:09 AM
Nusoap in Code Igniter 1.5.4 - by El Forum - 04-13-2010, 09:13 AM
Nusoap in Code Igniter 1.5.4 - by El Forum - 04-13-2010, 09:21 AM
Nusoap in Code Igniter 1.5.4 - by El Forum - 10-25-2010, 10:57 AM
Nusoap in Code Igniter 1.5.4 - by El Forum - 10-25-2010, 09:39 PM
Nusoap in Code Igniter 1.5.4 - by El Forum - 04-13-2011, 01:57 PM
Nusoap in Code Igniter 1.5.4 - by El Forum - 04-13-2011, 03:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB