Hello,
I have to do a check in a Web Service where a valid CPF is sent and returns me a true or false according to validation.
I can access the Web Service with the following code:
// INICIANDO O OBJETO CLIENTE INFORMANDO O WSDL
$client = new SoapClient('https://www5.oab.org.br/Integracao/CNA.svc?wsdl', $options = array(
'soap_version' => SOAP_1_2,
'trace'=>1,
'exceptions'=> 0
));
// NOME DA FUNÇÃO A SER EXECUTADA
$function = 'AdvogadoRegular';
// PARÂMETROS DA FUNÇÃO A SER EXECUTADA
$arguments= array('AdvogadoRegular' => array( 'cpf' => '99999999999' ));
// URL DO WEB SERVICE
$options = array('location' => 'https://www5.oab.org.br/Integracao/CNA.svc');
echo 'Resposta: <pre>';
print_r($result);
echo '</pre>';
However, in order to access the Web Service, authentication of type Soap Header Authentication is required. Below is the SOAP Envelope example.
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:int="https://www5.oab.org.br/integracao/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<token xmlns="http://CFOAB.Integracao">CHAVE_DE_AUTENTICAÇÃO</token>
<wsa:To>https://www5.oab.org.br/Integracao/CNA.svc</wsa:To>
</soapenv:Header>
<soapenv:Body>
</soapenv:Body>
</soapenv:Envelope>
So I try to add the Header to my SOAP with the following code.
// ADICIONANDO O HEADER
$auth = array('token' => 'xxxxxxxx');
$header = new SoapHeader('http://CFOAB.Integracao','token',$auth,false);
$client->__setSoapHeaders($header);
Now my question is as follows, like sending the parameters correctly to the header by also sending the xmlns: wsa and wsa: To parameters described in the SOAP envelope?
Help me with this. Thanks