10/24/2008

Contoh Program Sederhana C++ ( dengan Array )

Buat temen2 yang baru pertama kali nyobain NuSoap - WSDL pasti pernah bingung. Bagaimana caranya mengirim variabel output array kepada aplikasi client. syntax xsd:array tidak ada !!! Trus bagaimana caranya?

Temen2 bisa liat contoh yang kutulis. Aplikasi sederhana untuk menampilkan data mahasiswa dari suatu jurusan. perhatikan tipe data ini :

— CONTOH IMPLEMENTASI MULTIPLE (MULTI-DIMENSIONAL) ARRAY —

// registers the types Register the data structures used by the service
// Input Complex Datatype
(
‘TypeDataInput’, // name
‘complexType’, // typeClass (complexTypesimpleTypeattribute)
’struct’, // phpType: currently supported are array and struct (php assoc array)
‘all’, // compositor (allsequencechoice)
”, // restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
array( // elements = array ( name = array(name=>’’,type=>’’) )
‘jurusan’ => array(’name’ => ‘jurusan’, ‘type’ => ‘xsd:string’)
)
);
// Output Complex Datatype
$server->wsdl->addComplexType(
‘TypeDataOutput’,
‘complexType’,
’struct’,
‘all’,
”,
array(
‘nim’ => array(’name’ => ‘nim’, ‘type’ => ‘xsd:int’),
‘nama’ => array(’name’ => ‘nama’, ‘type’ => ‘xsd:string’),
‘alamat’ => array(’name’ => ‘alamat’, ‘type’ => ‘xsd:string’)
)
);
// Output Array Complex Datatype
$server->wsdl->addComplexType(’TypeDataOutputArray’,
‘complexType’
‘array’,
”,
‘SOAP-ENC:Array’,
array(),
array(array(’ref’=>’SOAP-
ENC:arrayType’,'wsdl:arrayType’=>’tns:TypeDataOutput[]‘)),
‘tns:TypeDataOutput’
);
— END —

Tidak ada komentar: