使用ref和out参数动态调用WCF服务

时间:2012-09-06 09:20:13

标签: wcf dynamic

我经历了以下引用,发现可以动态调用WCF服务。但是,我无法将接受参数的服务(方法)称为 ref out

Calling a WCF service from a client without having the contract interface

Dynamic Programming with WCF

Dynamically Invoking Web Services... With WCF This Time

Invoking WCF Service without adding a Service Reference.

有没有办法通过参考输出参数进行此类调用?

1 个答案:

答案 0 :(得分:2)

只要我知道合同,

Invoking WCF Service without adding a Service Reference.就会有效。所以我首先添加了Web引用,将生成的代理复制到实际项目中,然后删除了Web引用并简单地将方法称为

            BasicHttpBinding binding = new BasicHttpBinding();
            EndpointAddress epAddr = new EndpointAddress("http://192.168.0.233/GMS/GMSService.svc");
            GMSContract.IGMSService _interface = ChannelFactory<GMSContract.IGMSService>.CreateChannel(binding, epAddr);         
...
            bool r = _interface.MyGMSMethod(..., ref ..., out ..., out ...);