Provision interface of Zhejiang mobile misc1.6 platform (SMS custom link synchronization Interface)

Source: Internet
Author: User

<%

Sbase_64_characters = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789 + /"
Sbase_64_characters = strunicode2ansi (sbase_64_characters)

Function strunicodelen (ascontents)
'Calculate the ANSI encoding length of the Unicode string
Ascontents1 = "A" & ascontents
Len1 = Len (ascontents1)
K = 0
For I = 1 to len1
Asc1 = ASC (mid (ascontents1, I, 1 ))
If asc1 <0 then asc1 = 65536 + asc1
If asc1> 255 then
K = K + 2
Else
K = k + 1
End if
Next
Strunicodelen = K-1
End Function

Function strunicode2ansi (ascontents)
'Convert a Unicode-encoded string to an ANSI-encoded string.
Strunicode2ansi = ""
Len1 = Len (ascontents)
For I = 1 to len1
Varchar = mid (ascontents, I, 1)
Varasc = ASC (varchar)
If varasc <0 then varasc = varasc + 65536
If varasc> 255 then
Varhex = hex (varasc)
Varlow = left (varhex, 2)
Varhigh = right (varhex, 2)
Strunicode2ansi = strunicode2ansi & chrb ("& H" & varlow) & chrb ("& H" & varhigh)
Else
Strunicode2ansi = strunicode2ansi & chrb (varasc)
End if
Next
End Function

Function stransi2unicode (ascontents)
'Convert an ANSI-encoded string to a Unicode-encoded string.
Stransi2unicode = ""
Len1 = lenb (ascontents)
If len1 = 0 Then exit function
For I = 1 to len1
Varchar = midb (ascontents, I, 1)
Varasc = ASCB (varchar)
If varasc> 127 then
Stransi2unicode = stransi2unicode & CHR (ASCW (midb (ascontents, I + 1, 1) & varchar ))
I = I + 1
Else
Stransi2unicode = stransi2unicode & CHR (varasc)
End if
Next
End Function

Function base64encode (ascontents)
'Encode the ANSI encoded string with base64
'Ascontents should be an ANSI encoded string (Binary strings can also be used)
Dim lnposition
Dim lsresult
Dim char1
Dim char2
Dim char3
Dim char4
Dim byte1
Dim byte2
Dim byte3
Dim savebits1
Dim savebits2
Dim lsgroupbinary
Dim lsgroup64
Dim M4, len1, len2

Len1 = lenb (ascontents)
If len1 <1 then
Base64encode = ""
Exit Function
End if

M3 = len1 mod 3
If m3> 0 then ascontents = ascontents & string (3-m3, chrb (0 ))
'The complement BITs are used to facilitate computation.

If m3> 0 then
Len1 = len1 + (3-m3)
Len2 = len1-3
Else
Len2 = len1
End if

Lsresult = ""

For lnposition = 1 to len2 step 3
Lsgroup64 = ""
Lsgroupbinary = midb (ascontents, lnposition, 3)

Byte1 = ASCB (midb (lsgroupbinary, 1, 1): savebits1 = byte1 and 3
Byte2 = ASCB (midb (lsgroupbinary, 2, 1): savebits2 = byte2 and 15
Byte3 = ASCB (midb (lsgroupbinary, 3, 1 ))

Char1 = midb (sbase_64_characters, (Bytes 1 and 252)/4) + 1, 1)
Char2 = midb (sbase_64_characters, (byte2 and 240)/16) or (savebits1 * 16) and & HFF) + 1, 1)
Char3 = midb (sbase_64_characters, (byte3 and 192)/64) or (savebits2 * 4) and & HFF) + 1, 1)
Char4 = midb (sbase_64_characters, (byte3 and 63) + 1, 1)
Lsgroup64 = char1 & char2 & char3 & char4

Lsresult = lsresult & lsgroup64
Next

'Process the remaining several characters
If m3> 0 then
Lsgroup64 = ""
Lsgroupbinary = midb (ascontents, len2 + 1, 3)

