[英]How to create Channel Factory
嗨,我正在嘗試從控制台應用程序中調用WCF服務,並返回以下代碼:
未處理的異常:System.InvalidOperationException:無法創建基礎通道工廠,因為沒有將綁定傳遞給ChannelFactory。
我的代碼:
EndpointAddress address = new EndpointAddress("http://xx.xx.xx.xx:xxxxxx/xxxx/FormulationService");
var servis = new ChannelFactory<IFormulasyonHost>().CreateChannel(address);
((IServiceChannel)servis).Open();
if (args[0].ToString() == "-update")
{
if (args[1].ToString() == "all")
{
servis.UpdateAll();
((IServiceChannel)servis).Close();
}
}
假設使用了基本綁定
var address = ...
var binding = new BasicHttpBinding();
var servis = new ChannelFactory<IFormulasyonHost>(binding,address)
.CreateChannel();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.