473,320 Members | 2,092 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,320 software developers and data experts.

.Net 2.0 issue with HttpWebRequest/Proxy breaking WebService

Our WebDev team seems to have found a problem that exposes a bug in .NET 2.0.
This problem can be shown when trying to access a WebService using SSL and
through a proxy server after using the HttpWebRequest object.

Under normal circumstances I am able to use the webservice without any
problems. But after using an HttpWebRequest object to make a call to a
website
all subsequent attempts to use the WebService will fail with a 401
Unauthorized error. This problem appears to be directly related to when the
Client's Internet Explorer settings are configured to use a Proxy server for
http requests. If the settings for the proxy server are disabled everything
works as expected.
Server Configuration:
Windows 2003 Server Service Pack 2
IIS 6.0, Using SSL Port 443, Anonymous access disabled, using Integrated
Windows Authentication
..Net 2.0

Client:
Windows XP Service Pack 2
..Net 2.0
IE 7, configured to use a proxy server

Below is sample code that can be used to reproduce the problem with a CSharp
Windows Application.
//PreRequisites: Webservice must be using SSL (https) and does
not allow anoymous connections(using Integrated Windows Authentication)
//Client's IE Settings requires http requests to go through a
Proxy server. (If proxy is not enabled the below scenario works properly)

//Create Web Service Object
YourWebService webServiceObject = new YourWebService();

//Set Credentials for Web Service
webServiceObject.Credentials = new
System.Net.NetworkCredential("username", "password", "domain");

//Call a method from the Web Service. This Call works without
any errors.
object returnObject = webServiceObject.anyWebServiceMethod();

//Create HttpWebRequest Object to any non secure web page
HttpWebRequest webRequestObject =
(HttpWebRequest)HttpWebRequest.Create("http://www.microsoft.com/");
//Call GetResponse
HttpWebResponse testRes =
(HttpWebResponse)webRequestObject.GetResponse();

//Call the same method from the Same Web Service Object. This
call will fail.
returnObject = webServiceObject.anyWebServiceMethod();

//The Above call will fail with the following error
//"The request failed with HTTP status 401: Unauthorized."

//Sample Stack Trace of the error
//at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
//at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
//at Proxy.[snip].Service.ValidateAccount(String email, String
password, OperatingSystemInfo osInfo) in
C:\Projects\Sandbox\CSharp\ProxyTest\Web References\[snip]\Reference.cs:line
336
//at Proxy.Form1.Form1_Load(Object sender, EventArgs e) in
C:\Projects\Sandbox\CSharp\ProxyTest\Form1.cs:line 38
//at System.Windows.Forms.Form.OnLoad(EventArgs e)
//at System.Windows.Forms.Form.OnCreateControl()
//at System.Windows.Forms.Control.CreateControl(Boolean
fIgnoreVisible)
//at System.Windows.Forms.Control.CreateControl()
//at System.Windows.Forms.Control.WmShowWindow(Message& m)
//at System.Windows.Forms.Control.WndProc(Message& m)
//at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
//at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
//at System.Windows.Forms.Form.WmShowWindow(Message& m)
//at System.Windows.Forms.Form.WndProc(Message& m)
//at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
//at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
//at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
//at System.Windows.Forms.SafeNativeMethods.ShowWindow( HandleRef
hWnd, Int32 nCmdShow)
//at System.Windows.Forms.Control.SetVisibleCore(Boolea n value)
//at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
//at System.Windows.Forms.Control.set_Visible(Boolean value)
//at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
//at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason,
ApplicationContext context)
//at System.Windows.Forms.Application.Run(Form mainForm)
//at Proxy.Program.Main() in
C:\Projects\Sandbox\CSharp\Proxy\Proxy\Program.cs: line 17
//at System.AppDomain.nExecuteAssembly(Assembly assembly,
String[] args)
//at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
//at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
//at System.Threading.ThreadHelper.ThreadStart_Context( Object
state)
//at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
//at System.Threading.ThreadHelper.ThreadStart()

Please do not hesitate to contact me if you require any additional
information or if you have a solution.
--
Larry Kuperman
Global Account Manager
Stardock- A Microsoft Gold Partner
Jun 27 '08 #1
2 3456
iy looks like the proxy requires authenication (pretty much standard). you
should supply proxy credentials to the webrequest.

-- bruce (sqlwork.com)
"LarryKuperman" wrote:
Our WebDev team seems to have found a problem that exposes a bug in .NET 2.0.
This problem can be shown when trying to access a WebService using SSL and
through a proxy server after using the HttpWebRequest object.

Under normal circumstances I am able to use the webservice without any
problems. But after using an HttpWebRequest object to make a call to a
website
all subsequent attempts to use the WebService will fail with a 401
Unauthorized error. This problem appears to be directly related to when the
Client's Internet Explorer settings are configured to use a Proxy server for
http requests. If the settings for the proxy server are disabled everything
works as expected.
Server Configuration:
Windows 2003 Server Service Pack 2
IIS 6.0, Using SSL Port 443, Anonymous access disabled, using Integrated
Windows Authentication
.Net 2.0

