PB 通过http协议以POST方式将XML发送到协议服务器

最近接触了手机支付系统,现在需要将生成的xml发送至服务器。
我查看了pb的帮助文件,posturl可以实现该功能
 
servicereference.PostURL ( urlname, urldata, headers, {serverport, } data )

Argument Description
servicereference Reference to the Internet service instance.
urlname String specifying the URL to post.
urldata Blob specifying arguments to the URL specified by urlname.
headers String specifying HTML headers. In Netscape, a newline (~n) is required after
each HTTP header and a final newline after all headers.
serverport (optional) Specifies the server port number for the request. The default value
for this argument is 0, which means that the port number is determined by the system
(port 80 for HTTP requests).
data InternetResult instance into which the function returns HTML.

 

 

------解决方案--------------------------------------------------------
Blob lblb_args
String ls_header
String ls_url
String ls_args
long ll_length
integer li_rc

inet iinet_base,iinet
//internetresult ir
iinet_base = create inet
iinet = create inet

li_rc = GetContextService( "Internet", iinet_base )

IF li_rc = 1 THEN

    ir = CREATE n_cst_internet
    ls_url = "http://xxx.com/getinfo.asp?"
    ls_args = "var1=tr&var2=tttt&var3=&var4=r&var5=&var6=&var7=tttt&var8=&var9=&var10=ttt&var11="
    lblb_args = Blob( ls_args )

    ll_length = Len( lblb_args )

    ls_header = "Content-Type: " + &
             "application/x-www-form-urlencoded~n" + &
          "Content-Length: " + String( ll_length ) + "~n~n"

     li_rc = iinet.PostURL( ls_url, lblb_args, ls_header, ir )

     messagebox('',string(li_rc))

END IF

integer li_filenum
li_filenum = fileopen('c:\1.html',textmode!,write!,shared!,replace!,encodingUTF8!)
filewriteex(li_filenum,ir.is_data)
fileclose(li_filenum)


ole_1.object.navigate('c:\1.html')

destroy iinet_base
destroy iinet
destroy ir

 

另一个方法,用ole

 

OLEObject dom, http
String Http_Name,result

Http_Name = "http://... "

dom = CREATE OLEObject
http = CREATE OLEObject
//messagebox调试看是否成功
messagebox( 'http ',http.ConnectToNewObject( "Msxml2.XMLHTTP "))
messagebox( 'dom ',dom.ConnectToNewObject( "Msxml2.DOMDocument "))

dom.Load( "c:\xxx.xml ")
http.Open( "POST ", Http_Name, TRUE)
http.Send(dom.xml)
do While http.readyState <> 4 // ' 查询状态,延时
yield()
Loop

result = http.responseText //这个测试用! 你可不写
messagebox( 'result ',result)

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值