0

I have several SOAP requests which i am handling by using curl_exec. My code looks like this:

 $xml_data1 = '<soapenv:Envelope xmlns:xsi="example" xmlns:xsd="example" xmlns:home="example">
                    <soapenv:Header/>
                    <soapenv:Body>
                       BODY OF THE SOAP- deleted for simplified example
                    </soapenv:Body>
                 </soapenv:Envelope>';


         $URL = 'example_URL';

         $ch = curl_init($URL);
         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data1");
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $output = curl_exec($ch);
         curl_close($ch);


$xml_data2 = '<soapenv:Envelope xmlns:xsi="example" xmlns:xsd="example" xmlns:home="example">
                    <soapenv:Header/>
                    <soapenv:Body>
                       BODY OF THE SOAP- deleted for simplified example
                    </soapenv:Body>
                 </soapenv:Envelope>';


         $URL = 'example_URL';

         $ch = curl_init($URL);
         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data2");
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $output = curl_exec($ch);
         curl_close($ch);


...etc.


return view("Simulation/step2");

There are around 18 of them and the whole thing takes up to 4 mins, which is way more than i would want. I want to use async but i am not sure how it works in PHP. As well, i am using Code Igniter as a framework. Thank you in advance!

potato
  • 35
  • 4

0 Answers0