Web Service dengan NUSoap Wiratmoko Yuwono Requirement Apache
Web Service dengan NUSoap Wiratmoko Yuwono
Requirement �Apache Web Server �PHP �Library NUSoap
Contoh Web Service Server (WSServer. php) � � � � � � � <? php // Pull in the Nu. SOAP code require_once('lib/nusoap. php'); // Create the server instance $server = new soap_server(); // Initialize WSDL support $server->configure. WSDL('hellowsdl', 'urn: hellowsdl'); // Register the method to expose $server->register('hello', // method name array('name' => 'xsd: string'), // input parameters array('return' => 'xsd: string'), // output parameters 'urn: hellowsdl', // namespace 'urn: hellowsdl#hello', // soapaction 'rpc', // style 'encoded', // use 'Says hello to the caller' // documentation ); // Define the method as a PHP function hello($name) { return 'Hello, '. $name; } // Use the request to (try to) invoke the service $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server->service($HTTP_RAW_POST_DATA); ? >
Contoh Web Service Client (WSClient. php)-Menggunakan Library Bawaan PHP �<? php �$client = new Soap. Client('http: //lecturer. eepisits. edu/~moko/WSServer. php? wsdl'); �$names = array('Scott'); �$result = $client->__soap. Call('hello', array('name' => 'Scott')); �print_r($result); �? >
Contoh Web Service Client (WSClient. php)-Menggunakan Library NUSOAP � <? php � // Pull in the Nu. SOAP code � require_once('lib/nusoap. php'); � // Create the client instance � $client = new soapclient('http: //lecturer. eepisits. edu/~moko/WSServer. php? wsdl', true); � // Call the SOAP method � $result = $client->call('hello', array('name' => 'Scott')); � // Result � print_r($result); � ? >
Tugas Aplikasikan WSClient. php ke server student dengan account masing -masing, WSServer. php bisa diakses pada alamat : http: //lecturer. eepis-its. edu/~moko/WSServer. php 2. Buat File WSServer 1. php untuk mencoba mengaplikasikan formula. Ada 3 parameter : Parameter 1 ->Nilai 1 Parameter 2 ->Nilai 2 Parameter 3 -> berisi ‘+’, ‘-’, ‘*’, ‘/’ Output : Formula dari nilai 1 dan nilai 2 sesuai entri parameter 3 3. Buat File WSClient 1. php untuk memanggil Web Service Server WSServer 1. php 4. WSServer 1. php dan WSClient 1. php diletakkan di account server student anda 1.
- Slides: 6