读书人

请问一个有关webservice的有关问题,还

发布时间: 2012-02-23 22:01:36 作者: rapoo

请教一个有关webservice的问题,还请帮忙看看,谢谢!
请问一个关于webservice的问题,服务端只有一个接口IFistWS:
type
IFirstWS=interface(IInvokable)
[ '{4D72FE8F-6543-4DC0-91ED-796746BF4E13} ']
function GetWSMsg:WideString;stdcall;
end;

implementation

uses
InvokeRegistry;

initialization
InvRegistry.RegisterInterface(TypeInfo(IFirstWS));

=====TFirstWS实现上面的接口:
type
TFistWS=class(TInterfacedObject,IFirstWS)
public
function GetWSMsg : widestring; stdcall;
end;

implementation

{ TFistWS }

function TFistWS.GetWSMsg: widestring;
begin
Result:= 'Test Good ';
end;

procedure FirstWSFactory(out obj:TObject);
begin
obj:=TFistWS.Create;
end;

initialization
InvRegistry.RegisterInvokableClass(TFistWS,FirstWSFactory);

end.
///////////////////////////////////
客户端的HTTPRIO1的WSDLLOCATION我设置为:
http://localhost:8081/FirstWEBService.WSDemo1/wsdl/IFirstWS
我在web app debugger中看到的地址是这个。
PORT:IFirstWSPort和Serice:IFirstWSservice
都是从下拉框中的选中的。

我在button1中的代码为:
implementation

{$R *.dfm}

uses
FirstWSIntf;

procedure TForm1.BitBtn1Click(Sender: TObject);
var
IFWebClient:IFirstWS;
begin
IFWebClient:=HTTPRIO1 as IFirstWS;
try
Edit1.Text:=IFWebClient.GetWSMsg;
finally
IFWebclient:=nil;
end;
end;

//执行到Edit1.Text:=IFWebClient.GetWSMsg;这一句时报错,提示如下:
Project clientapp.exe raised exception class ERemotableExcpetion with message 'Invalid pointer operation ',Process stopped.Use Step or Run to continue.
这个错误是怎么造成的?还请各位大侠们帮忙指点,谢谢!
我在调试服务端时,发现是在_FreeMem(self)这一步报的错。

[解决办法]
直接将调用服务器的代码修改为:

Edit1.Text:=(HTTPRIO1 as IFirstWS).GetWSMsg;

试试;

读书人网 >.NET

热点推荐