Link to WCF services without mex binding

I was wondering how a client project in Visual Studio can reference a WCF service that does not have a mex binding. Whenever I remove the default mex binding in any WCF service sample, client applications cannot find the service in auto-generated comments, it is recommended that the mex binding be removed in the production environment. Then how should client applications find the service and reference it?

+4
source share
2 answers

The mex endpoint is a necessary part of the WCF SOAP services. This is what enables client tools to reset WSDL and automatically generate proxy classes. As you indicate, without this, customers have no way to obtain information for using this service. If you want customers to be able to consume and find your service, you must leave it available when your service is in production.

0
source

If you have access to assemblies that contain types that define a service contract, operations, and data contracts, then you can simply create proxies on the fly using ChannelFactory. In this case, you will not need to receive any service metadata, since you already have access to all the information necessary to call the service.

for instance

// Create service proxy on the fly
var factory = new ChannelFactory<IMyServiceContract>("NameOfMyClientEndpointInConfigFile");
var proxy = factory.CreateChannel();

// Create data contract
var requestDataContract = new MyDataContract();

// Call service operation.
var responseDataContract = proxy.MyServiceOperation(requestDataContract);

, , .

+10

All Articles