I would like to add a note in case other people try to implement the SII from PHP.
You do not really need to create classes / objects for the data structure.
That is, simply create a PHP multi-level associative array with the entire structure and pass it as a parameter to the function that we call, and that is enough, then the same SOAP client is responsible for coding the data with the necessary XML structure.
Example of the PHP array with var_export ():
$datos=array (
'Cabecera' =>
array (
'IDVersionSii' => '1.0',
'Titular' =>
array (
'NombreRazon' => 'ALEXANDRU CATALIN TRANDAFIR',
'NIF' => 'X4378072E',
),
'TipoComunicacion' => 'A0',
),
'RegistroLRFacturasEmitidas' =>
array (
0 =>
array (
'PeriodoImpositivo' =>
array (
'Ejercicio' => '2017',
'Periodo' => '12',
),
'IDFactura' =>
array (
'IDEmisorFactura' =>
array (
'NIF' => 'X4378072E',
),
'NumSerieFacturaEmisor' => 'SIIDEMO/1',
'FechaExpedicionFacturaEmisor' => '31-12-2017',
),
'FacturaExpedida' =>
array (
'TipoFactura' => 'F1',
'ClaveRegimenEspecialOTrascendencia' => '01',
'ImporteTotal' => 1210,
'DescripcionOperacion' => 'Compra ordenador portátil',
'FechaOperacion' => '31-12-2017',
'Contraparte' =>
array (
'NombreRazon' => 'HeavyDots SL',
'NIF' => 'B66544586',
),
'TipoDesglose' =>
array (
'DesgloseFactura' =>
array (
'Sujeta' =>
array (
'NoExenta' =>
array (
'TipoNoExenta' => 'S1',
'DesgloseIVA' =>
array (
'DetalleIVA' =>
array (
0 =>
array (
'TipoImpositivo' => 21,
'BaseImponible' => 500,
'CuotaRepercutida' => 105,
),
1 =>
array (
'TipoImpositivo' => 21,
'BaseImponible' => 500,
'CuotaRepercutida' => 105,
),
),
),
),
),
),
),
),
),
1 =>
array (
'PeriodoImpositivo' =>
array (
'Ejercicio' => '2017',
'Periodo' => '12',
),
'IDFactura' =>
array (
'IDEmisorFactura' =>
array (
'NIF' => 'X4378072E',
),
'NumSerieFacturaEmisor' => 'SIIDEMO/2',
'FechaExpedicionFacturaEmisor' => '31-12-2017',
),
'FacturaExpedida' =>
array (
'TipoFactura' => 'F1',
'ClaveRegimenEspecialOTrascendencia' => '01',
'ImporteTotal' => 1210,
'DescripcionOperacion' => 'Compra ordenador portátil',
'FechaOperacion' => '31-12-2017',
'Contraparte' =>
array (
'NombreRazon' => 'HeavyDots SL',
'NIF' => 'B66544586',
),
'TipoDesglose' =>
array (
'DesgloseFactura' =>
array (
'Sujeta' =>
array (
'NoExenta' =>
array (
'TipoNoExenta' => 'S1',
'DesgloseIVA' =>
array (
'DetalleIVA' =>
array (
0 =>
array (
'TipoImpositivo' => 21,
'BaseImponible' => 500,
'CuotaRepercutida' => 105,
),
1 =>
array (
'TipoImpositivo' => 21,
'BaseImponible' => 500,
'CuotaRepercutida' => 105,
),
),
),
),
),
),
),
),
),
),
)
Then the call:
$comando = 'SuministroLRFacturasEmitidas';
$response = $client->$comando($datos);
And then if we want we can get the generated XML like this:
$peticion_xml = $client->__getLastRequest();
Generated XML:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/ssii/fact/ws/SuministroInformacion.xsd" xmlns:ns2="https://www2.agenciatributaria.gob.es/static_files/common/internet/dep/aplicaciones/es/aeat/ssii/fact/ws/SuministroLR.xsd">
<SOAP-ENV:Body>
<ns2:SuministroLRFacturasEmitidas>
<ns1:Cabecera>
<ns1:IDVersionSii>1.0</ns1:IDVersionSii>
<ns1:Titular>
<ns1:NombreRazon>ALEXANDRU CATALIN TRANDAFIR</ns1:NombreRazon>
<ns1:NIF>X4378072E</ns1:NIF>
</ns1:Titular>
<ns1:TipoComunicacion>A0</ns1:TipoComunicacion>
</ns1:Cabecera>
<ns2:RegistroLRFacturasEmitidas>
<ns1:PeriodoImpositivo>
<ns1:Ejercicio>2017</ns1:Ejercicio>
<ns1:Periodo>12</ns1:Periodo>
</ns1:PeriodoImpositivo>
<ns2:IDFactura>
<ns1:IDEmisorFactura>
<ns1:NIF>X4378072E</ns1:NIF>
</ns1:IDEmisorFactura>
<ns1:NumSerieFacturaEmisor>SIIDEMO/1</ns1:NumSerieFacturaEmisor>
<ns1:FechaExpedicionFacturaEmisor>31-12-2017</ns1:FechaExpedicionFacturaEmisor>
</ns2:IDFactura>
<ns2:FacturaExpedida>
<ns1:TipoFactura>F1</ns1:TipoFactura>
<ns1:FechaOperacion>31-12-2017</ns1:FechaOperacion>
<ns1:ClaveRegimenEspecialOTrascendencia>01</ns1:ClaveRegimenEspecialOTrascendencia>
<ns1:ImporteTotal>1210</ns1:ImporteTotal>
<ns1:DescripcionOperacion>Compra ordenador portátil</ns1:DescripcionOperacion>
<ns1:Contraparte>
<ns1:NombreRazon>HeavyDots SL</ns1:NombreRazon>
<ns1:NIF>B66544586</ns1:NIF>
</ns1:Contraparte>
<ns1:TipoDesglose>
<ns1:DesgloseFactura>
<ns1:Sujeta>
<ns1:NoExenta>
<ns1:TipoNoExenta>S1</ns1:TipoNoExenta>
<ns1:DesgloseIVA>
<ns1:DetalleIVA>
<ns1:TipoImpositivo>21</ns1:TipoImpositivo>
<ns1:BaseImponible>500</ns1:BaseImponible>
<ns1:CuotaRepercutida>105</ns1:CuotaRepercutida>
</ns1:DetalleIVA>
<ns1:DetalleIVA>
<ns1:TipoImpositivo>21</ns1:TipoImpositivo>
<ns1:BaseImponible>500</ns1:BaseImponible>
<ns1:CuotaRepercutida>105</ns1:CuotaRepercutida>
</ns1:DetalleIVA>
</ns1:DesgloseIVA>
</ns1:NoExenta>
</ns1:Sujeta>
</ns1:DesgloseFactura>
</ns1:TipoDesglose>
</ns2:FacturaExpedida>
</ns2:RegistroLRFacturasEmitidas>
<ns2:RegistroLRFacturasEmitidas>
<ns1:PeriodoImpositivo>
<ns1:Ejercicio>2017</ns1:Ejercicio>
<ns1:Periodo>12</ns1:Periodo>
</ns1:PeriodoImpositivo>
<ns2:IDFactura>
<ns1:IDEmisorFactura>
<ns1:NIF>X4378072E</ns1:NIF>
</ns1:IDEmisorFactura>
<ns1:NumSerieFacturaEmisor>SIIDEMO/2</ns1:NumSerieFacturaEmisor>
<ns1:FechaExpedicionFacturaEmisor>31-12-2017</ns1:FechaExpedicionFacturaEmisor>
</ns2:IDFactura>
<ns2:FacturaExpedida>
<ns1:TipoFactura>F1</ns1:TipoFactura>
<ns1:FechaOperacion>31-12-2017</ns1:FechaOperacion>
<ns1:ClaveRegimenEspecialOTrascendencia>01</ns1:ClaveRegimenEspecialOTrascendencia>
<ns1:ImporteTotal>1210</ns1:ImporteTotal>
<ns1:DescripcionOperacion>Compra ordenador portátil</ns1:DescripcionOperacion>
<ns1:Contraparte>
<ns1:NombreRazon>HeavyDots SL</ns1:NombreRazon>
<ns1:NIF>B66544586</ns1:NIF>
</ns1:Contraparte>
<ns1:TipoDesglose>
<ns1:DesgloseFactura>
<ns1:Sujeta>
<ns1:NoExenta>
<ns1:TipoNoExenta>S1</ns1:TipoNoExenta>
<ns1:DesgloseIVA>
<ns1:DetalleIVA>
<ns1:TipoImpositivo>21</ns1:TipoImpositivo>
<ns1:BaseImponible>500</ns1:BaseImponible>
<ns1:CuotaRepercutida>105</ns1:CuotaRepercutida>
</ns1:DetalleIVA>
<ns1:DetalleIVA>
<ns1:TipoImpositivo>21</ns1:TipoImpositivo>
<ns1:BaseImponible>500</ns1:BaseImponible>
<ns1:CuotaRepercutida>105</ns1:CuotaRepercutida>
</ns1:DetalleIVA>
</ns1:DesgloseIVA>
</ns1:NoExenta>
</ns1:Sujeta>
</ns1:DesgloseFactura>
</ns1:TipoDesglose>
</ns2:FacturaExpedida>
</ns2:RegistroLRFacturasEmitidas>
</ns2:SuministroLRFacturasEmitidas>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
For those who are still interested in integrating SII in PHP applications (and not only), I would like to tell you that I will soon finish writing and publishing the ebook / tutorial at link