相关资料:

http://www.2ccc.com/news/Html/?1507.html

http://www.dfwlt.com/forum.php?mod=viewthread&tid=922

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

服务端-实例代码:

 unit WebModuleUnit1;

 interface

 uses System.SysUtils, System.Classes, Web.HTTPApp, Soap.InvokeRegistry,
Soap.WSDLIntf, System.TypInfo, Soap.WebServExp, Soap.WSDLBind, Xml.XMLSchema,
Soap.WSDLPub, Soap.SOAPPasInv, Soap.SOAPHTTPPasInv, Soap.SOAPHTTPDisp,
Soap.WebBrokerSOAP, FireDAC.Stan.Intf, FireDAC.Stan.Option,
FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.MSAcc,
FireDAC.Phys.MSAccDef, FireDAC.Phys.MSSQLDef, FireDAC.Stan.Param,
FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, Datasnap.DBClient,
Datasnap.Provider, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client,
FireDAC.Phys.ODBCBase, FireDAC.Phys.MSSQL; type
TWebModule1 = class(TWebModule)
HTTPSoapDispatcher1: THTTPSoapDispatcher;
HTTPSoapPascalInvoker1: THTTPSoapPascalInvoker;
WSDLHTMLPublish1: TWSDLHTMLPublish;
FDConnection1: TFDConnection;
FDPhysMSSQLDriverLink1: TFDPhysMSSQLDriverLink;
FDQuery1: TFDQuery;
DataSetProvider1: TDataSetProvider;
ClientDataSet1: TClientDataSet;
procedure WebModule1DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
private
{ Private declarations }
public
function GetInfo: widestring;
function SetSQL(ASQL: widestring): widestring;
{ Public declarations }
end; var
WebModuleClass: TComponentClass = TWebModule1; implementation {%CLASSGROUP 'Vcl.Controls.TControl'} {$R *.dfm} function TWebModule1.GetInfo: widestring;
begin
ClientDataSet1.Close;
ClientDataSet1.Open;
Result := ClientDataSet1.XMLData;
ClientDataSet1.Close;
end; function TWebModule1.SetSQL(ASQL: widestring): widestring;
begin
FDQuery1.Close;
FDQuery1.SQL.Text := ASQL;
try
FDQuery1.ExecSQL;
Result := '成功 ';
except
Result := '失败';
end;
end; procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
WSDLHTMLPublish1.ServiceInfo(Sender, Request, Response, Handled);
end; end.
 { Invokable interface IMyData }

 unit MyDataIntf;

 interface

 uses Soap.InvokeRegistry, System.Types, Soap.XSBuiltIns;

 type

   { Invokable interfaces must derive from IInvokable }
IMyData = interface(IInvokable)
['{865DBF5C-8DE1-4D01-AE04-16D04A3F5EF0}']
function GetInfo:widestring;stdcall;
function SetSQL(ASQL: widestring): widestring;stdcall;
{ 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(IMyData)); end.
 { Invokable implementation File for TMyData which implements IMyData }

 unit MyDataImpl;

 interface

 uses Soap.InvokeRegistry, System.Types, Soap.XSBuiltIns, MyDataIntf;

 type

   { TMyData }
TMyData = class(TInvokableClass, IMyData)
public
function GetInfo:widestring;stdcall;
function SetSQL(ASQL: widestring): widestring;stdcall;
end; implementation
uses WebModuleUnit1; { TMyData } function TMyData.GetInfo: widestring;
var
oDM: TWebModule1;
begin
oDM := TWebModule1.Create(nil);
result := oDM.GetInfo;
oDM.Free;
end; function TMyData.SetSQL(ASQL: widestring): widestring;
var
oDM: TWebModule1;
begin
oDM := TWebModule1.Create(nil);
result := oDM.SetSQL(ASQL);
oDM.Free;
end; initialization
{ Invokable classes must be registered }
InvRegistry.RegisterInvokableClass(TMyData);
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

客户端-实例代码:

 unit Unit1;

 interface

 uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.DBGrids, Data.DB,
Datasnap.DBClient, Vcl.StdCtrls; type
TForm1 = class(TForm)
Button1: TButton;
ClientDataSet1: TClientDataSet;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Button2: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation
uses IMyData1;
{$R *.dfm} procedure TForm1.Button1Click(Sender: TObject);
var
ows: IMyData;
s: string;
begin
ows := GetIMyData(true,'http://localhost:8080/wsdl/IMyData',nil); //参数中可以使用配置的url
s := ows.GetInfo;
if length(s) <> then
ClientDataSet1.xmldata := s;
end; procedure TForm1.Button2Click(Sender: TObject);
var
ows:IMyData;
s:string;
begin
ows := GetIMyData(true,'http://localhost:8080/wsdl/IMyData',nil); //参数中可以使用配置的url
s := ows.SetSQL('delete from usesr where yonghu=' + QuotedStr('ni2'));
if length(s) <> then
Edit1.Text := s;
end; end.

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

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

    相关资料:http://www.2ccc.com/news/Html/?1507.html DelphiXE7新建WebService具体操作:1.打开“DelphiXE7”->“File”-& ...

  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. poj 2886 Who Gets the Most Candies?(线段树和反素数)

    题目:http://poj.org/problem?id=2886 题意:N个孩子顺时针坐成一个圆圈且从1到N编号,每个孩子手中有一张标有非零整数的卡片. 第K个孩子先出圈,如果他手中卡片上的数字A大 ...

  2. 学军NOI训练13 T3 白黑树

    唉,大学军有自己的OJ就是好,无限orz 只有周六的比赛是开放的囧,这场比赛最后因为虚拟机卡住没有及时提交…… 否则就能让大家看到我有多弱了…… 前两题题解写的很详细,可以自己去看,我来随便扯扯T3好 ...

  3. BZOJ2151: 种树

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=2151 题解:此题=数据备份.喜闻乐见挂链表. 代码: #include<cstdio&g ...

  4. I.MX6 Android U-blox miniPCI 4G porting

    /************************************************************************** * I.MX6 Android U-blox m ...

  5. DirectX截图黑屏的解决办法

    好久没有更新博客了,今天开始继续耕耘. 生活要继续 工作要继续 梦想也一定要继续! 之前写过一篇关于DirectX截屏的文章,其中有网友留言提到了截图黑屏的问题,于是这些日子研究了一下,与大家一同分享 ...

  6. Cocos2d提供的字体(图文并茂)

    1.AppleGothic CCLabelTTF *myLabel = [CCLabelTTF labelWithString:@"AppleGothic" fontName:@& ...

  7. 项目管理工具:Maven使用方法总结

    阅读目录 一.概念 二.Maven安装 三.常用命令 四.生命周期 五.第一个Maven项目 六.POM文件 七.Maven库 八.参考资料 回到顶部 一.概念 Maven是一个项目管理和构建自动化工 ...

  8. SQL 2005 日志损坏的恢复方法

    SQL 在突然停电或者非正常关机下,可能会出现日期文件错误,导致数据库不正常.恢复数据库方法如下 1.数据库服务停掉 将数据库文件备份 例如数据库名为 DTMS 则将 DTMS.mdf 备份出来. 2 ...

  9. HDU 5122 K.Bro Sorting

    K.Bro Sorting Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others) Tot ...

  10. java制作证书的工具keytool用法

    一.keytool的概念 keytool 是个密钥和证书管理工具.它使用户能够管理自己的公钥/私钥对及相关证书,用于(通过数字签名)自我认证(用户向别的用户/服务认证自己)或数据完整性以及认证服务.在 ...