问题
I have a multi-user COM+ application that needs to make multiple requests on SOAP WebServices. Each SOAP request may last from 10 to 60 seconds (that is not under my control). Problem is, I can never make more than 2 requests at the same time.
When I have, for example, 3 concurrent requests the third requests only starts when the second one finishes. I watched the same behaviour on a console application (for testing purposes) making multiple concurrent requests to the same WebService, and I was again limited to 2 requests.
When I tried to consume the same WebServices with another language (C#) the same happened, BUT, on the C# client there is a property that solves the problem:
System.Net.ServicePointManager.DefaultConnectionLimit
When I increased that property I could keep whatever number of concurrent requests I wanted. Is there a property similar to that one on Delphi?
I'm using the WSDL importer tool to consume the Web Services (Delphi XE2).
回答1:
Delphi uses Wininet.dll to make its SOAP requests, IE uses the same DLL. This limitation is in fact documented.
You have 2 choices:
- adapt the registry like stated in the KB article
- Use
InternetSetOption
before the SOAP call:
small code sample (please note that it does not include error checking):
Const
INTERNET_OPTION_MAX_CONNS_PER_SERVER = 73;
INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER = 74;
var
MaxConnections : Integer;
begin
MaxConnections := 10; // adapt to your needs
InternetSetOption(Nil, INTERNET_OPTION_MAX_CONNS_PER_SERVER, @MaxConnections , SizeOf(MaxConnections ));
InternetSetOption(Nil, INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER, @MaxConnections , SizeOf(MaxConnections ));
// do SOAP call
end;
回答2:
By default, Delphi SOAP programs uses WinInet in Windows, and Indy (TIdHTTP) in other platforms (see USE_INDY directive in SOAPHTTPTrans.pas unit), to comunicate with the server. [1]
You can try using Indy on Windows by defining USE_INDY and recompile the SOAP library (however I have not done this myself so the detailed steps to do this are unknown to me).
p.s. the linked article also indicates that UseNagle should be set to False.
来源:https://stackoverflow.com/questions/24936375/delphi-soap-client-can-not-keep-more-than-2-concurrent-requests-how-to-increase