Can I convert my int datatype variable to longint datatype because I need the object type to be long for soap API (XML)?
CodePudding user response:
To convert PHP variables/arrays and object you can use SoapVar to know further about SoapVar
for your task you need something like $workOrder['ID'] = new SoapVar($data['ID'],XSD_LONG);
to convert PHP object into Soap Object follow the below code, hopefully it will help you in solving your problem
$workOrder = [];
$workOrder['ID'] = new SoapVar($data['ID'],XSD_LONG);
$note = [];
$note['body'] = "valid note body";
$note['date'] = new SoapVar("2022-07-18",XSD_DATETIME);
$note['private'] = true;
$note['subject'] = "valid note subject";
$varNote = new SoapVar($note, SOAP_ENC_OBJECT, 'ns3:Note', null);
$varWorkOrder = new SoapVar($workOrder, SOAP_ENC_OBJECT, 'ns3:WorkOrder', null);
try{
$response2 = $client->attachNoteToWorkOrder($varNote,$varWorkOrder);
}catch (\SoapFault $exception){
// dd($exception);
dd($client->__getLastRequest());
}
dd($response2);