I'm having a problem creating an authentication mechanism using SOAP and PHP. No further delay. Here is the code:
//servidor
$namespace = '/service?wsdl'; $server = new soap_server();
$server->configureWSDL('myWS', $namespace);
//registrando método como serviço
$server->register('testWS', array('nome'=>'xsd:string'), array('return'=>'xsd:string'), 'uri:testWS', '', 'rpc', 'encoded', 'Mensagem1');
function testWS($nome) {
return 'ok';
}
ob_clean();
@$server->service(file_get_contents("php://input"));
exit();
//parte do cliente
$soapURL = "myurl/service?wsdl";
$client = new SoapClient($soapURL,array());
$auth = array('username' => 'usertest', 'password' => 'passtest');
$header = new SoapHeader('myurl/service', 'authentification', $auth, false);
$response = $client->__soapCall("testWS", array("nome" => "nometeste"));
I'd like to know how I can validate these username variables within my testWS service.
Thanks for any help, I've been trying to solve this for days, I've read a lot of documentation but could not get through.
Thank you