|
-
Jun 22nd, 2006, 07:09 AM
#1
Thread Starter
New Member
Handshaking in ASP
Hi all,
In my VBScript code, I want to be able to invoke an external script (a jsp script living in some other server) and pass a variable to that script that will do some database stuff, block and wait for that script to complete, and once it is done, resume with my code.
How do I do a url invocation without doing a redirect?
Thanks,
Didou
-
Jun 22nd, 2006, 04:23 PM
#2
PowerPoster
Re: Handshaking in ASP
There's a couple ways ..
<img src="http://www.other.com/page.asp?id=23" border="0" width="1" height="1">
This doesnt halt your script though generally, and has limitations ..
Then there is the MSXML Method ...
Rory
-
Jun 22nd, 2006, 04:31 PM
#3
PowerPoster
Re: Handshaking in ASP
Here is the MSXML version ..
(see the ASP page in this example also .. http://www.vbforums.com/showthread.p...70#post2477670)
A very simple example of the remote page would be ..
<% Response.Write "Okay" %>
or ..
<%
If Request("action") = "get" Then
Response.Write Request("id")
Else
Response.Write "Error"
End If
%>
Code:
<%@ Language="VBScript" %>
<%
Option Explicit
'// SET RESPONSE HEADERS
Response.Buffer = True
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "cache-control","private"
Response.AddHeader "pragma", "no-cache"
Dim objHttp
Dim strText
Dim strURL
Dim strStatus
Dim strResults
strURL = "http://www.other.com/page.asp?action=get&id=24"
'// GET A REMOTE WEB PAGE
Function RemoteData()
Dim strData
On Error Resume Next
Set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
objHttp.Open "GET", strURL, False
objHttp.setRequestHeader "Content-Type", "text/html"
If Err = 0 Then
objHttp.send
strStatus = objHttp.Status
strResults = objHttp.StatusText
strData = objHttp.ResponseText
End If
Set objHttp = Nothing
If Err <> 0 Then
strData = "Error " & Err.Number & "<br>" & _
Err.Description & vbCrLf
End If
RemoteData = strData
End Function
'// GET PAGE NOW
strText = RemoteData
'// RESPONSE ERROR
If strStatus >= 400 And strStatus <= 500 Then
Response.Write "Error " & strStatus & "<br>"
Response.Write strResults & vbCrLf
Response.End
'// SHOW DATA FROM PAGE
Else
Response.Status = "200 Ok"
Response.Write strText
End If
%>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|