How to parse SOAP response with PHP?

PHP Soap Multiple Concurrent Requests

  • I need to send multiple concurrent soap requests to the same source, but concurrent requests aren't supported in PHP's SOAP implementation. I can extend SoapClient to overwrite the _doRequest function to instead construct a curl handler to run as concurrent curl requests but I'd like to retain as much SOAP functionality as possible - specifically debugging and error catching/reporting. I can run the requests via cURL but how do I turn them back into soap requests so that I only process the successful ones and can report on unsuccessful ones and use __getLastReponse() etc? I found a library from DkLab that claimed to be able to do it but it didn't work - even the basic soap request didn't work, not even trying to do multiple concurrent requests.

  • Answer:

    Can you run multiple PHP instances simultaneously? (Sympathies, I'm dealing with some pretty complex SOAP stuff in Perl right now, and if I weren't already bald I'd be tearing my hair out.)

missmagenta at Ask.Metafilter.Com Visit the source

Was this solution helpful to you?

Other answers

Should mention, its running on Windows+IIS *shudder* and anything that requires the cooperation of the server admins is out of the question. It can take them 6 months to get around to setting up a new domain on the server.

missmagenta

Would it be acceptable to make the requests directly from the browser? If so, some jQuery SOAP plugin should make the asynchronous requests very easy to make and manage.

Monsieur Caution

Well, assuming you can serve it from the same origin as the web services. :)

Monsieur Caution

You're very close, just not thinking in the right way :) You don't want to modify SoapClient. That's going to make it hard to upgrade PHP in the future. Instead, write a worker.php in your app to handle the async requests, and call it asynchronously. The process would look like this: 1) Setup the request and store it in a shared location somewhere (file, memcached, DB, etc). 2) Perform an async curl request to your own server with a URL like worker.php?request_id=(something to identify the request in the shared area) 3) Repeat step (2) as many times as needed. 4) worker.php performs the normal SOAP request synchronously. Maybe it returns the result in a shared location. Maybe it returns it as serialize JSON over the HTTP request. Your choice. 5) In your master process, wait for all the async requests to complete. 6) Continue processing. WP does something similar to handle cron jobs without bogging down the client user. Make sure your worker.php only handles requests from approved hosts (ie: localhost), or authenticates with a shared secret, or uses a unique enough request ID. Just something to make sure external clients can't call it. To your Windows admins it just looks like more HTTP requests.

sbutler

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.