Solved

Get trough Authentification in ASP.NET for a Domino WebService

Posted on 2008-10-23
10
787 Views
Last Modified: 2013-11-17
I'm building a webservice in Domino designer that acces a lotus notes database. (we are on Ver. 7)

I want to consume that web service in ASP.net.
Whe i use a get method, i got a "Client found response content type of 'text/html; charset=UTF-8', but expected 'text/xml'."

I guess it's because i got to pass trough the Authentification process because when i go to the ?WSDL page, i got the "Log in to Sametime" page (the same that when i go to to out mail web access).
So i guess that is the 'text/html" response?
 
How could i provide a user/password to the webservice or another workaround?



 
0
Comment
Question by:David Robitaille
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 20

Assisted Solution

by:brwwiggins
brwwiggins earned 500 total points
ID: 22790276
This article might help but I think you have to have basic authentication

http://interoptips.com/forums/thread/25.aspx

We use session authentication and I never really got it working but I was just playing around.
0
 
LVL 18

Author Comment

by:David Robitaille
ID: 22790321
i dont think we use basic authentication, becaute it dont work...
How could i check?
 
0
 
LVL 20

Expert Comment

by:brwwiggins
ID: 22790420
in the server document in the address book

this might help as well. Didn't know it existed http://www.ibm.com/developerworks/wikis/display/dominoappdev/Overriding+Session+Authentication+rules
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 18

Author Comment

by:David Robitaille
ID: 22790520
OK, i will get my Server admin "Overriding Session Authentication rules" for me.
As another trail, i`m trying to manually log in thoug the form using a technique like this:
http://odetocode.com/Articles/162.aspx 
But it s look like I cant build a good "postData" string...
i will keep in touch...
 
0
 
LVL 18

Author Comment

by:David Robitaille
ID: 22812774
Well, I got my sysadmin add an rule and he said he restarted the HTTP part of the server, but it still not working. (I mean passing Credential to the service)
Now, I m trying to pass an cookie to the service but it dosen t work.
Does someone got an example working for notes?
I scroll down on the first link you provided me, and saw information that i thought useful, but i still cant get it work...
I need help!
0
 
LVL 18

Author Comment

by:David Robitaille
ID: 22813111
i thibk i now know why i was missing some reference.
I m using Visual web developer 2008 (express)
When I Add a webreference, I dont get a "reference.vb" file.
is it what i was missing?
Should i make the switch to Visual Studio or there is a way to do it with Visual web developer?
 
0
 
LVL 20

Expert Comment

by:brwwiggins
ID: 22813993
I believe the reference.vb proxy class file is only for winforms applications and not relevant on asp.net pages.

I'll see if I can dig up my old project and get it working with the override rule
0
 
LVL 18

Author Comment

by:David Robitaille
ID: 22814093
Thanks, it will be very appreciate
0
 
LVL 18

Accepted Solution

by:
David Robitaille earned 0 total points
ID: 22815940
I did it!
I found a way to get the authentication cookie and forward it to the webservice!
I use the link i provided + the one brwwiggins provided me in the first place.
I asked my sysadmin to remove the rule so i could confirm it work using session authentication.
Here my code!
 

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
 
        Dim QSWEBService As New WEBService()
 
        'connect to the service the first time
        Dim webRequest As Net.HttpWebRequest
        webRequest = Net.HttpWebRequest.Create(QSWEBService.Url)
        Dim responseReader As System.IO.StreamReader = New System.IO.StreamReader(webRequest.GetResponse().GetResponseStream())
        Dim responseData As String = responseReader.ReadToEnd()
        responseReader.Close()
 
        'have a cookie container ready to receive the forms auth cookie
        Dim cookies As System.Net.CookieContainer = New System.Net.CookieContainer()
 
        'construct the data to post
        Dim postDataByte As Byte()
        Dim userName As String = "myUserName"
        Dim password As String = "MyPassword"
        'enncode the form data string into a byte array 
        postDataByte = System.Text.Encoding.ASCII.GetBytes("username=" & userName & "&password=" & password)
 
        'indicate that you will be posting the data 
        Dim LOGIN_URL As String = "http://www.myurl.com/names.nsf?Login&&RedirectTo=" & QSWEBService.Url
        webRequest = Net.HttpWebRequest.Create(LOGIN_URL)
        webRequest.Method = "POST"
        webRequest.ContentType = "application/x-www-form-urlencoded"
        webRequest.AllowAutoRedirect = False
 
        webRequest.CookieContainer = cookies
 
        'write the form values into the request message
        Dim postStream As System.IO.Stream = webRequest.GetRequestStream()
        postStream.Write(postDataByte, 0, postDataByte.Length)
        ' Close the post
        postStream.Close()
 
        'we don't need the contents of the response, just the cookie it issues
 
        'This code is in case we want to get it (debugging) 
        'responseReader = New System.IO.StreamReader(webRequest.GetResponse().GetResponseStream())
        'responseData = responseReader.ReadToEnd()
        'responseReader.Close()
 
        webRequest.GetResponse().Close()
 
        'now we can send out cookie to the protected WEBService
        QSWEBService.CookieContainer = cookies
        QSWEBService.PreAuthenticate = True
        Dim test As string
 
        test = QSWEBService.GetTest()        
        Label1.Text = test
End Sub

Open in new window

0
 
LVL 20

Expert Comment

by:brwwiggins
ID: 22816038
wow, great job !! I will have to keep this for reference.
Thanks for sharing
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Iteration Help (Asp.net VB) 5 37
problem with deleted user 14 40
Where does legacy ASP.NET initialize language? 2 65
vb.net convert long time to mm:ss 23 23
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question