String ls_url,ls_data,ls_response
string sign_str,host,x-htjs-nonce,x-htjs-ua,ls_date,ls_post,ls_sign
string ls_SECRET,ls_key,Authorization
string isd_url,ls_urlnew,ls_datanew
int li_re
uo_json js_rc
js_rc =create uo_json
CHOOSE CASE as_urlid
CASE '3.1.1' //查询企业标识
isd_url="/cloud/queryUniqueSign"
CASE '3.2.6' //开居发票
isd_url="/cloud/applyInvoice"
CASE '3.2.7'//发票查询
isd_url="/cloud/queryOrder"
CASE '3.3.3'//发票红冲
isd_url="/cloud/applyElecRedInvoice"
CASE '3.3.4'//红冲结果查询
isd_url="/cloud/queryRedInvRes"
CASE '3.3.12'//红冲开具
isd_url="/cloud/doElecRedInvoice"
END CHOOSE
ls_url = "http://api.baiwangjs.com/swgx-saas/agentinvoiceservice-cloudservice-cloudservice/agentiscloud"+isd_url
//ls_url = "http://106.15.161.131/swgx-saas/agentinvoiceservice-cloudservice-cloudservice/agentiscloud"+isd_url
ls_post='POST /swgx-saas/agentinvoiceservice-cloudservice-cloudservice/agentiscloud'+isd_url+' HTTP/1.1'
ls_urlnew='http://192.168.50.57:8099/api/Mobile/baiWang'
uo_json js
js = create uo_json
js =au_json
//js.parsefile('d:\json\aa.txt')
uo_crypto crypto
crypto = create uo_crypto
host='api.baiwangjs.com'
//host='106.15.161.131'
x-htjs-nonce=crypto.getuuid()
x-htjs-ua='Java 1.8.0_131 64 bit, sdk-ver=1.0.0'
ls_date=f_gmt()
ls_SECRET='本院的替换'
ls_key='本院替换'
sign_str=ls_post+'~n'
sign_str=sign_str+'date: '+ls_date+'~n'
sign_str=sign_str+'host: '+host+'~n'
sign_str=sign_str+'x-htjs-nonce: '+x-htjs-nonce+'~n'
sign_str=sign_str+'x-htjs-ua: '+x-htjs-ua
gf_writfile(gs_path,'sign_strA:'+ sign_str)
ls_sign=crypto.base64encode(crypto.HmacEncode('sha256',ls_SECRET,crypto.toUTF8(sign_str)))
//Authorization="hmac username='"+ls_key+"', algorithm='hmac-sha256', headers='request-line date host x-htjs-nonce x-htjs-ua', signature='"+ls_sign+"'"
Authorization='hmac username="'+ls_key+'", algorithm="hmac-sha256", headers="request-line date host x-htjs-nonce x-htjs-ua", signature="'+ls_sign+'"'
gf_writfile(gs_path,'AuthorizationA:'+ Authorization)
gf_writfile(gs_path,as_urlid+'入参json:'+js.tostring())
ls_data = crypto.base64encode(crypto.toUTF8(js.tostring()))
gf_writfile(gs_path,as_urlid+'入参base64:'+ls_data)
OleObject lole_tenyear
lole_tenyear = CREATE oleobject
//XMLhttp组件,我测过xp和win7都自带,不需安装任何辅助软件如.net环境
lole_tenyear.ConnectToNewObject("Microsoft.XMLHttp")
//lole_tenyear.ConnectToNewObject('WinHttp.WinHttpRequest.5.1')
/*
//参数解释请看:
//http://blog.csdn.net/ldl22847/article/details/9662927
lole_tenyear.open ("POST",ls_url, false)
lole_tenyear.setRequestHeader ("Content-type", "application/json")
//lole_tenyear.setRequestHeader('Content-Length',string(len(ls_data)))
lole_tenyear.setRequestHeader ("Authorization", Authorization)
lole_tenyear.setRequestHeader ("x-htjs-ua", x-htjs-ua)
lole_tenyear.setRequestHeader ("Host", host)
lole_tenyear.setRequestHeader ("x-htjs-nonce", x-htjs-nonce)
lole_tenyear.setRequestHeader ("Date", ls_date)
gf_writfile(gs_path,as_urlid+'入参1Authorization:'+Authorization)
gf_writfile(gs_path,as_urlid+'入参2x-htjs-ua:'+x-htjs-ua)
gf_writfile(gs_path,as_urlid+'入参3host:'+host)
gf_writfile(gs_path,as_urlid+'入参4x-htjs-nonce:'+x-htjs-nonce)
gf_writfile(gs_path,as_urlid+'入参1DATE:'+ls_date)
gf_writfile(gs_path,as_urlid+'入参1DATA:'+ls_data)
*/
js_rc.set("url", ls_url)
js_rc.set("inparm", ls_data)
ls_datanew=js_rc.tostring()
gf_writfile(gs_path,as_urlid+'入参new:'+ls_datanew)
lole_tenyear.open ("POST",ls_urlnew, false)
lole_tenyear.setRequestHeader ("Content-type", "application/json")
lole_tenyear.send (ls_datanew)
if lole_tenyear.status>=300 then
messagebox('http pos',"网络不通"+ls_datanew)
li_re = -1
else
li_re = 0
end if
//返回值
s_bscs.result = lole_tenyear.responseText
gf_writfile(gs_path,string(lole_tenyear.status)+'反回值A:'+s_bscs.result)
destroy js
destroy js_rc
destroy lole_tenyear
destroy uo_crypto
return li_re