Byte1 = ASCB (midb (lsgroupbinary, 1, 1): savebits1 = byte1 and 3
Byte2 = ASCB (midb (lsgroupbinary, 2, 1): savebits2 = byte2 and 15
Byte3 = ASCB (midb (lsgroupbinary, 3, 1 ))

Char1 = midb (sbase_64_characters, (Bytes 1 and 252)/4) + 1, 1)
Char2 = midb (sbase_64_characters, (byte2 and 240)/16) or (savebits1 * 16) and & HFF) + 1, 1)
Char3 = midb (sbase_64_characters, (byte3 and 192)/64) or (savebits2 * 4) and & HFF) + 1, 1)

If m3 = 1 then
Lsgroup64 = char1 & char2 & chrb (61) & chrb (61) 'Use = to fill the digits
Else
Lsgroup64 = char1 & char2 & char3 & chrb (61) 'Use = to fill in the digits
End if

Lsresult = lsresult & lsgroup64
End if

Base64encode = lsresult

End Function

Function base64decode (ascontents)
'Convert a base64 encoded string to an ANSI encoded string
'Ascontents should also be an ANSI encoded string (Binary strings can also be used)
Dim lsresult
Dim lnposition
Dim lsgroup64, lsgroupbinary
Dim char1, char2, char3, char4
Dim byte1, byte2, byte3
Dim M4, len1, len2

Len1 = lenb (ascontents)
M4 = len1 mod 4

If len1 <1 or M4> 0 then
'String length should be a multiple of 4
Base64decode = ""
Exit Function
End if

'Judge whether the last digit is equal to =
'Determine whether the second to last digit is equal to or not
'Here M4 indicates the number of remaining characters that need to be processed separately.
If midb (ascontents, len1, 1) = chrb (61) Then M4 = 3
If midb (ascontents, len1-1, 1) = chrb (61) Then M4 = 2

If M4 = 0 then
Len2 = len1
Else
Len2 = len1-4
End if

For lnposition = 1 to len2 Step 4
Lsgroupbinary = ""
Lsgroup64 = midb (ascontents, lnposition, 4)
Char1 = bytes B (sbase_64_characters, midb (lsgroup64, 1, 1)-1
Char2 = bytes B (sbase_64_characters, midb (lsgroup64, 2, 1)-1
Char3 = bytes B (sbase_64_characters, midb (lsgroup64, 3, 1)-1
Char4 = bytes B (sbase_64_characters, midb (lsgroup64, 4, 1)-1
Byte1 = chrb (char2 and 48)/16) or (char1 * 4) and & HFF)
Byte2 = lsgroupbinary & chrb (char3 and 60)/4) or (char2 * 16) and & HFF)
Byte3 = chrb (char3 and 3) * 64) and & HFF) or (char4 and 63 ))
Lsgroupbinary = byte1 & byte2 & byte3

Lsresult = lsresult & lsgroupbinary
Next

'Process the remaining several characters
If M4> 0 then
Lsgroupbinary = ""
Lsgroup64 = midb (ascontents, len2 + 1, M4) & chrb (65) 'chr (65) = A, converted to 0
If M4 = 2 then' makes up four digits to facilitate computation
Lsgroup64 = lsgroup64 & chrb (65)
End if
Char1 = bytes B (sbase_64_characters, midb (lsgroup64, 1, 1)-1
Char2 = bytes B (sbase_64_characters, midb (lsgroup64, 2, 1)-1
Char3 = bytes B (sbase_64_characters, midb (lsgroup64, 3, 1)-1
Char4 = bytes B (sbase_64_characters, midb (lsgroup64, 4, 1)-1
Byte1 = chrb (char2 and 48)/16) or (char1 * 4) and & HFF)
Byte2 = lsgroupbinary & chrb (char3 and 60)/4) or (char2 * 16) and & HFF)
Byte3 = chrb (char3 and 3) * 64) and & HFF) or (char4 and 63 ))

If M4 = 2 then
Lsgroupbinary = byte1
Elseif M4 = 3 then
Lsgroupbinary = byte1 & byte2
End if

Lsresult = lsresult & lsgroupbinary
End if

Base64decode = lsresult

End Function

Set conn = server. Createobject ("ADODB. Connection ")
Conn. Open "driver = SQL Server; uid = *; Pwd = *; server = *. *; database = *"

Set xml = server. Createobject ("Microsoft. xmldom ")
XML. async = false
XML. Load request
Set root=xml.doc umentelement

