Could not find default endpoint element that references contract :connect to WCF endpoint through Powershell cmdlet Could not find default endpoint element that references contract :connect to WCF endpoint through Powershell cmdlet powershell powershell

Could not find default endpoint element that references contract :connect to WCF endpoint through Powershell cmdlet


have got this to work: here is a clean solution:

internal static class ServiceClass{    internal static Object GetWCFSvc(string siteUrl)    {        Uri serviceUri = new Uri(siteUrl);        EndpointAddress endpointAddress = new EndpointAddress(serviceUri);        //Create the binding here        Binding binding = BindingFactory.CreateInstance();        ServiceClient client = new ServiceClient(binding, endpointAddress);                    return client;    }}internal static class BindingFactory{    internal static Binding CreateInstance()    {        BasicHttpBinding binding = new BasicHttpBinding();        binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;        binding.UseDefaultWebProxy = true;        return binding;    }}


create configuration file with endpoints in startup project


When you're running the code in your cmdlet assembly, the executing process is powershell.exe (in %windir%\system32\WindowsPowershell\v1.0 or %windir%\syswow64\WindowsPowershell\v1.0), so any System.ServiceModel configuration will be need to be defined in the powershell config file (powershell.exe.config).

I'm guessing this is probably not a practical option, so you'll probably need to configure your service client or channel factory manually rather than via the application configuration file.

See here for an example: http://msdn.microsoft.com/en-us/library/ms734681.aspx

Another option may be to use an Activation Configuration File: http://msdn.microsoft.com/en-us/library/ff361644.aspx

I'm not sure how well this will work for service configuration elements.