Question

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 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.

Was it helpful?

Solution

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

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top