Question

Is there any possibility as a client to get a list of contracts a WCF host exposes?

I would like to query a service and to ask what interfaces it implements.

Was it helpful?

Solution

Take a look at WCF Discovery.

OTHER TIPS

This is not supported by WCF.

You can query the service's WSDL contract, but not the WCF contracts or any Interfaces.

The best you will be able to do is to see what is exposed, and assume that is the interface. You will not be able to see all the different interfaces that the class implements. For example, if you had a service which implemented IFooService, and IDisposable, with IFooService exposed through WCF, you would be able to see all the methods of IFooService from the client.

The WCF Test utility will take a given wsdl and generate a client for it, looking at the source for that might be a good starting point. (you'll have to decompile it with something like reflector)

Another idea, You could programatically invoke svcutil to generate a client for a given wsdl, then invoke msbuild to compile it, and use reflection to load the output assembly. It would be a fairly large amount of work, and I'm not sure what you would do with it. You would have to build a fairly complex UI to inspect and invoke the client.

In general (web) services are being described by XML-based protocols such as WSDL. This is used both for discovery of the services and for describing their operations. Also UDDI is sometimes used but mostly for Enterprise Application Integration (internal use).

So you can have your WCF service produce WSDL information and let your client query that.

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