【PB续命05】WinHttp.WinHttpRequest的介绍与使用
0 WinHttp.WinHttpRequest简介
winhttp.winhttprequest是Windows操作系统中的一个API函数,用于创建和发送HTTP请求。它可以用于从Web服务器获取数据,或将数据发送到Web服务器。该函数提供了许多选项,例如设置请求头、设置代理服务器、设置超时时间等。它是一个非常强大的工具,可以帮助开发人员轻松地与Web服务器进行通信。
winhttp.winhttprequest.5.1
wihttp.winhttprequest.5.1是一个Microsoft Windows操作系统中的COM组件,用于在应用程序中进行HTTP请求和响应。它提供了一种简单的方法来与Web服务器进行通信,可以用于发送和接收HTTP请求和响应,支持各种HTTP方法,如GET、POST、PUT、DELETE等。它还提供了一些其他功能,如设置请求头、设置代理服务器、设置超时等。
1 创建PB窗口
为了演示winhttp.winhttprequest的使用创建一PB测试窗口w_restful如下:

窗口w_restful代码如下:
forward
global type w_restful from window
end type
type mle_resp from multilineedit within w_restful
end type
type st_3 from statictext within w_restful
end type
type cb_delete from commandbutton within w_restful
end type
type cb_put from commandbutton within w_restful
end type
type cb_post from commandbutton within w_restful
end type
type cb_get from commandbutton within w_restful
end type
type sle_data from singlelineedit within w_restful
end type
type sle_url from singlelineedit within w_restful
end type
type st_2 from statictext within w_restful
end type
type st_1 from statictext within w_restful
end type
end forwardglobal type w_restful from window
integer width = 3186
integer height = 1980
boolean titlebar = true
string title = "PB请求RESTful的数据"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
mle_resp mle_resp
st_3 st_3
cb_delete cb_delete
cb_put cb_put
cb_post cb_post
cb_get cb_get
sle_data sle_data
sle_url sle_url
st_2 st_2
st_1 st_1
end type
global w_restful w_restfulforward prototypes
public subroutine wf_https (string as_method)
end prototypespublic subroutine wf_https (string as_method);string ls_url,ls_data
ls_url = sle_url.text
ls_data = sle_data.textstring ls_ret ls_ret = gf_https_apex(ls_url,ls_data,as_method)mle_resp.text = ls_ret
end subroutineon w_restful.create
this.mle_resp=create mle_resp
this.st_3=create st_3
this.cb_delete=create cb_delete
this.cb_put=create cb_put
this.cb_post=create cb_post
this.cb_get=create cb_get
this.sle_data=create sle_data
this.sle_url=create sle_url
this.st_2=create st_2
this.st_1=create st_1
this.Control[]={this.mle_resp,&
this.st_3,&
this.cb_delete,&
this.cb_put,&
this.cb_post,&
this.cb_get,&
this.sle_data,&
this.sle_url,&
this.st_2,&
this.st_1}
end onon w_restful.destroy
destroy(this.mle_resp)
destroy(this.st_3)
destroy(this.cb_delete)
destroy(this.cb_put)
destroy(this.cb_post)
destroy(this.cb_get)
destroy(this.sle_data)
destroy(this.sle_url)
destroy(this.st_2)
destroy(this.st_1)
end onevent resize;//窗口控件自动适用long llw , llh
llw = this.workspacewidth( ) - sle_url.x llh = this.workspaceheight( ) - mle_resp.ysle_url.width = llwsle_data.width = llwmle_resp.width = llw
mle_resp.height = llh
end eventtype mle_resp from multilineedit within w_restful
integer x = 411
integer y = 248
integer width = 2158
integer height = 812
integer taborder = 40
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
string text = "responseText"
borderstyle borderstyle = stylelowered!
end typetype st_3 from statictext within w_restful
integer x = 78
integer y = 256
integer width = 302
integer height = 76
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Response:"
alignment alignment = Right!
boolean focusrectangle = false
end typetype cb_delete from commandbutton within w_restful
integer x = 14
integer y = 784
integer width = 375
integer height = 116
integer taborder = 60
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "DELETE"
end typeevent clicked;//DELETE
wf_https("DELETE")
end eventtype cb_put from commandbutton within w_restful
integer x = 14
integer y = 648
integer width = 375
integer height = 116
integer taborder = 50
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "PUT"
end typeevent clicked;//PUT
wf_https("PUT")
end eventtype cb_post from commandbutton within w_restful
integer x = 14
integer y = 512
integer width = 375
integer height = 116
integer taborder = 40
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "POST"
end typeevent clicked;//POST
wf_https("POST")
end eventtype cb_get from commandbutton within w_restful
integer x = 14
integer y = 376
integer width = 375
integer height = 116
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "GET"
end typeevent clicked;//GET
wf_https("GET")
end eventtype sle_data from singlelineedit within w_restful
integer x = 411
integer y = 128
integer width = 2167
integer height = 100
integer taborder = 20
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
string text = "{}"
borderstyle borderstyle = stylelowered!
end typetype sle_url from singlelineedit within w_restful
integer x = 411
integer y = 4
integer width = 2167
integer height = 100
integer taborder = 10
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
string text = "https://apex.oracle.com/pls/apex/blma/b5217/"
borderstyle borderstyle = stylelowered!
end typetype st_2 from statictext within w_restful
integer x = 137
integer y = 136
integer width = 242
integer height = 76
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "DATA:"
alignment alignment = Right!
boolean focusrectangle = false
end typetype st_1 from statictext within w_restful
integer x = 137
integer y = 28
integer width = 242
integer height = 76
integer textsize = -9
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "URL:"
alignment alignment = Right!
boolean focusrectangle = false
end type
2 创建全局函数gf_https_apex()
用来发送请求和获得响应
global type gf_https_apex from function_object
end typeforward prototypes
global function string gf_https_apex (string as_url, string as_data, string as_method)
end prototypesglobal function string gf_https_apex (string as_url, string as_data, string as_method);// 用WinHttp.WinHttpRequest.5.1组件,请求https网页和响应/* 调用参数示例
String ls_url,ls_data,ls_response
ls_url = 'https://datacenter-web.eastmoney.com/api/data/v1/get?'
ls_data = "callback=jQuery11230903969942572268_1651624511350&sortColumns=UPDATE_DATE,SECURITY_CODE&sortTypes=-1,-1&pageSize=50&pageNumber=1&reportName=RPT_LICO_FN_CPD&columns=ALL&filter=(REPORTDATE='2023-09-30')"
ls_response = gf_https_apex(ls_url,ls_data,ls_method)
*/String ls_url,ls_data,ls_response//请求的URL和数据
ls_url = as_url
ls_data = as_dataOleObject lole_https //声明ole
lole_https = CREATE oleobject long llr
any la
llr = lole_https.ConnectToNewObject("WinHttp.WinHttpRequest.5.1")
lole_https.setTimeouts (50000,50000,50000,10000)
la = lole_https.open (as_method,ls_url, false) //OPEN if not upper(as_method) = "DELETE" then lole_https.setRequestHeader ("Content-Type", "application/json")lole_https.setRequestHeader ('Content-Length',string(len(ls_data)))
end iflole_https.setRequestHeader ("charset","UTF-8")
lole_https.setRequestHeader ("User-Agent","Mozilla/5.0") //这个是Apex的RESTful需要的lole_https.Send(ls_data)
/*
关键是这一步:如果你的https的环境没有安装浏览器的认证的根证书,一定会报错退出,
如果你申请安装了verisign等权威机构发的根证书,用ie打开上面的https,就不会报红色警告(问你是不是继续)。
但pb不会提示你是不是继续,直接报错退出。verisign的证书一年好像要1万-10万元的服务费。在这里你如果想测试一下,
你可以把上面的https地址换成https://www.alipay.com/ (支付宝的),不会报错的。注意:这里的证书及验证都是单向验证,不是双向的。
*/IF lole_https.Status >= 300 THEN ls_response = string(lole_https.Status) + " : " + string(lole_https.StatusText)MessageBox ("HTTPs request failed:",ls_response ) return ls_response
END IF blob lb_body
lb_body = lole_https.responseBodyls_response = string(lb_body,EncodingUTF8!) //返回结果//销毁 ole
destroy lole_httpsreturn ls_responseend function
3 运行效果
窗口上的调用https请求的函数代码:
string ls_url,ls_data
ls_url = sle_url.text
ls_data = sle_data.textstring ls_ret ls_ret = gf_https_apex(ls_url,ls_data,as_method)mle_resp.text = ls_ret
3.1 GET请求数据
【GET】按钮上的代码:
//GET
wf_https("GET")

