[SOLVED] Is there a way to get datatype long php?

Issue

Can I convert my int datatype variable to longint datatype because I need the object type to be long for soap API (XML)?

Solution

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);

Answered By – Mudassir Ahmad

Answer Checked By – Robin (BugsFixing Admin)

Leave a Reply

Your email address will not be published.