使用Delphi调用WebServices接口的简单应用实例
使用Delphi调用WebServices接口的简单应用实例
Delphi从6.0就开始支持Web Services的开发和应用了,本文通过使用Delphi 7.0调用新浪发送短信的Web Service进行短信应用程序开发这一实例详细的介绍在Delphi中如何开发基于Web Services的应用系统。
第一步,准备工作,了解新浪短信Web Service。新浪发送短信的Web Service地址是http://smsinter.sina.com.cn/ws/smswebservice0101.wsdl,该Web Service就只有一个方法,即string sendXml(carrier,userid,password,mobilenumber,content,msgtype)。各个参数全部为string类型,其含义基本如下(可能不正确)。
Carrier:运营商名称,好像可以随便输,建议输入“Sina”,如果输入其他的值,消息发送的特别慢;
Userid:您在新浪无线上注册的手机ID,如果您没有在http://sms.sina.com.cn上注册您的手机,你是无法使用本Web Service发送短信的;
Password:您在新浪无线上注册手机时所使用的密码;
Mobilenumber:对方的手机号码;
Content:发送短消息的内容;
Msgtype:发送短消息的类型,我估计支持彩信,不过我不知道怎么使用,似乎随便输什么都可以,我使用的是“Text”。
资费标准请参看新浪无线网站上的相关说明,为了不浪费电话费,我没测试使用,应该是一条一角钱,不过也或者是一条两角线,具体不太清楚。由于其后台可能使用了消息队列机制,在繁忙的时候,可能会有较长时间的延迟。
第二步,先建立一个空白的应用程序。运行Delphi 7,打开[File]->[New]->[Application]菜单,Delphi自动生成一个默认的工程。将默认的窗体Form1改为Form_Sms,然后将改工程保存为smsdemo.prj。
第三步,引入Web Service。,打开[File]->[New]->[Other]菜单,在弹出的窗口中选择WebServices Tab页面,然后选择其中的WSDL importer选项,单击OK按钮弹出WSDL importer Wizard窗口,如图2所示。在其上的Location of WSDL File or URL 中输入:http://smsinter.sina.com.cn/ws/smswebservice0101.wsdl (注意,千万不能输错!),单击Next按钮后,再单击Finishi按钮,完成浪发送短信Web Service的引入。此时工程文件中会增加一个名字为smswebservice0101.pas的文件,这是Delphi自动生成的Web Service引入申明文件,不要手工修改他。
第四步,调用Web Service的短信发送接口。在sms窗体中,依次增加四个TLabeledEdit控件,一个TButton控件,2个TMemo控件,
在Form_Sms单元的u
相关文档:
一、整数类型
类型 所占字节数 取值范围
byte 1 0-255
word 2 0-65535
shortint 1 -128-127
smallint 2 -32768-32767
integer 4 -214748648-214748467
longint 4 -214748648-214748467
cordinal 4 0-2147483647
二、实数类型
类型 所点字节数 取值范围
Real 6 ±2.9×10的负39次方到1.7× ......
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked then
SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOMOVE)
else
SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOMOVE);
end;//使用Self.FormStyle := fsStayOnTop;会使界 ......
原来是要在FormCreate中加入以下代码:
procedure TTntForm1.TntFormCreate(Sender: TObject);
begin
//这句很关键.对于平台的支持.
if Win32Platform = VER_PLATFORM_WIN32_NT then
Font.Name := 'MS Shell Dlg 2'
else
Font.Name := 'MS Shell Dlg';
......
unit Servicescontrol;
interface
uses Windows,Messages,SysUtils,Winsvc,Dialogs;
function StartServices(Const SvrName:String):Boolean;
function StopServices(Const SvrName:String):Boolean;
function QueryServiceStatu(Const SvrName:  ......
The built-in assembler allows you to write assembly code within Delphi programs. It has the following features:
内嵌的汇编器允许在delphi程序中书写汇编代码,他有如下特性:
Allows for inline assembly
允许内嵌汇编
Supports all instructions found in the Intel Pentium III, In ......