views:

1184

answers:

4

I'm trying to create an application that will let me execute a method specified at runtime on an arbitrary webservice (the URL of which I'll also provide at runtime). I've figured out how to use Type.InvokeMember to execute the arbitrary method, but how do I specify the web service to consume without creating a proxy class.

I found http://stackoverflow.com/questions/125627/how-do-i-call-a-webservice-without-a-web-reference which will helps me out if I already have the WSDL and only the URL will change, but I'd like to be able to call any webservice and fetch the result.

Thanks.

A: 

You should take a look at Dynamic Proxy for WCF (I'm sorry, but I can seem to find a link to it right now) - it's a library that lets you inspect services at runtime (if they publish their metadata), and also invoke methods (no need for metadata to do that).

Edit: actually, it seems that there is a project on Codeplex to do just that: SIF

mookid8000
+1  A: 

For WCF, you need to either have the proxy class, or the interface the service implements, so it's not likely you can do it via WCF (WCF is endlessly extensible, however, so there may be a way.

You can always just spin-up an HttpWebRequest object and make an "old-school" call to the service and parse the results yourself.

Robert C. Barth
A: 

You should be able to make your call just using WebRequest. You'll have to form the body of the message yourself, but that's not very hard.

A: 

Hi All,

SIF -- Seems to be great! We need the same. But i would like to ask to all experts suggestion for following scenario:

If i have loads of users[Say 1000] Users accessing the web service then what will be preferable to use "Static Proxy" OR "Dynamic Proxy"?

Any help/suggestions are appreciated!

Thanks,

KP