数据库表上的数据:

3.2 POST添加数据
【POST】按钮上的代码:
//POST
wf_https("POST")


3.3 PUT修改数据
【PUT】按钮上的代码:
//PUT
wf_https("PUT")


3.4 DELETE删除数据
【DELETE】按钮上的代码:
//DELETE
wf_https("DELETE")


4 Apex的AutoREST的其它服务
- GET一条记录
- GET分页设置
- 查询条件GET数据
- 按查询条件DELETE数据
- 批量从本地文件加载数据
- 等等,不再举例演示了
相关文章:
【PB续命05】WinHttp.WinHttpRequest的介绍与使用
0 WinHttp.WinHttpRequest简介 winhttp.winhttprequest是Windows操作系统中的一个API函数,用于创建和发送HTTP请求。它可以用于从Web服务器获取数据,或将数据发送到Web服务器。该函数提供了许多选项,例如设置请求头、设置代理服务器、设置超…...
【Linux】进程间是这样通信的--管道篇
TOC 目录 进程间通信的介绍 进程间通信的概念 进程间通信的目的 进程间通信的本质 进程间通信的分类 管道 什么是管道 匿名管道 pipe函数 匿名管道使用步骤 管道读写规则 管道的特点 1、管道内部自带同步与互斥机制 2、管道的生命周期随进程 3、管道提供的是流式…...
Python基础入门例程60-NP60 跳过列表的某个元素(循环语句)
最近的博文: Python基础入门例程59-NP59 提前结束的循环(循环语句)-CSDN博客 Python基础入门例程58-NP58 找到HR(循环语句)-CSDN博客 Python基础入门例程57-NP57 格式化清单(循环语句)-CSDN博客 目录 最近的博文: 描述...
三十二、W5100S/W5500+RP2040树莓派Pico<UPnP示例>
文章目录 1 前言2 简介2 .1 什么是UPnP?2.2 UPnP的优点2.3 UPnP数据交互原理2.4 UPnP应用场景 3 WIZnet以太网芯片4 UPnP示例概述以及使用4.1 流程图4.2 准备工作核心4.3 连接方式4.4 主要代码概述4.5 结果演示 5 注意事项6 相关链接 1 前言 随着智能家居、物联网等…...
2023.11.18 Hadoop之 YARN
1.简介 Apache Hadoop YARN (Yet Another Resource Negotiator,另一种资源协调者)是一种新的 Hadoop 资源管理器,它是一个通用资源管理系统和调度平台,可为上层应用提供统一的资源管理和调度。支持多个数据处理框架&…...
ceph 常用命令
bucket 常用命令 查看 realm (区域) radosgw-admin realm list输出 {"default_info": "43c462f5-5634-496e-ad4e-978d28c2x9090","realms": ["myrgw"] }radosgw-admin realm get{"id": "2cfc…...
6.8完全二叉树的节点个数(LC222-E)
算法: 如果不考虑完全二叉树的特性,直接把完全二叉树当作普通二叉树求节点数,其实也很简单。 递归法: 用什么顺序遍历都可以。 比如后序遍历(LRV):不断遍历左右子树的节点数,最后…...
基于协作mimo系统的RM编译码误码率matlab仿真,对比硬判决译码和软判决译码
目录 1.算法运行效果图预览 2.算法运行软件版本 3.部分核心程序 4.算法理论概述 5.算法完整程序工程 1.算法运行效果图预览 2.算法运行软件版本 matlab2022a 3.部分核心程序 ..................................................................... while(Err < TL…...
Django模型层
模型层 与数据库相关的,用于定义数据模型和数据库表结构。 在Django应用程序中,模型层是数据库和应用程序之间的接口,它负责处理所有与数据库相关的操作,例如创建、读取、更新和删除记录。Django的模型层还提供了一些高级功能 首…...
计算机视觉的应用18-一键抠图人像与更换背景的项目应用,可扩展批量抠图与背景替换
大家好,我是微学AI,今天给大家介绍一下计算机视觉的应用18-一键抠图人像与更换背景的项目应用,可扩展批量抠图与背景替换。该项目能够让你轻松地处理和编辑图片。这个项目的核心功能是一键抠图和更换背景。这个项目能够自动识别图片中的主体&…...
Redis(哈希Hash和发布订阅模式)
哈希是一个字符类型字段和值的映射表。 在Redis中,哈希是一种数据结构,用于存储键值对的集合。哈希可以理解为一个键值对的集合,其中每个键都对应一个值。哈希在Redis中的作用主要有以下几点: 1. 存储对象:哈希可以用…...
php正则表达式汇总
php正则表达式有"/pattern/“、”“、”$“、”.“、”[]“、”[]“、”[a-z]“、”[A-Z]“、”[0-9]“、”\d"、“\D”、“\w”、“\W”、“\s”、“\S”、“\b”、“*”、“”、“?”、“{n}”、“{n,}”、“{n,m}”、“\bword\b”、“(pattern)”、“x|y"和…...
Python与ArcGIS系列(八)通过python执行地理处理工具
目录 0 简述1 脚本执行地理处理工具2 在地理处理工具间建立联系0 简述 arcgis包含数百种可以通过python脚本执行的地理处理工具,这样就通过python可以处理复杂的工作和批处理。本篇将介绍如何利用arcpy实现执行地理处理工具以及在地理处理工具间建立联系。 1 脚本执行地理处理…...
cocos----刚体
刚体(Rigidbody) 刚体(Rigidbody)是运动学(Kinematic)中的一个概念,指在运动中和受力作用后,形状和大小不变,而且内部各点的相对位置不变的物体。在 Unity3D 中ÿ…...
【SAP-HCM】--HR人员信息导入函数
人员基本信息导入函数:HR_MAINTAIN_MASTERDATA 人员其他信息类型导入函数:HR_INFOTYPE_OPERATION 不逼逼,直接上代码,这两个函数还是相对简单易懂的 *根据操作类型查找对应的T529A 操作类型对应的值IF gt_alv IS NOT INITIAL.S…...
【开源】基于JAVA的大学兼职教师管理系统
项目编号: S 004 ,文末获取源码。 \color{red}{项目编号:S004,文末获取源码。} 项目编号:S004,文末获取源码。 目录 一、摘要1.1 项目介绍1.2 项目录屏 二、研究内容三、界面展示3.1 登录注册3.2 学生教师管…...
Pyhon函数
import time # # for i in range(1,10): # j1 # for j in range(1,i1): # print(f"{i}x{j}{i*j} " ,end) # print() #复用,代码,精简,复用度高def j99(n1,max10): for i in range(n,max):jifor j in ran…...
使用vuex完成小黑记事本案例
使用vuex完成小黑记事本案例 App.vue <template><div id"app"><TodoHeader></TodoHeader><TodoMain ></TodoMain><TodoFooter></TodoFooter></div> </template><script> import TodoMain from …...
进阶理解:leetcode115.不同的子序列(细节深度)
这道题是困难题,本章是针对于动态规划解决,对于思路进行一个全面透彻的讲解,但是并不是对于基础讲解思路,而是渗透到递推式和dp填数的详解,如果有读者不清楚基本的解题思路,请看我的这篇文章算法训练营DAY5…...
数据结构-哈希表(C语言)
哈希表的概念 哈希表就是: “将记录的存储位置与它的关键字之间建立一个对应关系,使每个关键字和一个唯一的存储位置对 应。” 哈希表又称:“散列法”、“杂凑法”、“关键字:地址法”。 哈希表思想 基本思想是在关键字和存…...
港科资讯|郑光廷教授出席国际科技组织发展与全球科技治理论坛 分享协作实践
2026年3 月 28 日,国际科技组织发展与全球科技治理论坛在北京中关村国际创新中心成功举办。香港科技大学副校长(研究及发展)郑光廷教授受邀出席并发表主题演讲,香港科大内地办(北京)主任袁冶老师一同参会,与中外嘉宾交…...
智能票务自动化工具:提升大型活动门票获取效率的全流程解决方案
智能票务自动化工具:提升大型活动门票获取效率的全流程解决方案 【免费下载链接】Automatic_ticket_purchase 大麦网抢票脚本 项目地址: https://gitcode.com/GitHub_Trending/au/Automatic_ticket_purchase 在数字化时代,大型展会、体育赛事等热…...
千问3.5-2B集成IDEA开发环境:Java大模型应用快速构建指南
千问3.5-2B集成IDEA开发环境:Java大模型应用快速构建指南 1. 为什么要在IDEA中集成大模型? 作为Java开发者,我们经常需要在项目中处理各种文本处理任务。传统方式要么需要调用外部API(有网络延迟和费用问题)…...
基于鲸鱼优化算法改进XGBoost在MATLAB中的时间序列预测性能(迭代次数、最大深度和学习...
基于鲸鱼优化算法优化XGBoost(WOA-XGBoost)的时间序列预测 WOA-XGBoost时间序列 采用交叉验证抑制过拟合问题 优化参数为迭代次数、最大深度和学习率 matlab代码,注:暂无Matlab版本要求 -- 推荐 2016B 版本及以上 注:采用 XGBoost 工具箱&…...
无需本地安装,用快马平台5分钟搭建git操作可视化原型
最近在准备一个Git入门教学项目时,发现很多新手卡在环境配置这一步。传统方式需要先安装Git客户端、配置SSH密钥、设置全局参数,光是这些前置操作就能劝退不少人。于是尝试用InsCode(快马)平台的云端开发环境,意外发现能跳过所有安装步骤直接…...
别让电源拖后腿!手把手教你搞定Xilinx 7系列FPGA(以XC7K325T为例)的供电设计
别让电源拖后腿!手把手教你搞定Xilinx 7系列FPGA(以XC7K325T为例)的供电设计 第一次翻开Xilinx 7系列FPGA的硬件手册时,相信不少工程师都会被密密麻麻的电源轨搞得头晕目眩。VCCINT、VCCBRAM、VCCO、VMGTAVCC...这些看似简单的电压…...
告别桌面混乱:NoFences让文件管理效率提升80%的空间收纳方案
告别桌面混乱:NoFences让文件管理效率提升80%的空间收纳方案 【免费下载链接】NoFences 🚧 Open Source Stardock Fences alternative 项目地址: https://gitcode.com/gh_mirrors/no/NoFences 每天在杂乱的桌面图标中寻找文件,就像在堆…...
智能电网RAG优化:闭环协同与精准检索
RAG论文原理解析、公式含义与错误点对点修正方案 一、论文核心原理详细解析(含场景举例) 本文针对通用RAG框架在术语密集、强监管垂直领域(智能电网)的三大原生适配瓶颈,提出了** RAG领域原生闭环协同RAG范式**,核心是将智能电网领域知识嵌入检索-生成-评估全生命周期,…...
Vue3+Three.js实战:拆解Xtreme1点云标注工具的技术架构
Vue3Three.js深度实战:构建工业级3D点云标注工具的技术解析 在自动驾驶、工业检测和机器人视觉领域,3D点云标注工具正成为AI训练数据生产的核心基础设施。Xtreme1作为开源多模态标注平台的代表,其pc-tool模块采用Vue3Three.js技术栈实现了专…...
如何快速解锁网易云音乐NCM文件:ncmdumpGUI终极指南
如何快速解锁网易云音乐NCM文件:ncmdumpGUI终极指南 【免费下载链接】ncmdumpGUI C#版本网易云音乐ncm文件格式转换,Windows图形界面版本 项目地址: https://gitcode.com/gh_mirrors/nc/ncmdumpGUI 还在为网易云音乐下载的NCM格式文件无法在其他…...