Client:
Windows XP Service Pack 2
.Net 2.0
IE 7, configured to use a proxy server

Below is sample code that can be used to reproduce the problem with a CSharp
Windows Application.
//PreRequisites: Webservice must be using SSL (https) and does
not allow anoymous connections(using Integrated Windows Authentication)
//Client's IE Settings requires http requests to go through a
Proxy server. (If proxy is not enabled the below scenario works properly)

//Create Web Service Object
YourWebService webServiceObject = new YourWebService();

//Set Credentials for Web Service
webServiceObject.Credentials = new
System.Net.NetworkCredential("username", "password", "domain");

//Call a method from the Web Service. This Call works without
any errors.
object returnObject = webServiceObject.anyWebServiceMethod();

//Create HttpWebRequest Object to any non secure web page
HttpWebRequest webRequestObject =
(HttpWebRequest)HttpWebRequest.Create("http://www.microsoft.com/");
//Call GetResponse
HttpWebResponse testRes =
(HttpWebResponse)webRequestObject.GetResponse();

//Call the same method from the Same Web Service Object. This
call will fail.
returnObject = webServiceObject.anyWebServiceMethod();

//The Above call will fail with the following error
//"The request failed with HTTP status 401: Unauthorized."

//Sample Stack Trace of the error
//at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
//at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
//at Proxy.[snip].Service.ValidateAccount(String email, String
password, OperatingSystemInfo osInfo) in
C:\Projects\Sandbox\CSharp\ProxyTest\Web References\[snip]\Reference.cs:line
336
//at Proxy.Form1.Form1_Load(Object sender, EventArgs e) in
C:\Projects\Sandbox\CSharp\ProxyTest\Form1.cs:line 38
//at System.Windows.Forms.Form.OnLoad(EventArgs e)
//at System.Windows.Forms.Form.OnCreateControl()
//at System.Windows.Forms.Control.CreateControl(Boolean
fIgnoreVisible)
//at System.Windows.Forms.Control.CreateControl()
//at System.Windows.Forms.Control.WmShowWindow(Message& m)
//at System.Windows.Forms.Control.WndProc(Message& m)
//at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
//at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
//at System.Windows.Forms.Form.WmShowWindow(Message& m)
//at System.Windows.Forms.Form.WndProc(Message& m)
//at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
//at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
//at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
//at System.Windows.Forms.SafeNativeMethods.ShowWindow( HandleRef
hWnd, Int32 nCmdShow)
//at System.Windows.Forms.Control.SetVisibleCore(Boolea n value)
//at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
//at System.Windows.Forms.Control.set_Visible(Boolean value)
//at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
//at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason,
ApplicationContext context)
//at System.Windows.Forms.Application.Run(Form mainForm)
//at Proxy.Program.Main() in
C:\Projects\Sandbox\CSharp\Proxy\Proxy\Program.cs: line 17
//at System.AppDomain.nExecuteAssembly(Assembly assembly,
String[] args)
//at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
//at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
//at System.Threading.ThreadHelper.ThreadStart_Context( Object
state)
//at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
//at System.Threading.ThreadHelper.ThreadStart()

Please do not hesitate to contact me if you require any additional
information or if you have a solution.
--
Larry Kuperman
Global Account Manager
Stardock- A Microsoft Gold Partner
Jun 27 '08 #2
Hi, Bruce and thanks for your reply. We are using this as a workaround, but
it doesn't really solve the issue.

Under normal circumstances we are able to use the webservice without any
problems. But after using an HttpWebRequest object to make a call to a
website
all subsequent attempts to use the WebService will fail with a 401
Unauthorized error.

So, initially the .Net framework is setting the proxy for you. But after
using a WebRequest the Proxy settings for the WebService calls get removed
and thus need to be set manually.

We are still seeking a solution.
--
Larry Kuperman
Global Account Manager
Stardock- A Microsoft Gold Partner
"bruce barker" wrote:
iy looks like the proxy requires authenication (pretty much standard). you
should supply proxy credentials to the webrequest.

-- bruce (sqlwork.com)
"LarryKuperman" wrote:
Our WebDev team seems to have found a problem that exposes a bug in .NET 2.0.
This problem can be shown when trying to access a WebService using SSL and
through a proxy server after using the HttpWebRequest object.

Under normal circumstances I am able to use the webservice without any
problems. But after using an HttpWebRequest object to make a call to a
website
all subsequent attempts to use the WebService will fail with a 401
Unauthorized error. This problem appears to be directly related to when the
Client's Internet Explorer settings are configured to use a Proxy server for
http requests. If the settings for the proxy server are disabled everything
works as expected.
Server Configuration:
Windows 2003 Server Service Pack 2
IIS 6.0, Using SSL Port 443, Anonymous access disabled, using Integrated
Windows Authentication
.Net 2.0

