最近接触了手机支付系统,现在需要将生成的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)