[英]How to make remote secured web call from Windows 2003 server ASP
How can I make this kind of code for Windows 2003 IIS server? 如何为Windows 2003 IIS服务器制作此类代码?
Dim req as New WebClient()
Dim myCache As New CredentialCache()
myCache.Add(New Uri(URL), "Basic", _
New NetworkCredential(Username, Password))
req.Credentials = myCache
Dim results as String
results = System.Encoding.UTF8.GetString(req.DownloadData(URL))
I suppose you could compile this to a webservice using VB.NET and make calls to it using SOAP from your classic ASP site. 我想您可以使用VB.NET将其编译为Web服务 ,并使用来自经典ASP站点的SOAP对其进行调用。
You may find that you'd need to extend the functionality of the service to include other facilities to manipulate your requirements later on. 您可能会发现您需要扩展该服务的功能,以包括其他功能以稍后处理您的需求。
This probably isn't the best solution, but it's something to consider. 这可能不是最好的解决方案,但这是要考虑的问题。
Found it myself, this VBScript code makes a call to url with user:pass credentials, the base64 class is required due the bug in ms library. 我自己找到了这个VBScript代码,使用user:pass凭据调用url,由于ms库中的错误,因此需要base64类。
Dim http: Set http = Server.CreateObject("MSXML2.ServerXMLHTTP")
dim url
url = "any.html"
http.open "GET", url, False,"user","pass"
http.setRequestHeader "Authorization", "Basic " & Base64Encode("user:pass")
http.send
Function Base64Encode(inData) 'ripped from: ' http://www.pstruh.cz/tips/detpg_Base64Encode.htm 'rfc1521 '2001 Antonin Foller, PSTRUH Software, http://pstruh.cz Const Base64 = _ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" 函数Base64Encode(inData)'摘自:' http ://www.pstruh.cz/tips/detpg_Base64Encode.htm'rfc1521'2001 Antonin Foller,PSTRUH Software, http: //pstruh.cz Const Base64 = _“ ABCDEFGHIJKLMNpQRSTUVWXYZabcyghijklm3456”
Dim sOut, I 'For each group of 3 bytes For I = 1 To Len(inData) Step 3 Dim nGroup, pOut Dim sOut,I'对于每组3个字节,对于I = 1到Len(inData)步骤3 Dim nGroup,pOut'Create one long from this 3 bytes. nGroup = &H10000 * Asc(Mid(inData, I, 1)) + _ &H100 * MyASC(Mid(inData, I + 1, 1)) + _ MyASC(Mid(inData, I + 2, 1)) 'Oct splits the long To 8 groups with 3 bits nGroup = Oct(nGroup) 'Add leading zeros nGroup = String(8 - Len(nGroup), "0") & nGroup 'Convert To base64 pOut = Mid(Base64, CLng("&o" & Mid(nGroup, 1, 2)) + 1, 1) + _ Mid(Base64, CLng("&o" & Mid(nGroup, 3, 2)) + 1, 1) + _ Mid(Base64, CLng("&o" & Mid(nGroup, 5, 2)) + 1, 1) + _ Mid(Base64, CLng("&o" & Mid(nGroup, 7, 2)) + 1, 1) 'Add the part To OutPut string sOut = sOut + pOut Next Select Case Len(inData) Mod 3 Case 1: '8 bit final sOut = Left(sOut, Len(sOut) - 2) + "==" Case 2: '16 bit final sOut = Left(sOut, Len(sOut) - 1) + "=" End Select Base64Encode = sOut End Function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.