Groups | Blog | Home
all groups > dotnet web services > february 2006 >

dotnet web services : Webservices called from behind proxy server fails



sameer
2/10/2006 11:43:21 AM
..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 of
them is ISA ... if i a not wrong), if yes how?

Tony
2/11/2006 1:37:15 AM
Yes, you can but you have provide your proxy server credentials to your web
service on the client side as in the following example.

The example assumes you have created your web service object (names
..WebService in this example):

WebProxy oProxy = new WebProxy(string.Format("{0}:{1}", sProxyServer,
nProxyPort), true);

oProxy.Credentials = new NetworkCredential(sProxyUsername, sProxyPassword);

oWebService.Proxy = oProxy;
oWebService.Discover();

Hope this helps,
Tony


[quoted text, click to view]

sameer
2/12/2006 10:00:28 AM
Tony,

since some of the clients of this application does not use proxy server, how
can i and where exactly in the code should i make changes so that depending
on a setting in the configuration file, it should set up a proxy object. When
i say "where can i", i mean to ask is there any call in the reference.vb file
where i can override a method which is called every time this webserivce
object is initialized so that once I feed the settings to the webservice,
code in no other places needs to be changed.

Also can you point me to a resource on any website which describes this in
detail.
thanks

[quoted text, click to view]
Tony
2/12/2006 11:11:45 PM
I provide a configuration UI in my application where the user is allowed to
specify if they need to use a proxy server, and if so, they can provide the
proxy server, port, username and password (sometimes username and password
are options) and I write this info to a config file to remember them for the
next time.

I have a method that I use to get a the webservice instance and that method
attaches the proxy server stuff as indicated in my prev message.

Tony


[quoted text, click to view]

sameer
2/13/2006 7:36:27 AM
tony thanks for you reply, i now know that i can use the code that you
mentioend to involke webservices from behing a proxy server. Another question
which was part of the previous one is:
my application has a lot of places where it makes the webservice calls, and
the application is pretty huge. also if at all there is a proxy server then
my clients would let me know in advance and i could specify this value in the
application before they start using. So my question is , is there place in
the reference.VB file of the webservice where if i override a function and
specify the proxy Ip and port just ONES per webserivce then evertime this
webserice is initialized , it gets the proxy IP and port and i dont have to
make this change 100s of times all over the application.

thanks

[quoted text, click to view]
Tony
2/13/2006 9:03:49 PM
I wouldn't think you would want to hard code it into your application.
What I would do is create a factory class - a static class with a static
method that would setup the web service object with the needed proxy info
and return it. You would then change the 100 or so places to call the static
method instead of creating the object directly. This would enable you from
this point on to make changes in one place without having to change it
everywhere.

Another option is to add the info to a configuration file. I'm sure that it
probably supports specification of the proxy information, but I don't use
config files so I can't tell you how to do this.

Tony

[quoted text, click to view]

sameer
2/14/2006 6:13:09 AM
Tony thanks for your suggestions,
talking about configuration file, i am trying to add it to the config file
so that it picks up the default values from the configuration file but it
does not seem to work. Here is the code that i added to the config file, let
me know if you have any suggestions.

<system.net>
<defaultProxy>
<proxy
proxyaddress = "http://proxyserver:80"
/>
</defaultProxy>
</system.net>

thanks


[quoted text, click to view]
AddThis Social Bookmark Button