Salve,
non riesco a trovare esempi su Google, ho fatto un semplice WS in PHP per inviare più Email e funziona molto bene.
Il mio codice è procedurale come si vede nell'esempio sotto, vorrei implementare un WS ad Oggetti in modo da gestire molte più cose in maniera semplice,
io sviluppo ad oggetti ma un WS non l'ho mai fatto, non lo so come si implementa ad Oggetti.
Come potrei trasformare il mio WS ad Oggetti ???
codice:
<?
require_once("lib/nusoap.php");
$ns = "http://www.mio-sito.it/php_webservice/";
$server = new soap_server();
$server->configureWSDL('WS_GladiatorMail', $ns);
$server->wsdl->schemaTargetNamespace = $ns;
//Register Function
$server->register('SendMail', array(
'_sEmails' => 'xsd:string',
'_sSubject' => 'xsd:string',
'_sHtml' => 'xsd:string',
'_sFrom' => 'xsd:string'
),
array('return' => 'xsd:string'), $ns);
function SendMail($_sEmails, $_sSubject, $_sHtml, $_sFrom)
{
$sResult = '';
$aEmail = preg_split("/[|]+/", $_sEmails);
$sHeader .= "From: <$_sFrom>\n";
$sHeader .= "X-Mailer: PHP/".phpversion()."\n";
$sHeader .= "MIME-Version: 1.0\n";
$sHeader .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$sHeader .= "Content-Transfer-Encoding: 7bit\n\n";
foreach($aEmail as $sEmail)
{
if($sEmail != '')
{
if(!mail($sEmail, $_sSubject, $_sHtml, $sHeader))
{
$sResult .= "|$sEmail";
}
}
}
return new soapval('return', 'xsd:string', substr($sResult, 1, strlen($sResult)));
}
$server->service($HTTP_RAW_POST_DATA);
?>