Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ap3twe's avatar

Sending array of products to API with Soap Call

Guys, can anyone show me how I can send the products as an array based on XML WSDL structure below. It looks like It accepts an array of products. The XML is below.

<s:element minOccurs="0" maxOccurs="1" name="Products" type="tns:ArrayOfDLCPMCaseProduct"/>

This is my soap call. I send it to the API and it works but it only registers one product. I tried to duplicate the product part but does not work

 'DLCPMCaseProduct' => array (
                        'ProductCode' => 'CICGS',
                        'Description' => 'Chrome Money',
                        'Quantity' => '1',
                        'Price' => $GLOBALS['totalCost1'],
                        )
 'DLCPMCaseProduct' => array (
                        'ProductCode' => 'BMIGS',
                        'Description' => 'Kolhn Money',
                        'Quantity' => '2',
                        'Price' => $GLOBALS['totalCost2'],
                        )

// Method

public function AddCaseWebPortal (Request $request, DoctorsChrome $doctorsChrome){   
       $clienttest2 = new SoapClient('https://money***.com/API/DLCPMAPIServer.asmx?WSDL');
       $paramstest2 = array(
           'addCaseReq' => array(
               'DlcpmCase' => array(
                   'CaseID' => '000443',
                   'CaseNumber' => '',
                   'ShipDate' => date("Y-m-d"),
                   'DateIn'=> date("Y-m-d"),
                   'Address'=> $address,
                   'CustomerID' => $customerId,
                   'PatientFirst' => $request->patient_firstname,
                   'PatientLast' =>  $request->patient_lastname,
                   'WebComments' => date('Y-m-d H:i:s'). '  '. \ucwords ($doctorsChrome->owner['drname']). "\r\n" . 
                    "\r\n" .  "\r\n" 
                   'Products' => array(
                   'DLCPMCaseProduct' => array (
                       'ProductCode' => 'CICGS',
                       'Description' => 'Chrome Doctor',
                       'Quantity' => '1',
                       'Price' => $GLOBALS['totalCost'],
                       )
                    ), 
                   ),
               'Auth' => array(
                   'AppName' => 'DLCPM WS',
                   'UserName' => $_ENV['TECKEY'],
                   'Password' => $_ENV['TECPASSWORD'],
                   'DeveloperKey' => $_ENV['TECDEVELOPERKEY']
                   )
               )

           );
       try {
         $responsetest2 = $clienttest2->__soapCall("AddCase", array($paramstest2));

       } catch (Exception $e) {
           echo 'Caught exception: ',  $e->getMessage(), "\r\n";
       }
   }

// Soap Schema

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <AddCase xmlns="http://tempuri.org/">
            <!-- Optional -->
            <addCaseReq>
                <!-- Optional -->
                <Auth>
                    <AppName>[string?]</AppName>
                    <DeveloperKey>[string?]</DeveloperKey>
                    <UserName>[string?]</UserName>
                    <Password>[string?]</Password>
                </Auth>
                <!-- Optional -->
                <DlcpmCase>
                    <CaseID>[string?]</CaseID>
                    <CaseNumber>[int]</CaseNumber>
                    <CustomerID>[string?]</CustomerID>
                    <PatientFirst>[string?]</PatientFirst>
                    <PatientLast>[string?]</PatientLast>
                    <LabName>[string?]</LabName>
                    <Shade>[string?]</Shade>
                    <RxNumber>[string?]</RxNumber>
                    <ShipDate>[dateTime]</ShipDate>
                    <DateIn>[dateTime]</DateIn>
                    <DueDate>[dateTime]</DueDate>
                    <DoctorName>[string?]</DoctorName>
                    <PracticeDoctorID>[string?]</PracticeDoctorID>
                    <PanNumber>[string?]</PanNumber>
                    <Carrier>[string?]</Carrier>
                    <CarrierServiceType>[string?]</CarrierServiceType>
                    <WebComments>[string?]</WebComments>
                    <WorkorderNotes>[string?]</WorkorderNotes>
                    <!-- Optional -->
                    <Products>
                        <!-- Optional -->
                        <DLCPMCaseProduct>
                            <CPID>[string?]</CPID>
                            <ProductCode>[string?]</ProductCode>
                            <Description>[string?]</Description>
                            <Quantity>[double]</Quantity>
                            <Price>[double]</Price>
                            <ToothStr>[string?]</ToothStr>
                            <ToothStr2>[string?]</ToothStr2>
                            <Shade>[string?]</Shade>
                        </DLCPMCaseProduct>
                    </Products>
                </DlcpmCase>
            </addCaseReq>
        </AddCase>
    </Body>
</Envelope>
0 likes
3 replies
Ap3twe's avatar

Sorry, I didn't find anything relatable. My only concern is send array of the products

Please or to participate in this conversation.