简体   繁体   English

如何从Windows 2003 Server ASP进行远程安全的Web呼叫

[英]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.

相关问题 Windows Server 2003上的经典ASP - Classic ASP on Windows Server 2003 从Windows Server 2003迁移到Server 2008后,ASP Classic功能似乎无法正常工作 - ASP Classic function appears to not work after migration from Windows Server 2003 to Server 2008 从远程服务器从ASP发布到Web服务 - Post to Web Service from ASP, from Remote Server 将Microsoft应用程序从Windows 2003 Server迁移到Windows 2012 Server - migrating Microsoft apps from windows 2003 server to windows 2012 server 在Windows Server 2003 IIS6上将Excel生成为经典ASP应用程序 - Generating Excel to classic asp app on Windows Server 2003 IIS6 在 Windows 服务器 2003 中的 IIS 7.5 中配置 .ASP 页面 - Configuring .ASP pages in IIS 7.5 in Windows server 2003 在Windows 2003服务器上的ASP应用程序中有哪些选项可以替换CDONTS - What options are there for replacing CDONTS in an ASP application on Windows 2003 server 迁移问题:ASP经典应用程序中的错误“ 80040e14”从Windows Server 2003 / SQL Server 2000迁移到Windows Server 2008 R2 / SQL Server 2012 - Migration Issue: error '80040e14' in ASP classic application from Windows server 2003/SQL Server 2000 to Windows Server 2008 R2/SQL Server 2012 在Windows Server 2003 IIS中将ASP.NET页面与ASP页面混合 - Mixing ASP.NET pages with ASP Pages in windows server 2003 IIS 在虚拟化的Windows 2003 x64服​​务器上使用ASP连接到MySQL数据库 - Connecting to MySQL database with ASP on a virtualized Windows 2003 x64 server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM