PB 用POSTURL()例子

本文介绍了PowerBuilder中POSTURL()函数的使用方法,通过具体例子展示如何利用此函数进行HTTP POST请求,实现数据的发送和接收,从而在应用程序中与Web服务交互。
摘要由CSDN通过智能技术生成
PB 通过 PostRul


一 创建Standard Class对象 type为"internetresult" n_ir


forward
global type n_ir from internetresult
end type
end forward


global type n_ir from internetresult
end type
global n_ir n_ir


type variables
string	is_data
blob     ib_blob
boolean 	ib_finished 
end variables


forward prototypes
public function integer internetdata (blob data)
public function boolean wf_get_data (ref string as_html, ref blob ab_blob)
end prototypes


public function integer internetdata (blob data);
//messagebox('返回结果',string(data))
ib_finished = False
ib_blob      = data
is_data     = string(data)
ib_finished = True
RETURN 0
end function


public function boolean wf_get_data (ref string as_html, ref blob ab_blob);
as_html = is_data
ab_blob = ib_blob


return ib_finished
end function


on n_ir.create
call super::create
TriggerEvent( this, "constructor" )
end on


on n_ir.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on


二 创建Standard Class对象 type为"inet"  n_inet


forward
global type n_inet from inet
end type
end forward


global type n_inet from inet
end type
global n_inet n_inet


on n_inet.create
call super::create
TriggerEvent( this, "constructor" )
end on


on n_inet.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on


三 创建非可视化对象nvo_string 用来转参数的编码类型


forward
global type nvo_string from nonvisualobject
end type
end forward


global type nvo_string from nonvisualobject autoinstantiate
end type


type prototypes
FUNCTION long WideCharToMultiByte(uint CodePage, ulong dwFlags, ref blob lpWideCharStr, long cchWideChar, 


ref blob lpMultiByteStr, long cbMultiByte, long lpDefaultChar,long lpUsedDefaultChar) Library 


"kernel32.dll" 
FUNCTION long MultiByteToWideChar(uint CodePage, ulong dwFlags, ref blob lpMultiByteStr,long 


cchMultiByte,ref blob lpWideCharStr,  long cchWideChar) LIBRARY "kernel32.dll"
end prototypes


type variables
constant  long CP_ACP = 0
constant  long CP_UTF8 = 65001


end variables


forward prototypes
public function integer of_unicode_utf8 (ref blob ablb_source, ref blob ablb_target)
public function string of_utf8_asni (blob ablb_source)
public function integer of_utf8_unicode (ref blob ablb_source, ref blob ablb_target)
public function integer of_ansi_unicode (string as_ansi, ref blob ablb_unicode)
public function integer of_ansi_utf8 (ref string as_ansi, ref blob ablb_utf8)
end prototypes


public function integer of_unicode_utf8 (ref blob ablb_source, ref blob 


ablb_target);//====================================================================
// 函数: of_unicode_utf8()
//--------------------------------------------------------------------
// 描述: Unicode编码转换为UTF8编码
//--------------------------------------------------------------------
// 参数: 
// reference blob ablb_source   源Unicode字节
// reference blob ablb_target   目标UTF8字节	
//--------------------------------------------------------------------
// 返回值:  integer 转换后的字节长度
//--------------------------------------------------------------------
// 作者: David 日期: 2015.7.23
//--------------------------------------------------------------------
// 修改历史: 
// 
//====================================================================
long 		ll_Unicode_Size,ll_UTF8_Size
string	ls_res


ll_Unicode_Size = len(ablb_source)
if ll_Unicode_Size < 1 then
	return 0
end if


ll_Unicode_Size = ll_Unicode_Size / 2
ll_UTF8_Size = WideCharToMultiByte(CP_UTF8, 0, ablb_source, ll_Unicode_Size, ablb_target, 0, 0, 0)
if ll_UTF8_Size < 1 then
	return 0
end if


ablb_target = Blob(space(ll_UTF8_Size))
ll_UTF8_Size = WideCharToMultiByte(CP_UTF8, 0, ablb_source, ll_Unicode_Size, ablb_target, ll_UTF8_Size, 0, 


0)
if ll_UTF8_Size < 1 then
	return 0
end if


return ll_UTF8_Size




end function


public function string of_utf8_asni (blob 


ablb_source);//====================================================================
// 函数: of_utf8_asni()
//--------------------------------------------------------------------
// 描述: utf8编码转换为asni字符
//--------------------------------------------------------------------
// 参数: 
// reference blob ablb_source   
//--------------------------------------------------------------------
// 返回值:  string 转换后字符串
//--------------------------------------------------------------------
// 作者: David 日期: 2015.7.23
//--------------------------------------------------------------------
// 修改历史: 
// 
//====================================================================


string	ls_res
blob 		lblb_Unicode
long 	
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值