Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / August 2004

Tip: Looking for answers? Try searching our database.

Connecting to a web service thru a proxy server

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wild Wind - 03 Aug 2004 15:42 GMT
Hello all,

I apologise in advance for the long windedness of
this post, but I feel that if I am going to get any
solution to this problem, it is important that I present
as much information that will be useful in diagnosing
the problem.

I have an application which calls a method of a web service
that we host remotely. I have deployed the application to a
client site on which access to the Internet is done through
a proxy server. However, the application on this site is
unable to call the web service method.

It appears that the proxy server requires authentication -
when the users of machines on the site wish to access the web
and start up a web browser, they are presented with a dialog
box in which they type in a UserName and PassWord.

I have tried various different means to call the web service
method, but I have had no success.

I have written code snippets below describing the attempts
I have made to connect to the Internet via this proxy.
Before I describe the various means I have tried, here
are variables that I have used in calling the web service
method:

Dim cred As ICredentials
Dim nwCred as NetworkCredential
Dim cCache As CredentialCache

'this will hold the address of the proxy server thru which
'connections are made to the Internet
Dim proxyURI As String = "http://proxyserveraddress"

Dim uname As String
Dim pwd As String

'this is the proxy generated for my web service
Dim wsObj As MyWebServiceProxy

Now for the code snippets:

Attempt 1 - using default credentials
cred = CredentialCache.DefaultCredentials

'ws obj creation block
wsObj = New MyWebServiceProxy()
wsObj.Proxy = new WebProxy(proxyURI, True, Nothing)
wsObj.Proxy.Credentials = cred
wsObj.Credentials = cred
wsObj.MyWebServiceMethod()

Error Message: The request failed with HTTP status 407:
Proxy authentication required.

Attempt 2 - using supplied credentials

'this is the same UserName/PassWord combination
'supplied before users can browse the web
uname = "UserName"
pwd = "PassWord"

nwCred = New NetworkCredential(uname, pwd)
cred = nwCred

'ws obj creation block as with attempt 1, i.e.
wsObj = New MyWebServiceProxy()
...
wsObj.MyWebServiceMethod()

Error Message: The underlying connection was closed:
An unexpected error occurred on a receive.

Attempt 3 - using NTLM authentication

'this is the same UserName/PassWord combination
'supplied before users can browse the web
uname = "UserName"
pwd = "PassWord"

nwCred = New NetworkCredential(uname, pwd)
cCache = new CredentialCache()
cCache.Add(new uri(ProxyURI), "NTLM", nwCred)
cred = cCache

'ws obj creation block as with attempt 1, i.e.
wsObj = New MyWebServiceProxy()
...
wsObj.MyWebServiceMethod()

Error Message: The request failed with HTTP status 407:
Proxy authentication required.

Attempt 4 - using negotiate authentication

This is identical to attempt 3, except that
in place of

cCache.Add(new uri(ProxyURI), "NTLM", nwCred)

I have

cCache.Add(new uri(ProxyURI), "Negotiate", nwCred)

Error Message: The request failed with HTTP status 407:
Proxy authentication required.

Attempt 5 - using basic authentication

This is identical to attempt 3, except that
in place of

cCache.Add(new uri(ProxyURI), "NTLM", nwCred)

I have

cCache.Add(new uri(ProxyURI), "Basic", nwCred)

Error Message: The underlying connection was closed:
An unexpected error occurred on a receive.

Attempt 6 - using digest authentication

This is identical to attempt 3, except that
in place of

cCache.Add(new uri(ProxyURI), "NTLM", nwCred)

I have

cCache.Add(new uri(ProxyURI), "Digest", nwCred)

Error Message: The request failed with HTTP status 407:
Proxy authentication required.

If you've made it this far, thanks for at least
reading through the post. Any answer(s) will be
gratefully received.

Signature

Akin

aknak at aksoto dot idps dot co dot uk

Nicole Calinoiu - 04 Aug 2004 16:11 GMT
Akin,

Different proxy servers have different authentication requirements, and
deriving these from user behaviour is a bit of stretch.  Have you considered
discussing the problem with a network administrator at this client site?

Nicole

> Hello all,
>
[quoted text clipped - 136 lines]
> reading through the post. Any answer(s) will be
> gratefully received.
Wild Wind - 05 Aug 2004 01:46 GMT
Hello Nicole,

Thanks for the response.

I could certainly speak to the network administrator
to find out what authentication requirements their proxy
server have - it's just that I'm not too sure that they
fully understand how it's been set up, so I would need to
know what specific questions to ask to resolve this problem.

So could you tell me what I should specifically ask for,
and how, based on this information, I could go about
resolving the connectivity problem?

TIA,

Akin

> Akin,
>
[quoted text clipped - 11 lines]
> > as much information that will be useful in diagnosing
> > the problem.

<snip>

> > Akin
> >
> > aknak at aksoto dot idps dot co dot uk
Nicole Calinoiu - 05 Aug 2004 20:27 GMT
Akin,

Well, someone knows, and it won't be either the users or someone with no
access to the systems involved. <g>  Your best bet is to find the IT person
with responsibility for the proxy.  If he doesn't know enough details, he
can probably at least provide you with the product documentation and/or
locate an appropriate vendor contact.  As for questions to ask, you could
start with the value of every property you'll need to set for the WebProxy
class, including the user name, password, domain, and authentication type
for the credentials.

HTH,
Nicole

> Hello Nicole,
>
[quoted text clipped - 36 lines]
>> >
>> > aknak at aksoto dot idps dot co dot uk

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.