Sah*_*wal 4 .net c# powershell cmdlets wcf
我创建了一个类库,它应该连接到我托管的WCF端点项目.客户端项目定义了应该与服务交互的命令行开关.
但是,我不断收到以下错误:
Could not find default endpoint element that references contract Service1.MyService in the
ServiceModel client configuration section. This might be because no configuration file was found
for your application, or because no endpoint element matching this contract could be found in the
client element.
Run Code Online (Sandbox Code Playgroud)
你知道问题可能是什么吗?
编辑 我所拥有的是定义cmdlet的单个类库.我使用.psd1文件到Import-Module,它使用生成的dll文件.
EDIT2 再一次,我没有一个引用我的库的项目.powershell调用定义的命令行开关,这些cmdlet应连接到WCF端点
谢谢
Sah*_*wal 10
有这个工作:这是一个干净的解决方案:
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;
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
12766 次 |
最近记录: |