2

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.

4

3 回答 3

1

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.

于 2009-01-06T18:10:57.587 回答
0

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

于 2009-01-06T18:09:04.313 回答
0

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.

于 2009-01-06T18:25:21.520 回答