注册 登录
编程论坛 ASP.NET技术论坛

求助:GET数据的转发如何实现(续)

bml888 发布于 2012-01-31 16:36, 615 次点击
求助:GET数据的转发如何实现
比如:C程序,A服务器,B服务器,这两个服务器的IP地址不同。
过程:C程序把请求(http://202.202.1.1/gap.asp?GB=2112)发送到A服务器,A服务器原封不动地把请求转发到B服务器,然后B服务器返回一个对应的数据给A服务器。
这个对应数据中包含有一个特定的字串(BAFF),A服务器将其过滤后,C程序从A服务器中读取过滤后的数据。

现在C程序和B服务器都已固定,求A服务器的转发和过滤部分的ASP方案实例示范
不要只提供结构原理,因为本人多次编写,到返回那块就出问题了。
谢谢!!!
3 回复
#2
cnfarer2012-02-01 10:24
用AJAX的GET请求
#3
cnfarer2012-02-01 10:36
参考这个吧
Function   PostHttpPage(RefererUrl,PostUrl,PostData)   
          Dim   xmlHttp   
          Dim   RetStr               
          Set   xmlHttp   =server.CreateObject("Msx"   &   "ml2.XM"   &   "LHT"   &   "TP")     
          xmlHttp.Open   "POST",   PostUrl,   False
          XmlHTTP.setRequestHeader   "Content-Length",Len(PostData)   
          xmlHttp.setRequestHeader   "Content-Type",   "application/x-www-form-urlencoded"
          xmlHttp.setRequestHeader   "Referer",   RefererUrl
          xmlHttp.Send   PostData   
          If   Err.Number   <>   0   Then   
                  Set   xmlHttp=Nothing
                  PostHttpPage   =   "$False$"
                  Exit   Function
          End   If
        PostHttpPage=bytesToBSTR(xmlHttp.responseBody,"GB2312")
        Set   xmlHttp   =   nothing
End   Function
Function   BytesToBstr(strBody,CodeBase)
                dim   obj
                set   obj=Server.CreateObject("Adodb.Stream")
                obj.Type=1
                obj.Mode=3
                obj.Open
                obj.Write   strBody
                obj.Position=0
                obj.Type=2
                obj.Charset=CodeBase
                BytesToBstr=obj.ReadText
                obj.Close
                set   obj=nothing
End   Function

response.write   posthttppage("http://passport.baidu.com/?login&tpl=mn&u=http%3A//www.baidu.com/","https://passport.baidu.com/?login","username=kmiaoer&password=******")
#4
BigPei2012-02-02 14:54
写过的一段代码,仅供参考:
                // Post xml to NAM server(URL in code table, Code Category : PSI_EASY, Code id : NAM_URL get the digital signature
                MSXML2.ServerXMLHTTPClass lxmlhttp = new MSXML2.ServerXMLHTTPClass();
               
                int iXMLTimeOut = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["XmlTimeOut"].ToString());

                lxmlhttp.setTimeouts(iXMLTimeOut, iXMLTimeOut, iXMLTimeOut, iXMLTimeOut);
                lxmlhttp.open("POST",xmlDS.EASY_CONST[0].EASY_NAM_URL, null, null, null); // NAM_URL
                lxmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                lxmlhttp.send("plaintext=" + HttpUtility.UrlEncode(xml,System.Text.UTF8Encoding.UTF8));
                lxmlhttp.waitForResponse(iXMLTimeOut);

                while ( lxmlhttp.readyState < 4 )
                {
                }
                string digitalSignature = lxmlhttp.responseText;
                lxmlhttp=null;
               
1