相关资料:http://www.2ccc.com/news/Html/?1507.html

DelphiXE7新建WebService具体操作
1.打开“DelphiXE7”->“File”->“New”->“Other”
2.“New Items”->“Delphi Projects”->“WebSrvice”->“SOAP Server Application”
3.“Stand-alone application”->“Next”
4.“VCL application”->“Next”
5.“8080”->“Finish”
6.“Create Interface for SOAPmodule?”->“Yes”
7.“Add New WebService”->输入服务名字“MyData”->“OK”
8.保存全部工程文件
9.在“WebModuleUnit1”单元中放入控件:
FDConnection1
FDPhysMSSQLDriverLink1
FDQuery1
DataSetProvider1
ClientDataSet1
10.双击FDConnection1->Definition->Driver ID:->“MSAcc”->Daabase->“E:\MyData.mdb”->LoginPrompt:=False->Connected:=True
11.FDQuery1->Connection:=FDConnection1->SQL:=“select * from usesr”->Active:=True
12.DataSetProvider1->DataSet:=FDQuery1
13.ClientDataSet1->ProvideName:=DataSetProvider1

服务端-实例代码:

 1 unit WebModuleUnit1;
2
3 interface
4
5 uses System.SysUtils, System.Classes, Web.HTTPApp, Soap.InvokeRegistry,
6 Soap.WSDLIntf, System.TypInfo, Soap.WebServExp, Soap.WSDLBind, Xml.XMLSchema,
7 Soap.WSDLPub, Soap.SOAPPasInv, Soap.SOAPHTTPPasInv, Soap.SOAPHTTPDisp,
8 Soap.WebBrokerSOAP, FireDAC.Stan.Intf, FireDAC.Stan.Option,
9 FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
10 FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.MSAcc,
11 FireDAC.Phys.MSAccDef, FireDAC.Phys.MSSQLDef, FireDAC.Stan.Param,
12 FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, Datasnap.DBClient,
13 Datasnap.Provider, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client,
14 FireDAC.Phys.ODBCBase, FireDAC.Phys.MSSQL;
15
16 type
17 TWebModule1 = class(TWebModule)
18 HTTPSoapDispatcher1: THTTPSoapDispatcher;
19 HTTPSoapPascalInvoker1: THTTPSoapPascalInvoker;
20 WSDLHTMLPublish1: TWSDLHTMLPublish;
21 FDConnection1: TFDConnection;
22 FDPhysMSSQLDriverLink1: TFDPhysMSSQLDriverLink;
23 FDQuery1: TFDQuery;
24 DataSetProvider1: TDataSetProvider;
25 ClientDataSet1: TClientDataSet;
26 procedure WebModule1DefaultHandlerAction(Sender: TObject;
27 Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
28 private
29 { Private declarations }
30 public
31 function GetInfo: widestring;
32 function SetSQL(ASQL: widestring): widestring;
33 { Public declarations }
34 end;
35
36 var
37 WebModuleClass: TComponentClass = TWebModule1;
38
39 implementation
40
41 {%CLASSGROUP 'Vcl.Controls.TControl'}
42
43 {$R *.dfm}
44
45 function TWebModule1.GetInfo: widestring;
46 begin
47 ClientDataSet1.Close;
48 ClientDataSet1.Open;
49 Result := ClientDataSet1.XMLData;
50 ClientDataSet1.Close;
51 end;
52
53 function TWebModule1.SetSQL(ASQL: widestring): widestring;
54 begin
55 FDQuery1.Close;
56 FDQuery1.SQL.Text := ASQL;
57 try
58 FDQuery1.ExecSQL;
59 Result := '成功 ';
60 except
61 Result := '失败';
62 end;
63 end;
64
65 procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
66 Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
67 begin
68 WSDLHTMLPublish1.ServiceInfo(Sender, Request, Response, Handled);
69 end;
70
71 end.
 1 { Invokable interface IMyData }
2
3 unit MyDataIntf;
4
5 interface
6
7 uses Soap.InvokeRegistry, System.Types, Soap.XSBuiltIns;
8
9 type
10
11 { Invokable interfaces must derive from IInvokable }
12 IMyData = interface(IInvokable)
13 ['{865DBF5C-8DE1-4D01-AE04-16D04A3F5EF0}']
14 function GetInfo:widestring;stdcall;
15 function SetSQL(ASQL: widestring): widestring;stdcall;
16 { Methods of Invokable interface must not use the default }
17 { calling convention; stdcall is recommended }
18 end;
19
20 implementation
21
22 initialization
23 { Invokable interfaces must be registered }
24 InvRegistry.RegisterInterface(TypeInfo(IMyData));
25
26 end.
 1 { Invokable implementation File for TMyData which implements IMyData }
2
3 unit MyDataImpl;
4
5 interface
6
7 uses Soap.InvokeRegistry, System.Types, Soap.XSBuiltIns, MyDataIntf;
8
9 type
10
11 { TMyData }
12 TMyData = class(TInvokableClass, IMyData)
13 public
14 function GetInfo:widestring;stdcall;
15 function SetSQL(ASQL: widestring): widestring;stdcall;
16 end;
17
18 implementation
19 uses WebModuleUnit1;
20
21 { TMyData }
22
23 function TMyData.GetInfo: widestring;
24 var
25 oDM: TWebModule1;
26 begin
27 oDM := TWebModule1.Create(nil);
28 result := oDM.GetInfo;
29 oDM.Free;
30 end;
31
32 function TMyData.SetSQL(ASQL: widestring): widestring;
33 var
34 oDM: TWebModule1;
35 begin
36 oDM := TWebModule1.Create(nil);
37 result := oDM.SetSQL(ASQL);
38 oDM.Free;
39 end;
40
41 initialization
42 { Invokable classes must be registered }
43 InvRegistry.RegisterInvokableClass(TMyData);
44 end.

DelphiXE7客户端具体操作:
1.打开“DelphiXE7”->“File”->“New”->“Other”
2.“New Items”->“Delphi Projects”->“WebSrvice”->“WSDL Importer”
3.“Import WSDL”->WSDL Source中输入“http://localhost:8080/wsdl/IMyData”->“Next”
4.“Automatic SOAP versioning.(Recommended)”->“Next”
5.默认选项->“Finish”
6.Delphi会自动生成IMyData文件->保存
7.放入控件
ClientDataSet1
DataSource1
DBGrid1
8.DataSource1->DataSet:=ClientDataSet1
9.DBGrid1->DataSource:=DataSource1

客户端-实例代码:

 1 unit Unit1;
2
3 interface
4
5 uses
6 Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
7 Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.DBGrids, Data.DB,
8 Datasnap.DBClient, Vcl.StdCtrls;
9
10 type
11 TForm1 = class(TForm)
12 Button1: TButton;
13 ClientDataSet1: TClientDataSet;
14 DataSource1: TDataSource;
15 DBGrid1: TDBGrid;
16 Button2: TButton;
17 Edit1: TEdit;
18 procedure Button1Click(Sender: TObject);
19 procedure Button2Click(Sender: TObject);
20 private
21 { Private declarations }
22 public
23 { Public declarations }
24 end;
25
26 var
27 Form1: TForm1;
28
29 implementation
30 uses IMyData1;
31 {$R *.dfm}
32
33 procedure TForm1.Button1Click(Sender: TObject);
34 var
35 ows: IMyData;
36 s: string;
37 begin
38 ows := GetIMyData(true,'http://localhost:8080/wsdl/IMyData',nil); //参数中可以使用配置的url
39 s := ows.GetInfo;
40 if length(s) <> 0 then
41 ClientDataSet1.xmldata := s;
42 end;
43
44 procedure TForm1.Button2Click(Sender: TObject);
45 var
46 ows:IMyData;
47 s:string;
48 begin
49 ows := GetIMyData(true,'http://localhost:8080/wsdl/IMyData',nil); //参数中可以使用配置的url
50 s := ows.SetSQL('delete from usesr where yonghu=' + QuotedStr('ni2'));
51 if length(s) <> 0 then
52 Edit1.Text := s;
53 end;
54
55 end.
http://www.cnblogs.com/FKdelphi/p/5302928.html
 
http://www.cnblogs.com/FKdelphi/p/5302928.html

DelphiXE7中创建WebService(服务端+客户端) good的更多相关文章

  1. DelphiXE7中创建WebService(服务端+客户端)

    相关资料: http://www.2ccc.com/news/Html/?1507.html http://www.dfwlt.com/forum.php?mod=viewthread&tid ...

  2. eclipse使用CXF3.1.*创建webservice服务端客户端以及客户端手机APP(二)

    eclipse使用CXF3.1.*创建webservice服务端客户端以及客户端手机APP(二) 接上篇博客,本篇博客主要包含两个内容: 4.使用Android studio创建webservice客 ...

  3. eclipse使用CXF3.1.*创建webservice服务端客户端以及客户端手机APP(一)

    eclipse使用CXF3.1.*创建webservice服务端客户端以及客户端手机APP(一) 本篇博客主要包含五个内容: 1.CXF换将搭建以及eclipse配置CXF. 2.eclipse创建w ...

  4. [转载]Java创建WebService服务及客户端实现

    Java创建WebService服务及客户端实现 Java创建WebService服务及客户端实现

  5. MyEclipse创建WebService服务端和客户端

    1.新建立一个javaWeb项目,一个java类,如图: 2.接下来我们就要将项目中的TestService的这个类生成WebService服务端,选择new Web Service,如图: Next ...

  6. IDEA创建WebService服务端与客户端

    创建服务端 一.file–>new–>project 二.点击next后输入服务端名,点击finish,生成目录如下 三.在 HelloWorld.Java 文件中右击,选 Tools 的 ...

  7. idea创建WebService服务端和客户端

    创建服务端 1.file–>new–>project 2.点击next后输入服务端名,点击finish,生成目录如下 3.在 HelloWorld.Java 文件中右击,选 WebServ ...

  8. [gRPC] 在 .NET Core 中创建 gRPC 服务端和客户端

    gRPC 官网:https://grpc.io/ 1. 创建服务端 1.1 基于 ASP.NET Core Web 应用程序模板创建 gRPC Server 项目. 1.2 编译并运行 2. 创建客户 ...

  9. JAVA WEBSERVICE服务端&客户端的配置及调用(基于JDK)

    前言:我之前是从事C#开发的,因公司项目目前转战JAVA&ANDROID开发,由于对JAVA的各种不了解,遇到的也是重重困难.目前在做WEBSERVICE提供数据支持,看了网上相关大片的资料也 ...

随机推荐

  1. 趋势科技4月移动client病毒报告

    2014年4月移动client安全威胁概况 截至2014年4月30日,中国区移动client病毒码1.669.60,大小9,792,484字节,能够检測病毒约221万个.移动client病毒约12万个 ...

  2. NYOJ10,skiing

    skiing 时间限制:3000 ms  |  内存限制:65535 KB 难度:5 描写叙述 Michael喜欢滑雪百这并不奇怪, 由于滑雪的确非常刺激.但是为了获得速度,滑的区域必须向下倾斜,并且 ...

  3. 不用SWIG,Go使用C++代码的方式

    将C++代码用C作一次封装,就可以让Go调用了. 这是一个C++头文件: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #ifndef CGO_CPPGO_C ...

  4. perl use utf8

    utf8 Perl编译 来启用/禁用 UTF-8(or UTF-EBCDIC) 在源代码里 简洁: use utf8; no utf8; # Convert the internal represen ...

  5. 来推荐个免费的PPT演示工具--ZohoShowTime

    事实上这个不算新产品了,这次是做了一些大的改进.上次在Zoho的全球用户大会上,全程演讲都是用的这个工具.Zoho这点非常好啊.自己的产品自己带头用.个人认为它最大的用处就是.离得远的观众能够在自己的 ...

  6. 关于new enhancement的一些知识

    关于new enhancement sap源程序里也给我们留了很多. 以下例句point .section.spot说明这些知识点. 1.不管是point还是section 都是基于spot的,spo ...

  7. PL/SQL(二):变量

    变量 标识符定义 PL/SQL程序设计中的标识符定义与SQL的标识符定义的要求相同.要求和限制有: 个字符. )首字符必须为字母. )不区分大小写. )不能使用SQL保留字. )对标识符的命名最好遵循 ...

  8. [转载]关于网传JDK1.7语法层次支持集合的问题

    以  JDK1.7新特性 为关键词进行百度的话,总能发现这样的描述,说: 从语法层面上支持集合,不再是数组的专利.还有这样的例子: final List<Integer> piDigits ...

  9. 【Demo 0006】Android 组件(Activity)

    本章学习要点:        1.  了解Activity基本概念;        2.  掌握Activity生命周期:        3.  掌握 Activity之间跳转:  

  10. EasyUI - Resizable 调整大小

    效果: html代码: <div id="rr" style="width: 100px; height: 100px; border: 2px solid #cc ...