I'm trying to call a soap webservice method in php but I get the following error: Reference to object not established as an instance of an object.
This is the structure of the method I want to call:
pr($client->__getTypes());
[0] => struct VentaDT {
Encabezado Encabezado;
Cuerpo Cuerpo;
}
[1] => struct Encabezado {
dateTime FechaEntrega;
decimal Amex;
decimal Tarjeta;
}
[2] => struct Cuerpo {
string Producto_Id;
decimal Cantidad;
decimal Precio;
}
The WebService need save the data in 2 Tables: Encabezado and Cuerpo.
I tried to create a class for each table or send it as an array, but I get the same result.
I have also tried SoapVar and SoapParam but it still gives me the same error
This is my PHP Code:
$wsdl = "http://irusalserver.dns-dns.com/eComerce/Servicio.asmx?wsdl";
$client = new SoapClient($wsdl,
array(
'trace' => 1,
'exceptions'=>1
)
);
$encabezado = new Encabezado();
$cuerpo = new Cuerpo();
$encabezado->FechaEntrega = '2019-08-16 2:20:00';
$encabezado->Amex = 0;
$encabezado->Tarjeta = sprintf('%01.2f',629.30);
$cuerpo->Producto_Id = '013059';
$cuerpo->Cantidad = 1;
$cuerpo->Precio = sprintf('%01.2f',629.30);
$result = $client->__soapCall('GenerarVenta',
array(
$encabezado,
$cuerpo
)
);
pr($result);
/********* With SoapVar and SoapParam **************/
$encabezado_struct = new SoapVar($encabezado, SOAP_ENC_OBJECT,
"Encabezado","http://tempuri.org/VentaDT.xsd");
$cuerpo_struct = new SoapVar($cuerpo, SOAP_ENC_OBJECT,
"Cuerpo","http://tempuri.org/VentaDT.xsd");
$encabezadoParam = new SoapParam($encabezado_struct, "Encabezado");
$cuerpoParam = new SoapParam($cuerpo_struct, "Cuerpo");
$response = $client->__soapCall("GenerarVenta",
array(
$encabezadoParam,
$cuerpoParam
)
);
pr($response);
I get the error: Reference to object not established as an instance of an object.
What am I doing wrong?
I hope and someone can help me please.
Thank you.