关闭

移动MISC接口1.6程序[ASP]

868人阅读 评论(0) 收藏 举报
以下存为default.asp文件
<!--#include file = "conn.asp" -->
<%
    Rem -------------------------------------------
	Rem 文件名:SyncOrderRelationReq.asp
	Rem 作用:解析POST请求的XML,检测处理结果
	Rem 作者:
	Rem MSN :
	Rem -------------------------------------------
%>
<%
	function WriteLog(str)
		dim ofs,oFile,m_tempi
		sPath = "out_SyncOrderRelationReq.txt"
		set ofs = server.createobject("Scripting.FileSystemObject")
		sFileName = Server.MapPath(sPath)
		Set oFile = ofs.OpenTextFile(sFileName, 8 , true)
		oFile.WriteLine str
		set ofs = nothing
	end function
%>
<%
	Response.ContentType="text/xml"
	Response.CharSet="utf-8"
	
    dim ReceivedDoc,oResponseDom
	WriteLog "Synchro Request Begin"	'同步请求开始
	Set ReceivedDoc = server.CreateObject("MSXML2.DOMDocument") 
    ReceivedDoc.async=False 
	'是否同步
    ReceivedDoc.load Request
	'取得post请求
	'///////////////////////////////////
	
	If (ReceivedDoc.parseError.errorCode <> 0) Then
        Set myErr = ReceivedDoc.parseError
		set oResponseSoapBody = oResponseDom.selectSingleNode("//SyncOrderRelationResp")
		oResponseSoapBody.selectSingleNode("hRet").text = "9014"
		'无法解析SOAP和XML结构
		oResponseDom.save(Response)
	    WriteLog "Have error " & myErr.reason
		'response.End()
    End If
	if ReceivedDoc.childNodes.length=0 then
		set oResponseSoapBody = oResponseDom.selectSingleNode("//SyncOrderRelationResp")
		oResponseSoapBody.selectSingleNode("hRet").text = "9014"
		oResponseDom.save(Response)
		WriteLog "无法解析SOAP和XML结构。" 
		'response.End()
	end if
	
   '//////////////////////////////////////
    '得到POST过来的XML文档
	a= ReceivedDoc.selectSingleNode("//TransactionID").text 
	WriteLog "TransactionID="&a
	'消息编号
	b= ReceivedDoc.selectSingleNode("//Version").text
	WriteLog "Version="&b
	'该接口消息的版本号
	c= ReceivedDoc.selectSingleNode("//MsgType").text
	WriteLog "MsgType="&c
	'消息类型
	
    d= ReceivedDoc.selectSingleNode("//Send_Address/DeviceType").text
	WriteLog "DeviceType="&d
	e = ReceivedDoc.selectSingleNode("//Send_Address/DeviceID").text
	WriteLog "DeviceID="&e
	
	f= ReceivedDoc.selectSingleNode("//Dest_Address/DeviceType").text
	WriteLog "DeviceType="&f
	g= ReceivedDoc.selectSingleNode("//Dest_Address/DeviceID").text
	WriteLog "DeviceID="&g
	
	
    h= ReceivedDoc.selectSingleNode("//FeeUser_ID/UserIDType").text
	WriteLog "UserIDType="&h
	i= ReceivedDoc.selectSingleNode("//FeeUser_ID/MSISDN").text
	WriteLog "MSISDN="&i
	j = ReceivedDoc.selectSingleNode("//FeeUser_ID/PseudoCode").text
	WriteLog "PseudoCode="&j

	k= ReceivedDoc.selectSingleNode("//DestUser_ID/UserIDType").text
	WriteLog "UserIDType="&k
	l= ReceivedDoc.selectSingleNode("//DestUser_ID/MSISDN").text
	WriteLog "MSISDN="&l
	m= ReceivedDoc.selectSingleNode("//DestUser_ID/PseudoCode").text
	WriteLog "PseudoCode="&m
	
	n= ReceivedDoc.selectSingleNode("//LinkID").text
	WriteLog "LinkID="&n
	o= ReceivedDoc.selectSingleNode("//ActionID").text
	WriteLog "ActionID="&o
	p= ReceivedDoc.selectSingleNode("//ActionReasonID").text
	WriteLog "ActionReasonID="&p
	q= ReceivedDoc.selectSingleNode("//SPID").text
	WriteLog "SPID="&q
	r= ReceivedDoc.selectSingleNode("//SPServiceID").text
	WriteLog "SPServiceID="&r
	s= ReceivedDoc.selectSingleNode("//AccessMode").text
	WriteLog "AccessMode="&s
	t= ReceivedDoc.selectSingleNode("//FeatureStr").text
	WriteLog "FeatureStr="&t
	 Set ReceivedDoc =nothing	
   WriteLog "同步请求结束"&now()
    WriteLog ""
 
	if nRet<>0 then	'Rem ---------出错处理接口
		nRet = 1
		WriteLog "同步正向订购关系失败 "&now()
	else
		'Rem---------正确返回结果
		sql="select * from tb_test where  i='"&i &"'and  r='"&r&"'"
		rs.open sql,conn,1,3
		if (rs.eof and rs.bof )then '相同号码相同业务代码的不存在
			if  o=1 then
				logout="0"
				logindate=now()
				rs.addnew  '增加
				rs("logindate")=logindate
				rs("logout")=logout
				rs("a")=a
				rs("b")=b
				rs("c")=c
				rs("d")=d
				rs("e")=e
				rs("f")=f
				rs("g")=g
				rs("h")=h
				rs("i")=i
				rs("j")=j
				rs("k")=k
				rs("l")=l
				rs("m")=m
				rs("n")=n
				rs("o")=o
				rs("p")=p
				rs("q")=q
				rs("r")=r
				rs("s")=s
				rs("t")=t
				rs.update
			end if
		else'号码存在
			if  o=2 or o=4 then
				logout="1"
				logoutdate=now()
				rs("logout")=logout
				rs("logoutdate")=logoutdate
				rs.update
			else
				logout="0"
				rs("logout")=logout
				rs.update
			end if 
		end if 
		rs.close
		set rs=nothing
		conn.close
		set conn=nothing
	end if

	nRet=0
	WriteLog "同步应答开始"
	 Set oResponseDom = Server.CreateObject("MSXML2.DOMDocument")
    oResponseDom.async = false'是否同步
	oResponseDom.load(Server.MapPath("SyncOrderRelationResp.xml"))'取得回复格式
	
	oResponseDom.selectSingleNode("//TransactionID").text = a
	WriteLog "TransactionID="&a 
	oResponseDom.selectSingleNode("//hRet").text = nRet
	WriteLog "hRet="&nRet
    '--------------------------------------回送XML。
	oResponseDom.save(Response)
	Set oResponseDom =nothing
	WriteLog "同步应答结束"
	WriteLog "==================================="
	WriteLog ""
	WriteLog ""
