zoukankan
html css js c++ java
【Vegas原创】A系统(aspx)向B系统(asp)交互(XmLHttp)
A系统 :
Imports
System.Xml
Partial
Class _Default
Class
_Default
Inherits
System.Web.UI.Page
Protected
Sub Page_Load()
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
Dim
strXML
As
String
Dim
URL
As
String
Dim
strRtn
As
String
strXML
=
"
<?xml version='1.0' encoding='utf-8' ?><ROOT>
"
strXML
=
strXML
&
"
<FORM_KIND>***</FORM_KIND>
"
strXML
=
strXML
&
"
<IS_UPDATE>N</IS_UPDATE>
"
strXML
=
strXML
&
"
<FORM_NO>0</FORM_NO>
"
'
IS_UPDATE等于Y时为表单号码
strXML
=
strXML
&
"
<FORM_FILLER>0606806</FORM_FILLER>
"
'
填表人工号
strXML
=
strXML
&
"
<EMP_NO>0606806</EMP_NO>
"
'
申请人工号
strXML
=
strXML
&
"
<FIELD_COUNT>7</FIELD_COUNT>
"
'
分隔的字段数
strXML
=
strXML
&
"
<FIELDS>
"
strXML
=
strXML
&
"
TRAIN_NAME*+*TRAIN_NO*+*TIME*+*HOURS*+*PROCESS_UNIT*+*NEED_RETURN*+*APP_NAME
"
strXML
=
strXML
&
"
</FIELDS>
"
strXML
=
strXML
&
"
<ROWS>
"
strXML
=
strXML
&
"
<ROW>
"
strXML
=
strXML
&
"
<VALUE>
"
strXML
=
strXML
&
"
test*+*123*+*11:00*+*12*+*SC00*+*Y*+*Vegas
"
strXML
=
strXML
&
"
</VALUE>
"
strXML
=
strXML
&
"
</ROW>
"
strXML
=
strXML
&
"
</ROWS>
"
strXML
=
strXML
&
"
</ROOT>
"
Dim
xmlhttp
As
New
MSXML.XMLHTTPRequest()
URL
=
"
http://***/forms/VegasTest.asp?xmlText=
"
&
strXML
xmlhttp.open(
"
POST
"
, URL,
False
)
xmlhttp.send()
Dim
xmlDom
As
New
System.Xml.XmlDocument
xmlDom.LoadXml(xmlhttp.responseText)
Dim
Form_Result
As
String
Dim
Form_Kind
As
String
Dim
Form_No
As
String
Dim
Err_Desc
As
String
Form_Result
=
xmlDom.SelectSingleNode(
"
/ROOT/FORM_RESULT
"
).InnerXml
Form_Kind
=
xmlDom.SelectSingleNode(
"
/ROOT/FORM_KIND
"
).InnerXml
Form_No
=
xmlDom.SelectSingleNode(
"
/ROOT/FORM_NO
"
).InnerXml
Err_Desc
=
xmlDom.SelectSingleNode(
"
/ROOT/FORM_DESC
"
).InnerXml
strRtn
=
""
If
Form_Result
=
"
Y
"
Then
'
成功
'
…
strRtn
=
""
ElseIf
Form_Result
=
"
N
"
Then
'
失败
'
…
strRtn
=
"
Failure
"
ElseIf
Form_Result
=
"
ERROR
"
Then
'
失败
'
…
strRtn
=
Err_Desc
End
If
lblMsg.text
=
strRtn
End Sub
End Class
B系统:
<%
@CODEPAGE
=
936
Language
=
VBScript
%>
<%
Response.Charset
=
"
gb2312
"
%>
<%
Response.Buffer
=
true
%>
<!--
#include file="../Service/EngineWebservice.asp"
-->
<!--
#include file="FlowERFunction.asp"
-->
<%
On
Error
Resume
Next
'
**接收客户端XML包的数据格式
'
**FIELDS和VALUE中的字段以 *+* 来分隔,且分隔数量必须相同
dim
xmlDom
set
xmlDom
=
createobject
(
"
MSXML2.DOMDocument
"
)
xmlDom.async
=
False
flag
=
xmlDom.loadxml(request.QueryString(
"
xmlText
"
))
if
flag
then
dim
cnn,RsFindEmp_ID
Set
cnn
=
Server.CreateObject(
"
ADODB.Connection
"
)
cnn.Open Session(
"
ConnectionString
"
)
'
myWriteLog Form_Kind,"1. Receive: " & xmlDom.xml
dim
Form_No, Form_kind, strFlag
dim
Form_Filler, Emp_No
dim
FieldCount
dim
arrC1, arrC2
dim
strFields,strValue
Form_No
=
trim
(xmlDom.selectSingleNode(
"
/ROOT/FORM_NO
"
).Text)
Form_kind
=
trim
(xmlDom.selectSingleNode(
"
/ROOT/FORM_KIND
"
).Text)
Form_Filler
=
trim
(xmlDom.selectSingleNode(
"
/ROOT/FORM_FILLER
"
).Text)
Emp_No
=
trim
(xmlDom.selectSingleNode(
"
/ROOT/EMP_NO
"
).Text)
FieldCount
=
trim
(xmlDom.selectSingleNode(
"
/ROOT/FIELD_COUNT
"
).Text)
strFlag
=
trim
(xmlDom.selectSingleNode(
"
/ROOT/IS_UPDATE
"
).Text)
myWriteLog Form_Kind,
"
1. Receive:
"
&
xmlDom.xml
FieldCount
=
FieldCount
*
1
strFields
=
xmlDom.selectSingleNode(
"
/ROOT/FIELDS
"
).Text
arrC1
=
Split
(strFields,
"
* *
"
)
dim
SqlFindEmp_ID,strEmpId
SqlFindEmp_ID
=
"
select ***.
"
set
RsFindEmp_ID
=
cnn.Execute(SqlFindEmp_ID)
if
not
RsFindEmp_ID.eof
then
strEmpId
=
RsFindEmp_ID(
"
Emp_ID
"
)
RsFindEmp_ID.Close()
else
ReturnXML Form_Kind,Form_No,
"
ERROR
"
,
"
NOEMP_3__
"
&
SqlFindEmp_ID
end
if
select
case
strFlag
case
"
N
"
'
New Form
if
Form_No
<=
0
then
Form_No
=
CreateForm (Form_Kind,strEmpId)
'
调用flowER组件来生成表单编号(FORM_NO)
end
if
case
"
Y
"
'
Update Form
Form_No
=
trim
(xmlDom.selectSingleNode(
"
/ROOT/FORM_NO
"
).Text)
end
select
'
response.write strEmpId & "-" & Form_Kind & "-" & Form_No
'
response.end
if
CLng
(Form_No)
<=
0
then
Connection.Execute
"
exec sp_Facade_DeleteForm Form_Kind,
"
&
Form_No
ReturnXML Form_Kind,
"
3
"
,
"
ERROR
"
,
"
FORM_NO
"
end
if
dim
strsql, intPos
dim
nodeList
dim
xmlNod
set
nodeList
=
xmlDom.selectNodes(
"
/ROOT/ROWS/ROW
"
)
For
Each
xmlNod In nodeList
strValue
=
xmlNod.SelectSingleNode(
"
VALUE
"
).Text
arrC2
=
Split
(strValue,
"
* *
"
)
'
*******************************************************************************************************************8
select
case
Form_Kind
case
"
***
"
intPos
=
GetIndex(arrC1, FieldCount,
"
TRAIN_NAME
"
)
strTrainName
=
arrC2(intPos)
intPos
=
GetIndex(arrC1, FieldCount,
"
TRAIN_NO
"
)
strTrainNo
=
arrC2(intPos)
intPos
=
GetIndex(arrC1, FieldCount,
"
TIME
"
)
strTime
=
arrC2(intPos)
intPos
=
GetIndex(arrC1, FieldCount,
"
HOURS
"
)
strHours
=
arrC2(intPos)
intPos
=
GetIndex(arrC1, FieldCount,
"
PROCESS_UNIT
"
)
strProcessUnit
=
arrC2(intPos)
intPos
=
GetIndex(arrC1, FieldCount,
"
NEED_RETURN
"
)
strNeedReturn
=
arrC2(intPos)
intPos
=
GetIndex(arrC1, FieldCount,
"
APP_NAME
"
)
strAppName
=
arrC2(intPos)
'
----------更新或插入表单数据
strsql
=
"
***.
"
'
end modify
set
myt
=
cnn.Execute(strsql)
if
not
myt.eof
then
'
'********************************************************回传参数
ReturnXML Form_Kind,Form_No,
"
Y
"
,
"
T024_ALREADY EXIST_
"
&
myt(
"
FORM_NO
"
)
strsql
=
"
sp_Facade_DeleteForm '***',
"
&
Form_No
cnn.Execute strsql
else
strsql
=
"
procedure *** '
"
&
Form_Filler
&
"
','
"
&
Form_Kind
&
"
',
"
&
Form_No
&
"
,'
"
&
Emp_No
&
"
'
"
strsql
=
strsql
&
"
,'
"
&
strTrainName
&
"
','
"
&
strTrainNo
&
"
','
"
&
strTime
&
"
','
"
strsql
=
strsql
&
strHours
&
"
','
"
&
strProcessUnit
&
"
','
"
&
strNeedReturn
&
"
','
"
&
strAppName
&
"
'
"
cnn.Execute strsql
end
if
end
select
myWriteLog Form_Kind,
"
2. Execute:
"
&
strsql
next
'
Each in nodeList
'
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Form_No
=
Form_No
&
""
SendFormResult
=
SendForm(Form_Kind, Form_No
&
""
, strEmpId,
"
1
"
)
'
调用flowER组件来生成或更新表单
ActiveFormResult
=
ActiveForm(Form_Kind, Form_No
&
""
)
if
LCase
(SendFormResult)
=
"
true
"
then
strResult
=
"
Y
"
else
strResult
=
"
N
"
end
if
'
*************************************************************
'
**Return the result to client
ReturnXML Form_Kind,Form_No,strResult,err.description
else
'
response.Write 11
'
response.End
ReturnXML
"
0
"
,
"
0
"
,
"
ERROR
"
,
"
RECEIVE:
"
&
xmlDom.parseError.reason
'
response.write xmlDom.parseError.reason
end
if
%>
<%
'
**********************************************************************
'
**Get the index of array
function
GetIndex(arrExpression, arrCount, SearchString)
dim
intPos, i
arrCount
=
arrCount
*
1
if
UCase
(
isArray
(arrExpression))
=
"
FALSE
"
or
arrCount
<=
0
then
intPos
=
0
else
for
i
=
0
to
arrCount
-
1
if
SearchString
=
arrExpression(i)
then
intPos
=
i
end
if
next
end
if
GetIndex
=
intPos
end function
'
**********************************************************************
'
**Return the processed result to client
sub
ReturnXML(Form_Kind, Form_No, Result, Desc)
on
error
resume
next
strxml
=
"
<?xml version='1.0' encoding='utf-8' ?><ROOT>
"
strxml
=
strxml
&
"
<FORM_KIND>
"
&
Form_Kind
&
"
</FORM_KIND>
"
strxml
=
strxml
&
"
<FORM_NO>
"
&
Form_No
&
"
</FORM_NO>
"
strxml
=
strxml
&
"
<FORM_RESULT>
"
&
Result
&
"
</FORM_RESULT>
"
strxml
=
strxml
&
"
<FORM_DESC>
"
&
Desc
&
"
</FORM_DESC>
"
strxml
=
strxml
&
"
</ROOT>
"
myWriteLog Form_Kind,
"
3. Return: FORM_KIND=
"
&
Form_Kind
&
"
-- FORM_NO=
"
&
Form_No
&
"
-- FORM_RESULT=
"
&
Result
&
"
-- ERR_DESC=
"
&
Desc
response.write strxml
if
Result
<>
"
Y
"
then
'
发生错误时删除该表单 Anson,04/12/2004
Connection.Execute
"
exec sp_Facade_DeleteForm '
"
&
trim
(Form_Kind)
&
"
',
"
&
Form_No
myWriteLog Form_Kind,
"
3. Return--DELETE: FORM_KIND=
"
&
Form_Kind
&
"
-- FORM_NO=
"
&
Form_No
&
"
-- FORM_RESULT=
"
&
Result
&
"
-- ERR_DESC = DELETE
"
end
if
response.end
end sub
'
**********************************************************************
'
**
sub
myWriteLog(FORM_KIND,strMsg)
on
error
resume
next
dim
strLogFileName
'
strLogFileName = "Receive_FormData_" & FORM_KIND & ".Log" 'Log文件名
strLogFileName
=
"
LOG\COMMON\
"
&
FORM_KIND
&
"
_
"
&
Year
(
date
)
&
"
-
"
&
Month
(
date
)
&
"
-
"
&
Day
(
date
)
&
"
.Log
"
'
Log文件名
WriteLog strLogFileName,strMsg,
true
end sub
%>
喜欢请赞赏一下啦^_^
查看全文
相关阅读:
[moka同学笔记]八、Yii2.0课程笔记(魏曦老师教程)[授权]
[moka同学转载]Yii2 中国省市区三级联动
[moka同学笔记]四、Yii2.0课程笔记(魏曦老师教程)[匿名函数的使用操作]
[moka同学笔记]Linux命令基本格式及目录处理命令
[moka同学笔记]使用composer 安装yii2以及遇到的问题
[moka同学笔记]MySql语句整理
[moka同学笔记]三、Yii2.0课程笔记(魏曦老师教程)关联字段增加搜索
Android笔记:ListView
Android笔记:去除标题栏
Android笔记:内部类
原文地址:https://www.cnblogs.com/amadeuslee/p/3744585.html
最新文章
javascript基础-事件1
javascript基础-对象
javascript基础-闭包
javascript基础-BOM原理
javascript基础-语法
3.ELK 之elasticsearch CRUD
2. ELK 之kibana 简介、获取、安装
1. ELK 之elasticsearch 简介、获取、安装
ANGULAR6.x
Crystal Reports报表使用 [一]
热门文章
记JS一个错误,
极光推送踩坑 【一】
JAVA spring 常用包作用
windows下Nginx配置与测试
ajax跨域访问 java controller 和 cxf(webservice) 配置方式(CORS)
[moka同学笔记]php 获取时间(今天,昨天,三天内,本周,上周,本月,三年内,半年内,一年内,三年内)
[moka同学摘录]SQL内联、外联的简单理解
[moka同学收藏]Vim升华之树形目录插件NERDTree安装图解
[moka同学收藏]网页上的“返回上一页”的几种实现代码
[moka同学转载]Yii2 checkBookList的使用
Copyright © 2011-2022 走看看