Client:
Windows XP Service Pack 2
.Net 2.0
IE 7, configured to use a proxy server

Below is sample code that can be used to reproduce the problem with a CSharp
Windows Application.
//PreRequisites: Webservice must be using SSL (https) and does
not allow anoymous connections(using Integrated Windows Authentication)
//Client's IE Settings requires http requests to go through a
Proxy server. (If proxy is not enabled the below scenario works properly)

//Create Web Service Object
YourWebService webServiceObject = new YourWebService();

//Set Credentials for Web Service
webServiceObject.Credentials = new
System.Net.NetworkCredential("username", "password", "domain");

//Call a method from the Web Service. This Call works without
any errors.
object returnObject = webServiceObject.anyWebServiceMethod();

//Create HttpWebRequest Object to any non secure web page
HttpWebRequest webRequestObject =
(HttpWebRequest)HttpWebRequest.Create("http://www.microsoft.com/");
//Call GetResponse
HttpWebResponse testRes =
(HttpWebResponse)webRequestObject.GetResponse();

//Call the same method from the Same Web Service Object. This
call will fail.
returnObject = webServiceObject.anyWebServiceMethod();

//The Above call will fail with the following error
//"The request failed with HTTP status 401: Unauthorized."

//Sample Stack Trace of the error
//at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
//at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
//at Proxy.[snip].Service.ValidateAccount(String email, String
password, OperatingSystemInfo osInfo) in
C:\Projects\Sandbox\CSharp\ProxyTest\Web References\[snip]\Reference.cs:line
336
//at Proxy.Form1.Form1_Load(Object sender, EventArgs e) in
C:\Projects\Sandbox\CSharp\ProxyTest\Form1.cs:line 38
//at System.Windows.Forms.Form.OnLoad(EventArgs e)
//at System.Windows.Forms.Form.OnCreateControl()
//at System.Windows.Forms.Control.CreateControl(Boolean
fIgnoreVisible)
//at System.Windows.Forms.Control.CreateControl()
//at System.Windows.Forms.Control.WmShowWindow(Message& m)
//at System.Windows.Forms.Control.WndProc(Message& m)
//at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
//at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
//at System.Windows.Forms.Form.WmShowWindow(Message& m)
//at System.Windows.Forms.Form.WndProc(Message& m)
//at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
//at
System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
//at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
//at System.Windows.Forms.SafeNativeMethods.ShowWindow( HandleRef
hWnd, Int32 nCmdShow)
//at System.Windows.Forms.Control.SetVisibleCore(Boolea n value)
//at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
//at System.Windows.Forms.Control.set_Visible(Boolean value)
//at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
//at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason,
ApplicationContext context)
//at System.Windows.Forms.Application.Run(Form mainForm)
//at Proxy.Program.Main() in
C:\Projects\Sandbox\CSharp\Proxy\Proxy\Program.cs: line 17
//at System.AppDomain.nExecuteAssembly(Assembly assembly,
String[] args)
//at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
//at
Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
//at System.Threading.ThreadHelper.ThreadStart_Context( Object
state)
//at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
//at System.Threading.ThreadHelper.ThreadStart()

Please do not hesitate to contact me if you require any additional
information or if you have a solution.
--
Larry Kuperman
Global Account Manager
Stardock- A Microsoft Gold Partner
Jun 27 '08 #3

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

Similar topics

3
by: bd-chan | last post by:
I'm trying to log in to a secured web site automatically using c#. To do this I have go through a proxy server, and use SSL, and log in to the secure site with another user name and password...
1
by: Imran Aziz | last post by:
Hello All, I am using HttpWebRequest to fetch webpages in my ASP.net C# application. The request works fine without the proxy, but on using the code from within a network that uses proxy the...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
6
by: sameer | last post by:
..NET Framework 1.1 VS2003 Application is making webservice calls from behind a proxy server and then freezes and dies. Questoin is can i use webservice over proxy server( i guess another name...
2
by: hharry | last post by:
hello all, trying to consume a simple web service using httpwebrequest instead of generating a proxy class. code for simple web service: Imports System.Web.Services ...
0
by: dan kisting | last post by:
Hello, I am writing a c# application which connects to web services through a Proxy Server. I am running a local Proxy Host to simulate what the user is seeing, and his problem is he is getting...
0
by: =?Utf-8?B?TGFycnlLdXBlcm1hbg==?= | last post by:
Our WebDev team is experiencing a problem when trying to access a WebService using SSL and through a proxy server after using the HttpWebRequest object. Under normal circumstances we are able to...
2
by: =?Utf-8?B?TGVuc3Rlcg==?= | last post by:
A C# (.NET 2) application which uses the System.Net.HttpWebRequest object to request a resource over HTTPS is failing following the installation of a new proxy server on our internal network with...
2
by: | last post by:
Hi all, I have an asp.net 2.0 website that accesses a locally hosted web service. This works fine on servers that are connected to our network. However, I am having a problem with a laptop...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.