Consume multiple Webservices with PHP at the same time (SOAP and REST)

Asked

Viewed 607 times

0

Basically, I need to consume several Web Services and then merge the results.

I was using Curl with PHP to make the requests, but as the number of Web Services increased, my service became slower, since it was necessary to wait for a reply and, only then, make the request for the next Web Service.

I solved this problem using curl_multi and everything was working properly.

What happens is that I have new Web Services to add to my service, but these new ones use the protocol SOAP and I’m no longer able to make simultaneous requests, because to consult SOAP Web Services I use Soapclient and not Curl.

I know I can make the XML of SOAP "in hand" and then send it along with others using Curl, but this seems to me a bad practice.

In short, there is some way to consume REST and SOAP Web Services simultaneously with PHP?

I asked the same question in So_en, but I did not receive any reply.

  • 2

    my suggestion (does not seem to me a very good practice, but should solve), is to consume the SOAP Webservice in a thread using existing code, the negative part is having to store the result of thread (BD or file, session should not work) and synchronize the return manually. Look that answer.

  • Thanks for the @Sanction tip. I thought about threaded as well, but I ran into other problems with this approach. I will analyze the link you gave me, I had not considered calling a . php through exec, but it can work even though it seems like a bad practice as you well noted.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.