博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
无聊写的delphi7 调rest接口的例子
阅读量:3587 次
发布时间:2019-05-20

本文共 1509 字,大约阅读时间需要 5 分钟。

unit Unit1;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs,msxml, StdCtrls;type  TForm1 = class(TForm)    btn1_callRestful: TButton;    mmo1: TMemo;    procedure btn1_callRestfulClick(Sender: TObject);  private    { Private declarations }  public    { Public declarations }  end;var  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.btn1_callRestfulClick(Sender: TObject);varHttpReq : IXMLHTTPRequest;url, msg,rsp   : string;begin   url:= 'http://xxxxx.ittun.com/usspachRest/initCheck';   msg:='msg={"timecut":"20170727141009",  '+    ' "ip":"xxx", '+    ' "uniform_oper":"MY",    '+    ' "oper_no":"NNPT00",       '+    ' "uniform_passwd":"C4CA4238A0B923820DCC509A6FFDDD"     '+    ' }';    HttpReq := CoXMLHTTPRequest.Create;   //两种提交请求的方式:Get和Post,Get是通过URL地址传递参数如果是中文需要转码,需要添加时间戳 Post不需要添加时间戳   //get url := 'http://localhost:5269/api/webmemberapi/NewMemberRegister?timestamp='+inttostr(Windows.GetTickCount);   //vQryURL := 'http://10.202.31.103:1080/hs/api/iOrderService/queryOrderWithBill';   HttpReq.open('Post', url, False, EmptyParam, EmptyParam);   //http post   //HttpReq.setRequestHeader('Accept', 'application/json');   HttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');   //HttpReq.setRequestHeader('Content-Type', 'application/json');   //请求主体   try    HttpReq.Send(msg);    rsp := (HttpReq.responseText);    mmo1.Lines.Add(rsp) ;   except     on Ex:Exception do       ShowMessage(Ex.Message);   end;end;end.

转载地址:http://fmvwn.baihongyu.com/

你可能感兴趣的文章
MACOS的Python虚拟环境使用笔记
查看>>
MAC系统使用Matplotlib显示中文问题亲测有效
查看>>
JavaScript的类型转换笔记
查看>>
JavaScript闭包实现计数器
查看>>
JavaScript中this关键字
查看>>
JavaScript两种定时器的使用
查看>>
阿里云服务器配置Nginx访问不到问题
查看>>
MAC电脑使用jupyter notebook
查看>>
Windows上设置jupternotebook远程访问
查看>>
查找数组中指定值下标
查看>>
不用strcat进行连接
查看>>
排列组合Cnm,有参数有返回值
查看>>
嵌套数组中查找元素
查看>>
gets函数
查看>>
查找句子中单词数,串
查看>>
局部变量存储类别
查看>>
Ubuntu18安装vim
查看>>
第39级台阶 c++
查看>>
C#如何统计出文本框中字母、空格、数字及其他字符的个数
查看>>
command 'x86_64-linux-gnu-gcc' failed with exit status 1
查看>>