从vb6.0 inet dll调用的HTTPWebRequest转换 [英] HTTPWebRequest conversion from vb6.0 inet dll call

查看:182
本文介绍了从vb6.0 inet dll调用的HTTPWebRequest转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将旧的vb6.0应用转换为vb.net。 vb6.0应用程序使用iNet Dll向一个非常古老的网站发出HTTPS请求,允许脚本访问以提取数据。



我认为我需要使用HTTPWebRequest类,但我不熟悉WebRequest方法,似乎无法弄清楚如何分解旧代码sCommand字符串以使用WebRequest调用。



以下是我需要转换为使用WebRequest方法的vb6.0应用程序的关键代码行。



< pre lang =vb> ' 将用户名和密码转换为Base64 - 网站要求
sLogon = Base64Encode( UserName& & PW

' 通过HTTPS脚本获取数据
sCommand = https://www.MyTargetSite.com/ servlet / SAServlet?CONTROLLER = ETScriptedAccessCtlr& ScriptedAccessType = Static& ACTION =& LANGUAGE = en& RunTraceList& TraceName = MyTraceName& ResponseOption = New + Events& OutputType = Output + To + File(逗号+分隔)
frmMain.Inet1.Execute(sCommand, GET ,, 授权:基本& sLogon)





请注意我主要是一个数据人员,我真的不熟悉所有的HTTPS内容所以这些例子这可以告诉我在哪里放置HTTP参数,用户名和密码,基本URL等将是非常有益的。



提前谢谢。

解决方案

可能你试图使用VB Internet Control 执行

http://msdn.microsoft.com/en-us /library/aa239737%28v=vs.60%29.aspx [ ^ ]



忘了这个蹩脚。始终尝试使用纯.NET FCL。 HttpWebRequest (根据HTTP响应)是您真正需要的。请看我过去的答案:

如何从其他网站获取数据 [ ^ ],

从网页获取特定数据 [ ^ ]。



-SA

I'm in the process of converting an old vb6.0 app to vb.net. The vb6.0 app uses the iNet Dll to make an HTTPS request to a very old web site that allows for scripted access to pull data.

I assume I need to use the HTTPWebRequest class but I'm just not that familiar with the WebRequest methods and can't seem to figure out how to break up the old codes sCommand string to work with the WebRequest call.

Below are the key lines of code from the vb6.0 app that I need to convert to use the WebRequest method(s).

'Convert UserName and Password to Base64 - required by the Site
sLogon = Base64Encode("UserName" & ":" & "PW")

'Get Data via HTTPS Scripting
sCommand = "https://www.MyTargetSite.com/servlet/SAServlet?CONTROLLER=ETScriptedAccessCtlr&ScriptedAccessType=Static&ACTION=&LANGUAGE=en&RunTraceList&TraceName=MyTraceName&ResponseOption=New+Events&OutputType=Output+To+File(Comma+Delimited)"
frmMain.Inet1.Execute(sCommand, "GET", , "Authorization: Basic " & sLogon)



Please consider that I am mostly a data guy and I'm really am not familiar with all of the HTTPS stuff so examples that could show me where to place the HTTP params, UserName and Password, the base URL etc. would be very beneficial.

Thanks in advance.

解决方案

Probably you tried to use VB Internet Control Execute:
http://msdn.microsoft.com/en-us/library/aa239737%28v=vs.60%29.aspx[^]

Just forget this lame. Always try to use pure .NET FCL. HttpWebRequest (and according HTTP response) is all you really need. Please see my past answers:
How to get the data from another site[^],
get specific data from web page[^].

—SA


这篇关于从vb6.0 inet dll调用的HTTPWebRequest转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