在Windows Server 2008 R2 64位IIS 7.5德尔福XE2
我提出用delphi XE2一个简单的WebService / ISAPI DLL。 这个Web服务有一个返回两数之和做了一个简单的客户端应用程序测试此函数的函数。 当我编译它(连同客户端)作为32位应用程序(在32位启用应用程序池虚拟目录),一切工作正常
当我编译它作为一个64位的DLL(客户端也被编译为64位aplication)我alws“模块地址0000000002199F33访问冲突‘得到一个访问冲突错误“类ERemotableException有消息MyWebService.dll’。读解决0000000000000000' “。
我检查了所有权限IIS7.5我应该做的(32位ISAPI DLL工作正常)和保持的问题出现。
这里是一些简单的测试反馈:
如果我使用的TRemotable类后代来向过程中的数据传递 - >不含Pb
然而,写一个简单的函数返回一个整数导致访问冲突。 我也试着使用原生的Wndows数据类型,比如Int64的没有运气。
也有人有过这样的问题? 因为坦率地说我绝望。
下面是代码:
这是webmodule接口
{ Invokable interface IMyDebugModule }
unit MyDebugModuleIntf;
interface
uses Soap.InvokeRegistry, System.Types, Soap.XSBuiltIns;
type
{ Invokable interfaces must derive from IInvokable }
IMyDebugModule = interface(IInvokable)
['{02A5AD69-24E4-447B-8882-804DA687A0F2}']
{ Methods of Invokable interface must not use the default }
{ calling convention; stdcall is recommended }
//function MyFunc():double;stdcall;
function MyFunc():Int64;stdcall;
end;
implementation
initialization
{ Invokable interfaces must be registered }
InvRegistry.RegisterInterface(TypeInfo(IMyDebugModule));
end.
和implementaion
{ Invokable implementation File for TMyDebugModule which implements IMyDebugModule }
unit MyDebugModuleImpl;
interface
uses Soap.InvokeRegistry, System.Types, Soap.XSBuiltIns, MyDebugModuleIntf;
type
{ TMyDebugModule }
TMyDebugModule = class(TInvokableClass, IMyDebugModule)
public
function MyFunc():Int64;stdcall;
end;
implementation
{ TMyDebugModule }
function TMyDebugModule.MyFunc: Int64;
begin
Result := 101;
end;
{ TMyDebugModule }
initialization
{ Invokable classes must be registered }
InvRegistry.RegisterInvokableClass(TMyDebugModule);
end.
这里是客户端应用程序WSDL文件帕斯卡:
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : C:\MyWorkingDir64\MyTests\WebServiceDebug\Client\IMyDebugModuleWSDL.xml
// Version : 1.0
// (19/04/2013 09:46:52 - - $Rev: 37707 $)
// ************************************************************************ //
unit IMyDebugModuleWSDL;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
type
// ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Embarcadero types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:long - "http://www.w3.org/2001/XMLSchema"[]
// ************************************************************************ //
// Namespace : urn:MyDebugModuleIntf-IMyDebugModule
// soapAction: urn:MyDebugModuleIntf-IMyDebugModule#MyFunc
// transport : http://schemas.xmlsoap.org/soap/http
// style : rpc
// use : encoded
// binding : IMyDebugModulebinding
// service : IMyDebugModuleservice
// port : IMyDebugModulePort
// URL : http://devserver2008/BahaaDebug/BahaaDebug.dll/soap/IMyDebugModule
// ************************************************************************ //
IMyDebugModule = interface(IInvokable)
['{64033E30-8D6E-F252-4E38-55502BF4E1A5}']
function MyFunc: Int64; stdcall;
end;
function GetIMyDebugModule(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): IMyDebugModule;
implementation
uses SysUtils;
function GetIMyDebugModule(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): IMyDebugModule;
const
defWSDL = 'C:\MyWorkingDir64\MyTests\WebServiceDebug\Client\IMyDebugModuleWSDL.xml';
defURL = 'http://devserver2008/BahaaDebug/BahaaDebug.dll/soap/IMyDebugModule';
defSvc = 'IMyDebugModuleservice';
defPrt = 'IMyDebugModulePort';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as IMyDebugModule);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
initialization
{ IMyDebugModule }
InvRegistry.RegisterInterface(TypeInfo(IMyDebugModule), 'urn:MyDebugModuleIntf-IMyDebugModule', '');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(IMyDebugModule), 'urn:MyDebugModuleIntf-IMyDebugModule#MyFunc');
end.
与所述检测单元调用该函数
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, IMyDebugModuleWSDL, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
w:IMyDebugModule;
i:integer;
begin
w := GetIMyDebugModule(True,'',nil);
i := w.MyFunc;
caption := IntToStr(i);
end;
end.