在网上有很多动态调用webservice的代码,可惜就是没有找到调用wcf的,有哪位高手写过,或用过,请贴出来分享一下谢谢
解决方案 »
- 好的asp.net MVC框架 源代码
- ExecuteReader: CommandText 属性尚未初始化
- C# 中写文本文件的问题
- DataGridViewComboBoxColumn如何引发事件啊?
- 无后缀URL的实现方法,谁知道告诉我一下,谢谢..
- 请教DATAGRID中的模版链中添加CHECKBOX控件的控制问题?
- 如何实现把一个结构体变量中存储的所有数据作为一个整体存储到一个byte数组中啊?
- DataGridViewImageCell 自适应问题
- 请教html页面form对象的action属性用法????
- 關于簡繁體顯示問題﹐請指教
- c#.net无边框窗口的拖动!
- word2007
楼主可以看一下
兄弟 ChannelFactory不行啊。错误提示: 传递给通用 ChannelFactory 类的类型参数必须是接口类型。
代码如下:public static object ExecuteMethod<T>(string pUrl,string pMethodName, params object[] pParams)
{
EndpointAddress address = new EndpointAddress(pUrl);
Binding bindinginstance = null;
BasicHttpBinding ws = new BasicHttpBinding();
ws.MaxReceivedMessageSize = 65535000;
bindinginstance = ws;
using (ChannelFactory<T> channel = new ChannelFactory<T>(bindinginstance,address))
{
T instance = channel.CreateChannel();
using (instance as IDisposable)
{
try
{
Type type = typeof(T);
MethodInfo mi = type.GetMethod(pMethodName);
return mi.Invoke(instance, pParams);
}
catch (TimeoutException)
{
(instance as ICommunicationObject).Abort();
throw;
}
catch (CommunicationException)
{
(instance as ICommunicationObject).Abort();
throw;
}
catch (Exception vErr)
{
(instance as ICommunicationObject).Abort();
throw;
}
}
}
}
错误发生点:
using (ChannelFactory<T> channel = new ChannelFactory<T>(bindinginstance,address))