1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| Type TypeServWCF = typeof(ServiceWCF);
Type TypeServIWCF = typeof(IServiceWCF);
using (myServiceHost = new ServiceHost(TypeServWCF, new Uri(baseAddress)))
{
// Check to see if the service host already has a ServiceMetadataBehavior
ServiceMetadataBehavior smb = myServiceHost.Description.Behaviors.Find<ServiceMetadataBehavior>();
// If not, add one
if (smb == null)
smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = false;
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
myServiceHost.Description.Name = "ComputerSpecs_Server_Bibli_WCF.ServiceWCF";
myServiceHost.Description.Behaviors.Add(smb);
myServiceHost.AddServiceEndpoint(TypeServWCF, new NetTcpBinding(), "");
myServiceHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexTcpBinding(), "mex");
myServiceHost.Open();
} |
Partager