Exposing metadata using an HTTP endpoint
Instructions for exposing the metadata of a service which is configured to use the IBM MQ custom channel for WCF.
If the services metadata must be exposed (so that tools such as svcutil can access it directly from the running service rather than from an offline WSDL file for example) it must be done by exposing the services metadata with an HTTP endpoint. The following steps can be used to add this additional endpoint.
- Add the base address of where the metadata must be exposed to the ServiceHost, for example:
ServiceHost service = new ServiceHost(typeof(TestService), new Uri("http://localhost:8000/MyService"));
- Add the following code to the ServiceHost before the service is opened:
ServiceMetadataBehavior metadataBehavior = new ServiceMetadataBehavior(); metadataBehavior.HttpGetEnabled = true; service.Description.Behaviors.Add(metadataBehavior); service.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");