Re: How to query n web services



Hi,

Nightfall wrote:
Dear friends,
let's say we have 10 "server-side" web service which return some kind
of data.

I'm using visual studio 2005 and I have a Project - the client -
where I added Web References to those 10 ws.
When I added web references, I wrote 10 different web references name.

So, i.e., I should write

Name01.Service service01 = new Name01.Service();
Name02.Service service02 = new Name02.Service();
Name03.Service service03 = new Name03.Service();
...
and then invoke service01.someMethod...

But let's say that I just have to query a subset of those 10 ws.
The subset is given by strings. (so that I have to invoke only those
ws whose names are specified in the following strings)

string s1 = "Name01";
string s4 = "Name04";
string s7 = "Name07";

I need some way to do

Name01.Service service01 = new Name01.Service();
Name04.Service service04 = new Name04.Service();
Name07.Service service07 = new Name07.Service();

which, certainly is not

s1.Service service01 = new s1.Service();

isn't it?

Thanx a lot for any hint.

bye!

Using Reflection, you can use a string to create an instance of an object and then invoke methods on that instance. Check Reflection on Google.

Note that Reflection is slow, so don't use it for performance-critical operations.

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
.



Relevant Pages

  • Re: How to query n web services
    ... When I added web references, I wrote 10 different web references name. ... and then invoke service01.someMethod... ... The subset is given by strings. ... Check Reflection on Google. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • How to query n web services
    ... I'm using visual studio 2005 and I have a Project - the client - ... When I added web references, I wrote 10 different web references name. ... and then invoke service01.someMethod... ... The subset is given by strings. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: [PHP] Object to array conversion oddity
    ... I can see that there might be some reason for converting the object with additional information in some circumstances (much like serialization to strings does), but here we're only talking about casting, which should be a 'best-fit' data matter. ... here we have undocumented behaviour justified by yet more undocumented behaviour! ... I think trying to preserve this information is entirely pointless - it's not as if you can cast back from an array to an object, and I can't think of any circumstances in which it is preferable to using reflection. ...
    (php.general)
  • Re: How can I detect the presense of an optional assembly and call a method within it?
    ... Basically you will need to use Reflection. ... allows you to dynamically create instances at runtime and invoke method. ... > 1- Read a configuration file where the client provides the assembly name ... > (DLL) and the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Getting Method objects without reflection
    ... methods and fields can be obfuscated while strings cannot. ... > So being able to call getName() on a Field has a big security advantage ... > over using raw reflection. ... I don't think that it would permit more thorough obfuscation that is currently ...
    (comp.lang.java.programmer)