What is Mex End point?
The Metadata Exchange Endpoint (MEX) is a special endpoint in WCF that exposes metadata used to describe a service.
In previous releases of WCF, the MEX was implicitly added to all services. However, due to security reasons, it is no longer exposed by default as of RC1.
Without the MEX, we will not be able to use svcutil.exe to automatically generate a proxy class.
Depending upon our binding, the corresponding MEX binding will vary. There is support for HTTP, TCP, and Named Pipes.
Http Get v/s new end point
If we have the mex end point, we are not required to enable HttpGet.
SvcUtil will still be able to access the MEX without it.
However, it is useful if we want to view the WSDL from a browser by going to the address of the service. We cannot do so without enabling the HttpGet.
Adding via code
ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
behavior.HttpGetEnabled = true;
host.AddServiceEndpoint( typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(),“http://localhost/MyService/mex/”);
Adding via config
MEX and WSDL are two different schemes to tell potential clients about the structure of your service.
So we can choose to either make the service contracts public as “metadata exchance format” (MEX) or in the “web service description language” (WSDL) — the latter being accessible via HTTP(s).
The httpGetEnabled configuration lets us set an http endpoint that would allow a non-mex proxy to be generated using WSDL, such as a legacy .NET webservice proxy.
There’re 2 ways to expose metadata.
One with MEX endpoint and one with <serviceMetadata httpGetEnabled=”true” />.
The first one will expose metadata using WS-MetadataExchange and second one will use WSDL
Service metadata exposes a wsdl file usually through http or https get urls that we can’t really configure (say for security limitations).
MEX endpoints expose metadata over configurable endpoints, and can use different types of transports, such as TCP or HTTP, and different types of security mechanisms.
So MEX are more configurable, while WSDL is more interoperable with older versions of clients and non-.net clients that work with WSDLs.
Excellent articles, which we can refer to increase our understanding.