我正在尝试使用 PowerBuilder 11.1 连接到 Vertex 税务数据库,但遇到以下代码问题。
我想我连接正确,因为返回码ls_status_text = loo_xmlhttp.StatusText
是 200 并且没问题ll_status_code = loo_xmlhttp.Status
。
当我从ls_response_text = loo_xmlhttp.ResponseText
代码中获取返回值时,返回值就是 MOTW 消息。
我期待下面的代码发送 ls_get_url (其中包含要发送到顶点的 xml)并接收一个大的 xml 作为回报,并根据 ls_get_url xml 计算税率。我得到的是 ls_status_text = 'OK' 和 ll_Status_code = 200 (任何> 300都是一个问题)。
// 获取请求 loo_xmlhttp.open("GET",ls_get_url , false) loo_xmlhttp.send()
//Get response
ls_status_text = ''
ls_status_text = loo_xmlhttp.StatusText
ll_status_code = loo_xmlhttp.Status
上述代码块成功运行后,将运行以下代码:
if ll_status_code >= 300 then
MessageBox("HTTP POST Request Failed", ls_response_text)
else
//Get the response we received from the web server
ls_response_text = loo_xmlhttp.ResponseText
MessageBox("POST Request Succeeded", ls_response_text)
end if
我收到“POST Request Succeeded”消息框,但 ls_response_text 包含 Mark Of The Web 语法。
你有什么想法可以帮助我吗?
谢谢!
String ls_get_url, ls_post_url
String ls_post_variables, ls_response
String ls_response_text, ls_status_text
long ll_status_code
OleObject loo_xmlhttp
//include parameters on the URL here for get parameters
ls_get_url = 'http://10.1.1.65:8095/vertex-ui/vertextcc.jsp'
try
//Create an instance of our COM object
loo_xmlhttp = CREATE oleobject
loo_xmlhttp.ConnectToNewObject( 'Microsoft.XMLHTTP')
// Get request
loo_xmlhttp.open ("GET",ls_get_url , false)
loo_xmlhttp.send()
//Get response
ls_status_text = ''
ls_status_text = loo_xmlhttp.StatusText
ll_status_code = loo_xmlhttp.Status
//Check HTTP Response code for errors
if ll_status_code >= 300 then
MessageBox("HTTP GET Request Failed", ls_response_text)
else
//Get the response we received from the web server
ls_response_text = loo_xmlhttp.ResponseText
MessageBox("GET Request Succeeded", ls_response_text)
end if
ls_post_url = 'http://10.1.1.65:8095/vertex-ui/vertextcc.jsp'
ls_post_variables = "I add my custom xml here - I can run it in the vertex software and the xml executes fine"
loo_xmlhttp.open ("POST",ls_post_url, false)
loo_xmlhttp.send(ls_post_variables)
//Get response
ls_status_text = loo_xmlhttp.StatusText
ll_status_code = loo_xmlhttp.Status
//Check HTTP Response code for errors
if ll_status_code >= 300 then
MessageBox("HTTP POST Request Failed", ls_response_text)
else
//Get the response we received from the web server
ls_response_text = loo_xmlhttp.ResponseText
MessageBox("POST Request Succeeded", ls_response_text)
end if
loo_xmlhttp.DisconnectObject()
catch (RuntimeError rte)
MessageBox("Error", "RuntimeError - " + rte.getMessage())
end try