确保之前的MySOAPServer.exe已经运行,在IE中打开地址http://localhost:1024/wsdl/IMySOAPWebService进行确认。
点击菜单File --> New --> Application,在窗体从标准控件中上放一个Button,一个Label,从WebServices控件中放一个HTTPRIO到窗体上。
排列一下Button1与Label1的位置,让它看起来漂亮一点。
点击菜单View --> Project Manager打开项目管理器,展开Project(n).exe目录
展开Unit1,双击Form1,按F11激活对象观察器,将Name属性由Form1改为MySOAPClientForm。
点击菜单File --> New --> Other,选WebServices标签,选中WSDL Importer图标,点OK
在WSDL Import向导窗口中输入WSDL文件的URL:http://localhost:1024/wsdl/IMySOAPWebService
然后点击下一步,最后点击Finish.
点击菜单View --> Project Manager打开项目管理器,双击Unit1.pas,在interface部分uses单元IMySOAPWebService1
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, IMySOAPWebService1;
对于 WSDLLocation属性,从下拉列表中选择 http://localhost:1024/wsdl/IMySOAPWebService
对于 Service属性,从下拉列表中选择 IMySOAPWebServiceservice
对于 Port 属性,从下拉列表中选择 IMySOAPWebServicePort
点击菜单View --> Project Manager打开项目管理器,双击MySOAPClientForm,再双击Button1
在 Button1Click方法中输入:
begin Label1.Caption :=(HTTPRIO1 as IMYSOAPWebService).HelloWorld('Worked!'); end;
现在你可以保存文件:
点菜单File --> Save Project As,将Unit1保存为MySOAPClientFormU.pas
IMySOAPWebService1保存为MySOAPWebServiceClientIntf.pas
Project1保存为MySOAPClient.dpr
点击菜单View --> Project Manager打开项目管理器,展开MySOAPClientForm,双击MySOAPClientFormU.pas,
将引用IMySOAPWebService1改为MySOAPWebServiceClientIntf。
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, MySOAPWebServiceClientIntf, InvokeRegistry, Rio, SOAPHTTPClient, StdCtrls;