0

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.

Daniel Bişar
  • 2,663
  • 7
  • 32
  • 54
  • The `ServiceHost` doesn't implement any service contracts - the service class that the service host hosts - that's the class that implements service contracts – marc_s Jan 20 '12 at 14:14
  • Do you want to query the list of contracts from the client or from within the service hosting code? – Richard Blewett Jan 20 '12 at 14:18
  • I edit the question. I would like to get at the client the list of contract interfaces implemented by the server. I hope my formulation is now more clear... Else just comment – Daniel Bişar Jan 20 '12 at 14:46

4 Answers4

2

Take a look at WCF Discovery.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
0

This is not supported by WCF.

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

Roy Dictus
  • 32,551
  • 8
  • 60
  • 76
0

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.

Brook
  • 5,949
  • 3
  • 31
  • 45
0

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.

Peladao
  • 4,036
  • 1
  • 23
  • 43