tags:

views:

143

answers:

1

I am just trying to consuming a web service in remote computer using windows authentication however login credentials are different in local & remote computer.

Code Snippet:

Dim objproxy As New WebReference.Service1
'Create a new instance of CredentialCache.
Dim mycredentialCache As CredentialCache = New CredentialCache()
'Create a new instance of NetworkCredential using the client
Dim credentials As NetworkCredential = New NetworkCredential("username", "pwd","domain")
'Add the NetworkCredential to the CredentialCache.
'mycredentialCache.Add(New Uri(objproxy.Url), "Basic", credentials)
objproxy.Credentials = credentials

It is timing out but when i use

mycredentialCache.Add(New Uri(objproxy.Url), "Basic", credentials)

I get "401 Unauthorized" message,

Please assist.

A: 

You want windows authentication so use:

mycredentialCache.Add(New Uri(objproxy.Url), "Negotiate", credentials)

See Passing Credentials for Authentication to Web Services

Tuzo
Tuzo, Thanks for the link i have tried using the above option it doesn't work :-(
Can you browse the service using a web browser? Also you can try inspecting the HTTP traffic using something like Fiddler to see what is happening on the wire.
Tuzo
Tuzo, I am able to add webreference successfully,have to check with fiddler to find out what's wrong with it