web-services - 从 64 位 Delphi DLL 调用 SOAP web 服务

标签 web-services delphi 64-bit isapi

我的 Delphi XE6 项目需要调用基于 SOAP 的网络服务。不幸的是,在 IIS 下从 64 位 DLL 执行此类 Web 服务调用似乎可能存在问题,这就是我的项目将如何部署。

例如,请参阅以下公共(public)网络服务:

http://www.webservicex.net/geoipservice.asmx?WSDL

在创建一个测试 ISAPI 网络服务器项目并导入上面的 WSDL 之后,我尝试使用以下代码进行网络服务调用:

uses activeX, geoipservice;

procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  CountryName : string;
  I : GeoIPServiceSoap;
  G : GeoIP2;
begin
  CoInitialize(nil);
  try
    CountryName := 'unassigned';
    I := GetGeoIPServiceSoap();
    if assigned(I) then begin
      G := I.GetGeoIP('...insert IP address here...');
      if assigned(G) then begin
        countryname := G.CountryName;
      end;
    end;
    Response.Content :=
      '<html>' +
      '<head><title>Web Service Test</title></head>' +
      '<body>Country: ' + CountryName + '</body>' +
      '</html>';
  except
    on E : exception do begin
      Response.Content :=
        '<html>' +
        '<head><title>Web Service Test</title></head>' +
        '<body>Exception: ' + E.ClassName() + ' ' + E.Message + '</body>' +
        '</html>';
    end;
  end;
  CoUninitialize();
end;

当我将项目作为 32 位 ISAPI DLL 运行时,在浏览器中查看网站会导致按预期显示国家/地区名称。当我将项目作为 64 位 ISAPI DLL 运行时,在浏览器中查看网站会导致显示以下错误消息(Zugriffsverletzung = 访问冲突):

Exception: EAccessViolation Zugriffsverletzung bei Adresse 000000C700492460. Schreiben von Adresse 000000C700492460

这似乎与以下问题非常相似:

Delphi XE2 64 bit ISAPI Access Violation

但是那里的问题与 Delphi XE2 有关,据说升级到 Delphi XE4 可以解决问题。我已经在 Delphi XE4 和 XE6 中进行了测试,并且两者都出现了问题。

有没有其他人遇到过这个问题或知道如何解决它?

设置:Delphi XE6、Win8.1、IIS 8.5

最佳答案

我认为问题与 wininet 有关。 Delphi 使用 Wininet(通过 HTTPRIO)连接到 SOAP 服务器(参见 Soap.SOAPHTTPTrans.pas)。但是 Microsoft 表示不支持在服务(例如 IIS)中使用 Wininet,这就是它在控制台应用程序上运行的原因。服务应使用 WinHTTP。 https://support.microsoft.com/en-us/help/238425/info-wininet-not-supported-for-use-in-services

我遇到了同样的问题,并尝试将 Wininet 调用转换为 WinHTTP,但最终我放弃了这个用例的 Delphi,对于这样一个昂贵的工具来说太麻烦了。

关于web-services - 从 64 位 Delphi DLL 调用 SOAP web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28067060/

相关文章:

delphi - 如何销毁运行时定义的 TClientDataSet TFields?

delphi - 在 64 位应用程序中使用 SetupAPI 枚举 USB HID 设备

delphi - 我无法使用 TIdIMAP4 仅检索未读消息

javascript - SOAP Web 服务错误 :Response to preflight request does not pass access control check 'Access-Control-Access-Origin' using SOAPClient. js

web-services - 创建 CXF Web 服务客户端时出现 ServiceConstructionException

c# - .NET Web 服务返回无效的 XML

Delphi FMX 用鼠标调整无边框窗体大小

c# - 多线程 .NET 应用程序导致在 64 位四核 Windows Server 上运行的 KERNEL32.dll 中出现应用程序错误

c++ - 为 x64 平台编译时出现 c2593 错误(运算符标识符不明确)

web-services - Web 应用程序在几个同时 HTTP 请求后被破坏