如何用Delphi7写一个WebService服务端程序,并验证它

skyclin 2010-09-09 03:29:42
各位大侠!本人搞delphi多年,却没接触过WebSerice开发,现在书店里也没有Delphi相关的书了,只能向大家请教了!
现在手工要做一个接口程序,用于两套系统进行数据交换,而确定采用WebService来实现,提供的接口完成向双方传递XML文件数据。(XML文件数据肯定要从我方的数据库中提取的)

我现在却不知道怎么动手啊!!各位大侠,能不能教我一步一步的做啊。尽量详细一点!
...全文
894 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
yueziaixin 2011-11-04
  • 打赏
  • 举报
回复
希望大家多多交流,交流过程中可以相互学习。
顶一下哈
L3nnon 2010-09-16
  • 打赏
  • 举报
回复
学习学习。。
顶一下吧。
liangpei2008 2010-09-16
  • 打赏
  • 举报
回复
嗯,用.NET可以快速地解决
一剑飘雪 2010-09-16
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 kye_jufei 的回复:]
用web寫一個webservice,直接調用。。。

1.利用webservice生成pas:

Delphi(Pascal) code
// ************************************************************************ //
// The types declared in this file were genera……
[/Quote]
这个不错
PS:能否把你图像换调?嘻嘻
kye_jufei 2010-09-16
  • 打赏
  • 举报
回复
用web寫一個webservice,直接調用。。。

1.利用webservice生成pas:
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://172.20.100.10/test/service.asmx?wsdl
// >Import : http://172.20.100.10/test/service.asmx?wsdl:0
// Encoding : utf-8
// Version : 1.0
// (2010/6/22 上午 11:31:35 - - $Rev: 10138 $)
// ************************************************************************ //

unit service;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

const
IS_OPTN = $0001;
IS_REF = $0080;


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 Borland types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"[Gbl]



// ************************************************************************ //
// Namespace : Kye
// soapAction: Kye/HelloWorld
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : ServiceSoap
// service : Service
// port : ServiceSoap
// URL : http://172.20.100.10/test/service.asmx
// ************************************************************************ //
ServiceSoap = interface(IInvokable)
['{B82FAFBA-EAB8-AD5C-2535-FB6046355616}']
function HelloWorld(const name_: WideString): WideString; stdcall;
end;

function GetServiceSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): ServiceSoap;


implementation
uses SysUtils;

function GetServiceSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ServiceSoap;
const
defWSDL = 'http://172.20.100.10/test/service.asmx?wsdl';
defURL = 'http://172.20.100.10/test/service.asmx';
defSvc = 'Service';
defPrt = 'ServiceSoap';
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 ServiceSoap);
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
InvRegistry.RegisterInterface(TypeInfo(ServiceSoap), 'Kye', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ServiceSoap), 'Kye/HelloWorld');
InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap), ioDocument);
InvRegistry.RegisterExternalParamName(TypeInfo(ServiceSoap), 'HelloWorld', 'name_', 'name');

end.


2.調用:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,service, StdCtrls;

type
TForm1 = class(TForm)
btn1: TButton;
edt1: TEdit;
Label1: TLabel;
procedure btn1Click(Sender: TObject);
private
aa:ServiceSoap;
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btn1Click(Sender: TObject);
begin
aa:=GetServiceSoap(False,'',nil);
ShowMessage(aa.HelloWorld(edt1.Text));
end;

end.

L3nnon 2010-09-16
  • 打赏
  • 举报
回复
顶回第一页。。
别忘了报答我哦。。
zhangxuyu1118 2010-09-14
  • 打赏
  • 举报
回复
顺便说下,很多在校新生都帮我完成了不少这样的类似的任务了。精通一门工具是好事,但千万别拘泥仅用于一种工具来完成所有任务。尺有所短,寸有所长。
zhangxuyu1118 2010-09-14
  • 打赏
  • 举报
回复
我也搞D多年,为什么不用.net呢。既然“确定采用WebService来实现”,那首先考虑的是应该有个WEB服务器。自己去开发ISAPI或者CGI程序,首先考虑稳定性能保证吗。
所以,我的首选肯定是IIS,用ASP.NET来解决你的问题简直小菜一碟。
aotofan 2010-09-13
  • 打赏
  • 举报
回复
学习中。。。。。。。。
L3nnon 2010-09-10
  • 打赏
  • 举报
回复
参考参考。。
谢谢你,让我学习啦。。
haitao 2010-09-09
  • 打赏
  • 举报
回复
好像有向导的吧

不过,delphi的ws和java/.net的不一定兼容
这个就像java的跨平台,其实不同版本都不一定兼容
dd_zhouqian 2010-09-09
  • 打赏
  • 举报
回复
网络很多例子,楼主可以参照下

http://so.csdn.net/bbsSearchResult.aspx?q=webservice&category=DC0369D7-BC4B-48FF-8FFA-24B46529CAB3,D593354E-8665-4410-94B5-508D935F5083,8AB98CD6-4AFB-4F14-947B-586DBA0AD98A,86FDA20C-918F-4004-9A60-83AC6156C017,4478B4F9-6258-4863-9A4B-87351EE3020B,E11D0C0D-A74C-4F5C-A57E-B77D7DD8FCE8,2D8A999F-B552-4BF1-81B2-DA785BDC082A&uname=&rname=&d1=2010-06-09&d2=2010-09-09&field=all
YLCN2010 2010-09-09
  • 打赏
  • 举报
回复
用IntraWeb,控件实现方式网上找,一大堆,Indy不是那么的强悍。。。
Im17benteng 2010-09-09
  • 打赏
  • 举报
回复
intraweb 听说过吗?

或直接用indy httpserver实现

webservice就是一http服务器嘛

xml解析功能自己实现

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