Hello, I'm challenged to make a system communicate with e-social webservice using php with laravel framework, but I have no clue how to proceed. The system is used to register employees.
I made the following test with the php SoapClient class, to get a sense of how the request was being mounted:
$this->options = [
'location' => 'https://webservices.producaorestrita.esocial.gov.br/servicos/empregador/enviarloteeventos/WsEnviarLoteEventos.svc',
'cache_wsdl' => WSDL_CACHE_NONE,
'exceptions' => false,
'trace' => true,
'local_cert' => '\teste\teste.pem',
];
$this->wsdl = 'C:\Users\alexs\Desktop\WsEnviarLoteEventos.wsdl';
$this->params = [
'nome' => 'Alex',
'idade' => '18',
'subatributos' =>[
'item1' => 'value1',
'item2' => 'value2',
'item3' => 'value3',
],
];
$this->function = "EnviarLoteEventos";
$this->client = new SoapClient($this->wsdl, $this->options);
$response = $this->client->SoapCall($this->function, $this->params);
return $this->client->getLastRequest();
I get the following return:
<soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.esocial.gov.br/servicos/empregador/lote/eventos/envio/v1_0_0">
<soap-env:body>
<ns1:enviarloteeventos>
<param1>18</param1>
<param2>
<item>
<key>item1</key>
<value>value1</value>
</item>
<item>
<key>item2</key>
<value>value2</value>
</item>
<item>
<key>item3</key>
<value>value3</value>
</item>
</param2>
</ns1:enviarloteeventos>
</soap-env:body></soap-env:envelope>
In the e-social developer guidance manual says that requests should be submitted in this format:
<eSocial xmlns="http://www.esocial.gov.br/schema/evt">
<!-- Xml do Evento -->
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<.../>
</Signature>
</eSocial>
One of my doubts is whether to mount the event XML before and pass as parameter to the SoapCall method, or should I leave it as is? I'm not sure what I did is right.
If you can give me a north I thank you because I'm a bit lost. I've never worked with Soap before.