Delphi Soap WebServer 一次不允许超过 2 个调用



我对SOAP web服务器有一个问题:如果我在服务器上有一个方法需要几秒钟才能给出结果,并且我不能从我的客户端应用程序(在Delphi中开发-只是为了测试,最终的客户端应用程序将是基于web的(进行两次以上的"simouselly"调用(从线程调用(。我的意思是,线程是以某种方式序列化的,我不知道是应该这样发生,还是我做错了什么,或者我是否需要进行特定的设置。

Delphi XE2 Professional,Windows 7 64位

链接到我的压缩项目:http://1drv.ms/Nwu9nY

服务器方法:

function TServiciu.Test: string;
var t0, t1, Duration : Cardinal;
    Guid : tguid;
    RGuid : HRESULT;
    received : boolean;
const MaxTime : Cardinal = 3000;
begin
  Result := '';
  RGuid := CreateGuid(Guid);
  if RGuid = S_OK then
    Result := GuidToString(Guid);
  t0 := GetTickCount;
  t1 := GetTickCount;
  duration := t1 - t0;
  while (Duration < Maxtime) do begin
    //waiting for something to be written in a db by another program
    //I am doing querys to the database for that result
    if received then begin
      Result := Result + '_RECEIVED_' + DateTimeToStr(Now);
      Break;
    end;
    t1 := GetTickCount;
    duration := t1 - t0;
    if duration > Maxtime then begin //MaxTime allowed is exceded
      Result := Result + '_NOTRECEIVED_' + DateTimeToStr(Now);
      Break;
    end;
  end;
end;

客户端过程执行我的线程:

procedure TThreadTest.Execute;
begin
  try
    // OleCheck will raise an error if the call fails
    OleCheck(CoInitializeEx(NIL, COINIT_MULTITHREADED or COINIT_SPEED_OVER_MEMORY));
    try
      s := 'Calling Method Test; Result=' +
      Self.ThGetService.Test;
      Synchronize(self.ScrieRezultat); //write result in memo
    finally
      CoUninitialize;
      FreeAndNil(self.ThHttprio);
    end;
  except
    // We failed, do something
  end;
end;

我能够毫不费力地处理40个并发调用(实际上不止于此(,但我使用的是另一种方法。我的服务是一个CGI可执行文件,所以IIS管理连接。当发出SOAP请求时,IIS启动myapp_cgi.exe的新实例来处理该请求。我的最高性能是40个TPS,但我在4台服务器上实现了负载平衡,所以我实际上可以做160个TPS,如果必要的话,可以全天持续。

你好,我解决了我的问题,这件事很愚蠢,我把我的服务器设置为HTTP1.1。与单个HTTP 1.1服务器的连接仅限于两个同时连接。http://support2.microsoft.com/kb/183110

我刚刚遇到了一个非常类似的问题,我很确定你的问题是在你的客户端上,而不是在你的服务器上。请参阅此处的此主题。

最新更新