473,395 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Proxy - Access Denied

Hi,
I've got strange error on computer which is accessing web-service thrugh proxy.

Scenario 1
----------
- the web-service does not require authentication (Anonymous access is allowed)
- client works fine

Scenario 2
----------
- web-service requires authentication (Intergrated Win. auth / Basic auth.)
- client fails on 401 : Access Denied even though correct credentials are supplied

Scenario 3
----------
- same as Scenario 2, but from client who's not using proxy
- client works fine

It seems as if just the combination of proxy & site which requires authentication was creating the problem.

I tried everything, wirh with default proxy (System.Net.GetDefaultProxy), create my own, pass credentials using just NetworkCredentials, using CredentialsCache... Nothing helped so far.

This is sample code:
// --- my web-service proxy

ProbePX wspx = new ProbePX();

// --- setting up the proxy

wspx.Proxy = System.Net.WebProxy.GetDefaultProxy();

wspx.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;

//wspx.Proxy.Credentials = new System.Net.NetworkCredential( txtPxUser.Text, txtPxPwd.Text, txtPxDomain.Text );

// --- setting up the credentials for the web-service

System.Net.CredentialCache cache = new System.Net.CredentialCache();

cache.Add(new Uri(wspx.Url), "Negotiate", new System.Net.NetworkCredential( txtAuthUser.Text, txtAuthPwd.Text, txtAuthDomain.Text ));

wspx.Credentials = cache;

--
Vlad
Nov 21 '05 #1
1 10451
Ok, I finally figured it out. Seems like the credentials have to be specified not only for the web-service, but also for the proxy (i.e. they have to "share" them). I think it's a bug in WSE2, but this fixes it...

// create sample web-service instance

SampleWS ws = new SampleWS();

// get default proxy and assign it to the WebService. Alternatively, you can replace this with manual WebProxy creation.

ws.Proxy = System.Net.WebProxy.GetDefaultProxy();

// create credentials cache - it will hold both, the WebProxy credentials and the WebService credentials too

System.Net.CredentialCache cache = new System.Net.CredentialCache();

// add default credentials for Proxy (notice the authType = 'Kerberos' !) Other types are 'Basic', 'Digest', 'Negotiate', 'NTLM'

cache.Add(((WebProxy) this.Proxy).Address, "Kerberos", (System.Net.NetworkCredential) System.Net.CredentialCache.DefaultCredentials);

// add credentials needed for the WebService (fill your own values here)

cache.Add(new Uri("http://www.exis.cz"), "Basic", new System.Net.NetworkCredential("myuser", "mypwd", "mydomain"));

// assign the credentials to both, the Proxy and WebService too

ws.Proxy.Credentials = cache;

ws.Credentials = cache;

// now you can call the WebService method

ws.MyMethod();

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tony | last post by:
Hi, I have a VB program which will access (using CallByName function) the JavaScript in a page using IE6. It works fine if no proxy is set in IE6 (Tools -> Internet Options -> Connections -> LAN...
4
by: Dave Langley | last post by:
I'm using VC++ to write an VC++ unmanaged client to communicate to a C#.NET web service. I have the proxy class for the unmanaged client and it uses the default CSoapSocketClientT<> template as...
0
by: George | last post by:
Hello, I'm running an ASPX application "WebApplication1" which consumes a web service (service1.asmx) hosted on a machine with IP (128.1.7.x) . The web service is located in the intranet. The...
1
by: John | last post by:
Hi I am trying to call a web service from behind a MS ISA Server on a sbs2003 machine. The calling program is coming up with this error; The request failed with HTTP status 407: Proxy...
0
by: lpinho | last post by:
Hi There, I've generated a C# file from a wsdl file using wsdl.exe utility. Then I created a console application and made a call to the method generated, first I got the error: "The request...
0
by: Jim_H | last post by:
I am trying to set the Credentials property of my web service proxy and I cannot seem to get anything to work. I am calling a remote asmx page from an aspx and they each reside on different web...
12
by: Griff | last post by:
I have a two tier system. I've created a COM+ package on the data tier (Win2003) and exported it as a COM+proxy (v 1.0 compliant) and installed this onto a Win2000 web application. I've...
4
by: Boni | last post by:
I want consuming a webserivce trough a proxy. I use this code. myService s = new myService (); System.Net.WebProxy proxyObject = new System.Net.WebProxy("http://proxyhost:8080"); s.Proxy =...
1
by: khubieb | last post by:
Situation: We have to connect to a 3rd party XML Web Service outside our LAN by adding a WCF Service Reference to a simple console application Problem: When attempting to invoke any of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.