Web services and web proxy issue

2 views
Skip to first unread message

Britt

unread,
Nov 9, 2009, 5:47:44 PM11/9/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
I have a windows application that connects to a web service that we've
just rolled out to a new client. The application is throwing a 401
access denied error when the application is trying to connect to the
web service.

Some things I've tried:

I tested that the user ID and password are correct by installing the
application on a few of our home computers. All of them succeed with
the right credentials entered and fail properly with bad login
information (straight up home installs with no VPNs or anything).

I have verified the login and password are entered correctly by the
client (I had the app dump the text for me to verify).

I have verified that the client can point IE to the web service's URL,
which properly authenticates with the login and password.

I wouldn't necessarily think that a 401 error would result from this,
but I did notice that their browsers have proxy autodetect turned
on.

I did some research to see if that was something I would have to
implement. When I looked at assigning a proxy object to the Proxy
property of the web service generated code, I get a deprecated message
that says I should just use the proxy object that is automatically
provided. Does that mean that the framework and the generated web
service wrapper code from Visual Studio is smart enough to query the
registry and detect web proxies?

I created a form to dump out some of the settings as they exist on
that machine and it appears that the Proxy property of the web service
instance is null.

Does anyone think the proxy is my problem, or should I keep looking?
If it is the proxy, should the framework handle this out of the box or
is this custom implementation?
Is it possible that the proxy is stripping my credentials from the
soap request and is there an obvious difference between my app
creating an authenticated connection to the web service URL and the
client's web browser making an authenticated (challenge/response)
connection to the exact same URL?

Thank you all!

Raghupathi Kamuni

unread,
Nov 10, 2009, 3:38:59 AM11/10/09
to dotnetde...@googlegroups.com

By default, the Web service client proxy does not inherit the credentials of the security context where the Web service client application is running.

To resolve this problem, you must use the Credentials property of the Web service client proxy to set the security credentials for Web service client authentication.

Look in here for resolution details

Britton Johnson

unread,
Nov 10, 2009, 11:56:14 AM11/10/09
to dotnetde...@googlegroups.com
Thank you for the quick response!

I actually am setting the NetworkCredential in my code to use the user name and password as it is entered into my configuration screen.  I'm confident in the implementation of this as it works in every environment I've tested it in except for this one client (good passwords/users work, bad ones don't).

The confusion I think is in the term proxy.  I'm not referring to the generated web service proxy code that is generated by visual studio when I create a web reference.  I am referring to an actual HTTP web proxy on this client's network/firewall.  This clash in terms has made it hard to google for solutions so far.

My question can probably be summed up as does the SoapHttpClientProtocol class know to check for a WebProxy if the local machine has one configured?  Do I need to implement my own configuration for WebProxy detection or is this handled by the .net framework intrinsically?  I've seen a few examples of creating WebProxy objects and assigning them to the SoapHttpClientProtocol.Proxy property of my service, but the hover text in VS tells me this deprecated and I should use the default proxy provided (null in my case).

Thank you very much!

Raghupathi Kamuni

unread,
Nov 11, 2009, 1:33:13 AM11/11/09
to dotnetde...@googlegroups.com
To specify the proxy server, set the Machine.config or Web.config file settings as follows:
 
<configuration>
   <system.net>
      <defaultProxy>
         <proxy
            usesystemdefault = "false"
            proxyaddress="http://proxyserver"
            bypassonlocal="true"
         />
      </defaultProxy>
   </system.net>
</configuration>
 
Also try this,
 
Dim myService As New MyWebService
Dim proxyObject As New System.Net.WebProxy("http://proxyserver:80/", True)
myService.Proxy = proxyObject

myService.MyMethod()
 

Please refer to the below links as well
Reply all
Reply to author
Forward
0 new messages