all groups > dotnet web services > april 2005 >
You're in the

dotnet web services

group:

Programmatically add / remove web reference in C#



Programmatically add / remove web reference in C# TC
4/22/2005 3:13:37 PM
dotnet web services: Hello All,

I have winforms app that accesses a webservice and the WSDL is referenced
dynamically.

I was wondering 2 things:

First, if one parses the .config file and changes the URL pointing to the
WSDL, I take it that these changes would not take effect until the user
closes and restarts the app, correct?

The above said, is there a way to programmtically upload the newly parsed
..config file, or, better yet, is there a way to programmatically remove the
old reference and add a new reference pointing to the new WSDL?

Thanks & Regards,

TC


Re: Programmatically add / remove web reference in C# Keenan Newton
4/23/2005 7:08:20 AM
Well I am assuming your trying to change the URL where your web service
is found at runtime. This is very easy to do by changing the URL
property on the generated web service proxy.

However, if your intent is to generate a new web service proxy on the
fly from a wsdl file. Then you would have to create your very own class
generator to interupt the wsdl, and generate a class file, compile that
file, and use refelction to call it up. To say the least not an easy
task.
Re: Programmatically add / remove web reference in C# Sami Vaaraniemi
4/23/2005 11:50:39 AM

[quoted text, click to view]

I take it you mean the Web Reference is dynamic, right? If so, then you are
correct, changes to the config file will not take effect until the app is
restarted. That's because the config file loader loads the .config file only
at first time you ask for a setting. After that all requests come from an
in-memory cache.

[quoted text, click to view]

If you just want to change the url of the Web Service proxy, assign to the
Url property of the proxy object. This works assuming the Web Service
interface (i.e., the WSDL) is the same.

Regards,
Sami

Re: Programmatically add / remove web reference in C# TC
4/23/2005 1:03:36 PM
Hey Guys,

Yep. I now see the 'URL' property of the proxy object.

Thanks a bunch! It's exactly what I was looking for.

Regards,

TC

[quoted text, click to view]

AddThis Social Bookmark Button