Transactionid = root. childnodes. Item (0). Text
Set OBJ = root. childnodes. Item (1). childnodes. Item (0)

Msgtype = obj. childnodes. Item (1). Text
Send_address_devicetype = obj. childnodes. Item (2). childnodes. Item (0). Text
Send_address_deviceid = obj. childnodes. Item (2). childnodes. Item (1). Text
Dest_address_devicetype = obj. childnodes. Item (3). childnodes. Item (0). Text
Dest_address_deviceid = obj. childnodes. Item (3). childnodes. Item (1). Text
Feeuser_id_useridtype = obj. childnodes. Item (4). childnodes. Item (0). Text
Feeuser_id_msisdn = obj. childnodes. Item (4). childnodes. Item (1). Text
Feeuser_id_pseudo docode = obj. childnodes. Item (4). childnodes. Item (2). Text
Destuser_id_useridtype = obj. childnodes. Item (5). childnodes. Item (0). Text
Destuser_id_msisdn = obj. childnodes. Item (5). childnodes. Item (1). Text
Destuser_id_pseudo docode = obj. childnodes. Item (5). childnodes. Item (2). Text
Linkid = obj. childnodes. Item (6). Text
Actionid = obj. childnodes. Item (7). Text
Actionreasonid = obj. childnodes. Item (8). Text
Spid = obj. childnodes. Item (9). Text
Spserviceid = obj. childnodes. Item (10). Text
Accessmode = obj. childnodes. Item (11). Text
Featurestr = stransi2unicode (base64decode (strunicode2ansi (obj. childnodes. Item (12). Text )))

Conn.exe cute ("provision" & msgtype & "','" & transactionid & "','" & send_address_devicetype & "','" & send_address_deviceid &"', '"& dest_address_devicetype &"', '"& dest_address_deviceid &"', '"& Region &"', '"& feeuser_id_msisdn &"', '"& feeuser_id_pseudo docode &"', '"& destuser_id_useridtype &"', '"& destuser_id_msisdn &"', '"& destuser_id_pseudo docode &"', '"& linkid &"', '"& actionid &"', '"& actionreasonid &"', '"& spid &"', '"& spserviceid &"', '"& accessmode &"', '"& featurestr &"'")
'Response. write "provision '" & msgtype & "', '" & transactionid & "', '" & send_address_devicetype & "', '" & send_address_deviceid &"', '"& dest_address_devicetype &"', '"& dest_address_deviceid &"', '"& Region &"', '"& feeuser_id_msisdn &"', '"& feeuser_id_pseudo docode &"', '"& destuser_id_useridtype &"', '"& destuser_id_msisdn &"', '"& destuser_id_pseudo docode &"', '"& linkid &"', '"& actionid &"', '"& actionreasonid &"', '"& spid &"', '"& spserviceid &"', '"& accessmode &"', '"& featurestr &"'"

Dim xmlstr
Response. contenttype = "text/XML"
Xmlstr = xmlstr + "<? XML version = "" 1.0 "" encoding = "" UTF-8 ""?> "& Vbcrlf
Xmlstr = xmlstr + "<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/ ">" & vbcrlf
Xmlstr = xmlstr + "<SOAP-ENV: Header>" & vbcrlf
Xmlstr = xmlstr + "<transactionid xmlns =" "http://www.monternet.com/dsmp/schemas/"> "& transactionid &" </transactionid> "& vbcrlf
Xmlstr = xmlstr + "</SOAP-ENV: Header>" & vbcrlf
Xmlstr = xmlstr + "<SOAP-ENV: Body>" & vbcrlf
Xmlstr = xmlstr + "<syncorderrelationresp xmlns =" "http://www.monternet.com/dsmp/schemas/"> "& vbcrlf
Xmlstr = xmlstr + "<version> 1.5.0 </version>" & vbcrlf
Xmlstr = xmlstr + "<msgtype> syncorderrelationresp </msgtype>" & vbcrlf
Xmlstr = xmlstr + "<HRET> 0 </HRET>" & vbcrlf
Xmlstr = xmlstr + "</syncorderrelationresp>" & vbcrlf
Xmlstr = xmlstr + "</SOAP-ENV: Body>" & vbcrlf
Xmlstr = xmlstr + "</SOAP-ENV: envelope>" & vbcrlf
Response. Write xmlstr

%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.