用Delphi编写Web Service

一、Delphi中编写Web Service的步骤如下:
1. File->New->other;

2. 在打开的对话框中,选择Web Services->SOAP Server Application


3. 选择ISAPI DLL


4. 选择Yes,自动生成接口和实现文件

也可以选择No,可以使用SOAP Server Interface向导来添加接口:


5. 输入接口名称

输入名称XXX后,会自动生成XXXIntf.pas和XXXImpl.pas文件,分别对应接口和类的实现。

二、代码范例
1. XXXIntf.pas

{ Invokable interface ISampleService }

unit SampleServiceIntf;

interface

uses InvokeRegistry, Types, XSBuiltIns;

type

  { Invokable interfaces must derive from IInvokable }
  ISampleService = interface(IInvokable)
  ['{FD7D3BA8-8FE8-47F7-8A06-08A8663A4FF3}']

    { Methods of Invokable interface must not use the default }
    { calling convention; stdcall is recommended }
  end;

implementation

initialization
  { Invokable interfaces must be registered }
  InvRegistry.RegisterInterface(TypeInfo(ISampleService));

end.

2. XXXImpl.pas
{ Invokable implementation File for TSampleService which implements ISampleService }

unit SampleServiceImpl;

interface

uses InvokeRegistry, Types, XSBuiltIns, SampleServiceIntf;

type

  { TSampleService }
  TSampleService = class(TInvokableClass, ISampleService)
  public
  end;

implementation


initialization
{ Invokable classes must be registered }
   InvRegistry.RegisterInvokableClass(TSampleService);
end.



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值