<?php

class wsClientDemo
{

    public function getCityName($postalCode)
    {   
	    $MIOLO = MIOLO::getInstance();
	    $host = $MIOLO->getConf('home.url');
	
	    try
	    {
	        // When requesting webservices from a Miolo's module, your need to inform the module name and the class
	        $options = array('location' => $host . '/webservices.php?module=example&class=wsServerDemo',
	                         'uri'      => $host );
	
	        $client = new SoapClient(NULL, $options);
	        // Note: we are not using WSDL on this example
	        $result = $client->__soapCall( 'getCity', array($postalCode) );
	
	        return $result;
	    }
	    catch (SOAPFault $e)
	    {
	        /* SOAP-ENV:Server is a intentionally error generated by the server to identify that the postalcode doesn't exist. */
	        if ( $e->faultcode == 'SOAP-ENV:Server' )
	        {
	            return $e->faultstring;
	        }
	        /* Other error? Show it.*/
	        else
	        {
	            return $e;
	        }
	    }
    }

}

?>