%> 



连接数据库文件conn.asp
<%  
dim conn,strconn
strconn ="Provider=SQLOLEDB;DATABASE=Provider;Persist Security Info=True;UID=sa;PWD=owen;Data Source=127.0.0.1"
set conn = server.createobject("adodb.connection")
conn.open strconn
set rs=server.createobject("adodb.recordset")
%>


在SQL中创建如下表

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tb_test]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tb_test]
GO

CREATE TABLE [dbo].[tb_test] (
	[id] [decimal](18, 0) IDENTITY (1, 1) NOT NULL ,
	[logindate] [datetime] NULL ,
	[logout] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[logoutdate] [datetime] NULL ,
	[a] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[b] [text] COLLATE Chinese_PRC_CI_AS NULL ,
	[c] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[d] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[e] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[f] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[g] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[h] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[i] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[j] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[k] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[l] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[m] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[n] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[o] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[p] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[q] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[r] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[s] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[t] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO


同级目录下建立名为:out_SyncOrderRelationReq.txt文件

建立如下SyncOrderRelationResp.xml文件
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
	<SOAP-ENV:Header>
		<TransactionID xmlns="http://www.monternet.com/dsmp/schemas/"></TransactionID>
	</SOAP-ENV:Header>
	<SOAP-ENV:Body>
		<SyncOrderRelationResp xmlns="http://www.monternet.com/dsmp/schemas/">
			<Version>1.5.0</Version>
			<MsgType>SyncOrderRelationResp</MsgType>
			<hRet></hRet>
		</SyncOrderRelationResp>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:331212次
    • 积分:4620
    • 等级:
    • 排名:第6325名
    • 原创:81篇
    • 转载:153篇
    • 译文:1篇
    • 评论:43条
    最新评论