ServicesResourcesConferencesOur TeamWeblogsAboutContact
   

Subscriptions

Post Categories

Affiliations

Archives

WCF Base Address and Endpoints - what's the deal?

The other I ran into my friend Steve Maine on IM. We are currently building some really advanced stuff for WCF and I stumbled over a problem testing this deep-down-stuff with a simple test service. I just could not get the WSDL from my service as I was used to do so in Beta 1.

In the (pre-)Beta 2 bits of WCF the metadata for a service is only expose relative to its base address. This base address is defined via the baseAddresses parameter in the ServiceHost instance for hosting your service. Metadata in WCF words can mean that you just can browse to ?wsdl and get the WSDL together with the XSDs and optionally annotated policies. But it also means that you can get a WS-MetadataExchange (MEX)-compatible metadata negotiation feature for your services.

So, I like this new behavior in Beta 2 because rather than exposing the metadata relative to the actual endpoints it now is just available on the base address. If you now want to have MEX based on HTTP but you do just want to have non-HTTP enpoints, let's say one over MSMQ and another one over TCP, then you can easily achieve this. Just add an HTTP baseAddress but not add any HTTP endpoints - this gets you MEX for HTTP. Here is a small snippet:
 
// Provide base address for both HTTP and TCP
ServiceHost service = new ServiceHost(
  typeof(TestService),
  new Uri("
http://localhost/TestService"),
  new Uri("net.tcp://localhost:789/TestService"));
// Add one TCP-based endpoint
service.AddServiceEndpoint(
  typeof(ISimpleContract),
  new NetTcpBinding(),
  "tcp");

With this code fragment we now have a 'real' endpoint at TCP base address + "/tcp" and MEX at HTTP base address + "/mex", nice.

posted on Thursday, October 13, 2005 3:00 PM

Powered by Community Server, by Telligent Systems