Return Array Data Nu Soap

12:06 AM 0 Comments

Hello every buddy,

Here i'am :)....In this tutorial i will share about NuSoap WSDL..First i user NuSoap-0.9.5, so follow my step:
  1. Commenting out nusoap.php line 6132:
    //$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
  2. And then copy paste this code: (below)
  3. Create your client nusoap
  4. FINISH
<?php
date_default_timezone_set('Asia/Jakarta);
require_once 'inc/nusoap-0.9.5/nusoap.php';

$ns = "http://webservice.sim.pnj.ac.id/mahasiswa.php";
// Create SOAP Server
$server = new soap_server();
$server->configureWSDL('Mahasiswa', $ns);

function Nilai()
    {
        $result = array();
        $result[] = array('matakuliah' => 'Bahasa Indonesia', 'nilai' => 88);
        $result[] = array('matakuliah' => 'Fisika', 'nilai' => 85);
        return $result;    
    }

$server->wsdl->addComplexType(
    'MahasiswaNilai',
    'complexType',
    'struct',
    'all',
    '',
    array(
        'matakuliah' => array('name'=>'matakuliah','type'=>'xsd:string'),
        'nilai' => array('name'=>'nilai','type'=>'xsd:int')
    )
);

$server->wsdl->addComplexType(
    'NilaiArray',
    'complexType',
    'array',
    '',
    'SOAP-ENC:Array',
    array(),
    array(
        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:MahasiswaNilai[]')
    ),
    'tns:MahasiswaNilai'
);
$server->register(
    'Nilai',
    array(),
    array('return'=>'tns:NilaiArray'),
    $ns,false,'rpc','encoded','Menampilkan Nilai Mahasiswa PNJ');



$server->service(isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '');
exit();

?>

Install Server Networking Programming

Support you how to install server, networking and Programming Easy

0 comments:

You can post comment with english language or indonesia language.
Anda bisa memberikan komentar dalam bahasa inggris atau bahasa indonesia.