I am using WebServiceCallout.invoke inside a batch to call a SOAP webservice in Dynamics AX. The batch size is 1. What I am seeing: after 9 or 10 fast (1 second) and successful callouts, the next one fails with an error message:
The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
After that, 9 or 10 fast and successful callouts, and then another timeout. Etcetera, etcetera.
The problem is not with the request per se: if I fire it individually, it returns data in 1 second.
The timeout for WebServiceCallout.invoke is set to 2 minutes. The Dynamics people are reluctant to increase the timeout on their side and I think I agree with them that it will not solve the problem. The callout will probably still timeout and not return data. They ask: are you closing your connections?
I don't know, I just use WebServiceCallout.invoke. It's the only method in the WebServiceCallout class. Also, I can't find a way to pass options to invoke that have something to do with closing. Anybody seen this before? Any ideas?