Creating a basic SOAP service
<?php
/*
webservice_SOAP.php
*/
// download and copy lib from nusoap
require_once "lib/nusoap.php" ;
function showPlanets() {
$planets = "sojdf fajodf osdjfsoj asdfj sodjfoifdsof ds" ;
return $planets;
}
// check if HTTP_RAW_POST_DATA is not available
if ( !isset($HTTP_RAW_POST_DATA) ) {
$HTTP_RAW_POST_DATA = file_get_contents('php://input') ;
}
// create the web service server
$server = new soap_server() ;
$server->register("showPlanets") ;
$server->service($HTTP_RAW_POST_DATA ) ;
/*
index.php
*/
require_once "lib/nusoap.php" ;
$client = new nusoap_client("http://mvc.net/webservice_SOAP.php");
$planets = $client->call('showPlanets') ;
echo "Planets list:<br>" ;
echo $planets ;
/*
OUTPUT:
sojdf fajodf osdjfsoj asdfj sodjfoifdsof ds
*/