Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. <?php
  2. // Pendling Async SOAP requests
  3. $_soapRequests = array();
  4. $_soapResponses = array();
  5. function soap_dispatch()
  6. {
  7. global $_soapRequests;
  8. global $_soapResponses;
  9. if (!in_array('curl', get_loaded_extensions())) {
  10. foreach ($_soapRequests as $id => $ch)
  11. $_soapResponses[$id] = true;
  12. $_soapRequests = array();
  13. return;
  14. }
  15. $mh = curl_multi_init();
  16. foreach ($_soapRequests as $ch)
  17. curl_multi_add_handle($mh, $ch);
  18. $active = null;
  19. do {
  20. $mrc = curl_multi_exec($mh, $active);
  21. } while ($mrc == CURLM_CALL_MULTI_PERFORM);
  22. while ($active && $mrc == CURLM_OK) {
  23. if (curl_multi_select($mh) == -1) usleep(100000);
  24. do {
  25. $mrc = curl_multi_exec($mh, $active);
  26. } while ($mrc == CURLM_CALL_MULTI_PERFORM);
  27. }
  28. foreach ($_soapRequests as $id => $ch) {
  29. $_soapResponses[$id] = curl_multi_getcontent($ch);
  30. if ($_soapResponses[$id] === NULL)
  31. $_soapResponses[$id] = new SoapFault("HTTP", curl_error($ch));
  32. curl_multi_remove_handle($mh, $ch);
  33. curl_close($ch);
  34. }
  35. curl_multi_close($mh);
  36. $_soapRequests = array();
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement