Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Live Link Login through .NET application 1

Status
Not open for further replies.

algotec

Programmer
Jul 30, 2001
2
CA
Hi,

First the goal:
1.First request - Login to Live Link 9.5 programaticaly from .net application using httpWebRequest POST method

2.Second request - Retreieve xml using objAction=XMLEXport parameter

VB.NET code looking something like this:

==============
Dim newUri As New Uri(url)
Dim result As String = ""
Dim nexturl As String = Server.UrlEncode("Dim encoding As System.Text.ASCIIEncoding = New System.Text.ASCIIEncoding()
Dim strPost As String = "func=ll.login&Username=username&Password=password&nextURL=" & nexturl
Dim data As Byte() = encoding.GetBytes(strPost)
Dim myWriter As StreamWriter = Nothing
Dim objRequest As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)

objRequest.Method = "POST"
objRequest.ContentType = "application/x-objRequest.ContentLength = strPost.Length

Dim newStream As Stream = objRequest.GetRequestStream()
' Send the data.
newStream.Write(data, 0, data.Length)
newStream.Close()

objRequest.CookieContainer = cookCont

Dim objResponse As HttpWebResponse = objRequest.GetResponse()
Dim sr As StreamReader

sr = New StreamReader(objResponse.GetResponseStream())

result = sr.ReadToEnd()

==============
The problem is the as a result I get html:
<HTML>
<!-- File: redirectmeta.html -->
<HEAD>
<TITLE>Livelink - Redirection</TITLE>
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=http://server/instance/livelink.exe?func=ll&objId=2000&objAction=XMLEXport">
</HEAD>
</HTML>
<!-- End File: redirectmeta.html -->

However, at this point I am already supposed to be logged in, in order to send second request and I am not:(

If it helps: My application currently running from localhost and submits to web server where LL is installed

I've checked similar threads, but it seems like no one posted a real solution to this

Thanks for your help
 
So you do not want to use like a LAPI session constructor.
like session=(server,port,dft,username,password,config)
The intent is to sue just http methods and getting output from livelink as XML.

What kind of web server ? which version of livelink etc.
in your output is livelink presenting you a cookie something like LLblahblah cookie three times or so...

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
If you look at the code behind the login request handler which you are going through it has the following comment to explain the redirect page you are seeing:

"Send a small html file with a link to the next page just in case the browser doesn't understand the redirection status code, or if we're using a server that doesn't generate the proper status".

The best way around this issue is to set the login cookie before your call to the XMLExport request. The cookie is encoded so it can't be set to the text value of the username and password.

The second best approach would be to write a special request handler to handle your specific login approach and bypass the redirect.

It also seems like you could anticipate the redirect page and read that and then send the URL for the XMLExport request.
 
Hi Syntergy,

Thank you for the response.

It also seems like you could anticipate the redirect page and read that and then send the URL for the XMLExport request.

This is exactly what I do - anticipating the redirect page (Assuming that geting the redirect page as a result means I am logged in)and then just ignore it and try XMLExport request as the second request inside the same function.


I can try the second method(writing the request handler), but not sure how to bypass the redirect:(

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top