1
I am studying the use of SOAP in PHP, and I have a webservice that when I send the number of an employee’s registration it returns the name of the employee and the sector, but I would like to send 5 number plates at the same time and return the name of 5 employees, how can I adapt my current code sending only one number at a time ?
My code:
<?php
$params = array("soap_version"=> SOAP_1_2,
"trace"=>1,
"exceptions"=>0,
);
$client = @new SoapClient('http://webserviceteste.com.br/WebService/WebService.asmx?WSDL',$params);
$retval = $client->ObterCadastro_S(
array(
'matricula' => '0000',
'inscricao' => '0000',
)
);
echo $retval->ObterCadastro_SResult->NomeFuncionario;
echo $retval->ObterCadastro_SResult->SetorFuncionario;
?>
Code for 3 parameter array
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sem título</title>
</head>
<body>
<?php
//array que guarda 'matricula' => 'inscricao'
//'0001' => '1234',
$arrayMatriculasInscricoes = array("dados" => array("matricula" => 0001, "inscricao" => 1234, "cpf" => 123456789));
echo $arr["dados"]["matricula"];
echo $arr["dados"]["inscricao"];
echo $arr["dados"]["cpf"];
foreach ($arrayMatriculasInscricoes as $i => $inscricao) {
//faz a consulta
$retval = $client->ObterCadastro_S(
array(
'matricula' => $i,
'inscricao' => $inscricao
)
);
echo $retval->ObterCadastro_SResult->NomeFuncionario;
echo $retval->ObterCadastro_SResult->SetorFuncionario;
}
?>
</body>
</html>
Valew
Cool, and if I want to send the number of the registration and the registration, as I can do ?
– Desenvolvedor
ai have to see if your Get Registration function receives the $registration variable. has how to post this function here?
– Fernando Rangel
Actually I need to pass the registration and registration as I can do ?
– Desenvolvedor
I don’t understand very well... today you can send these two values? if yes, post the code here.
– Fernando Rangel
I edited the code of my question, I need to send the registration together with the employee registration so that the system returns the name of the employee.
– Desenvolvedor
edited my answer.
– Fernando Rangel
no, ai indico estes link para você entender o funcionamento de arrays e de laços em php. follow [link] http://php.net/manual/en/language.types.array.php) and (http://php.net/manual/en/control-structures.foreach.php)
– Fernando Rangel