using System; using System.ServiceModel.Description; namespace ReadServiceDescription { class Program { static void Main(string[] args) { try { string svcPath = @"C:\Service1.svc"; ServiceDescription svcDescription = ServiceDescription.Read(svcPath); Console.WriteLine($"Service Name: {svcDescription.Name}"); Console.WriteLine($"Service Namespace: {svcDescription.Namespace}"); Console.WriteLine($"Service Endpoints: {svcDescription.Endpoints.Count}"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } } } }
using System; using System.ServiceModel.Description; namespace ModifyServiceDescription { class Program { static void Main(string[] args) { try { string svcPath = @"C:\Service1.svc"; ServiceDescription svcDescription = ServiceDescription.Read(svcPath); string endpointAddress = "http://localhost/MyService"; string bindingName = "basicHttpBinding"; string contractName = "IMyService"; // Add new endpoint svcDescription.Endpoints.Add(new ServiceEndpoint( ContractDescription.GetContract(Type.GetType(contractName)), new BasicHttpBinding(bindingName), new EndpointAddress(endpointAddress) )); // Remove existing endpoint svcDescription.Endpoints.RemoveAt(0); svcDescription.Write(svcPath); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } } } }Package Library: The System.ServiceModel.Description namespace is part of the .NET Framework Class Library. There is no additional package or library required to use ServiceDescription.