'SOAP Fails to load only on repetitive operations (Fails to load external entity, fails to fetch http headers etc.)
In a project which integrates to third parties through SOAP, I am facing a problem when I need to do some repetitive operations. I have been working with this endpoint for several years. In those years, I have searched SOAP problems for many times, including the ones I mentioned in the question. Usually there is no problem when I make one request to this endpoint. But when it comes to do more requests, right after the second or third, it fails to load by either one of the errors.
Shortly to say;
$service = new SoapClient($wsdl, $options)
$service->UpdateProduct(['id' => 5, 'price' => 150]);
This works pretty fine. But when it comes to;
foreach ($products_to_update as $product) {
$service = new SoapClient($wsdl, $options)
$service->UpdateProduct($product);
}
It fails with either one of these errors right after the second iteration. Oddly, sometimes I see that the service is actually updated for that product at which it claimed to have failed loading the external entity.
Instantiating the client once and calling the method in the iteration doesn't change the outcome.
As a not-very-much-sensical solution, I put a sleep(1); inside the iteration and it works most of the times. But of course in the future, when the number grows, this so-called solution will become obsolete. The service provider doesn't want to provide a method for bulk updating and they refuse to accept that this is a problem and say that "the others are using this service pretty well, so contact us only if that one request fails".
I wonder what would veterans comment about this and and if there could be a possible solution that I could implement without needing the aid of the service provider.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
