任何用于频道管理的 WCF 客户端代理生成器? [英] Any WCF Client Proxy Generator for channels manage?

查看:32
本文介绍了任何用于频道管理的 WCF 客户端代理生成器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你会推荐哪个最好的 ChannelFactrory 包装器?我正在寻找一个简单的方法来处理频道创建过程并在需要时重新打开.

Which best ChannelFactrory wrapper would you recommand? I`m searching for a simple one that will handle the channel creation process and reopen in when needed.

推荐答案

ChannelFactory 的频道创建过程已经非常简单.

The channel creation process is already very simple with ChannelFactory.

我想如果您使用 svcutil 预先生成一个服务代理,它会为您生成一个包装器.但我不认为包装器使用起来会更简单.

I guess if you pre-generate a service proxy using svcutil that would generate a wrapper for you. But I don't think the wrapper would be any simpler to use.

// Create service proxy on the fly
var factory = new ChannelFactory<IMyServiceContract>("NameOfMyClientEndpointInConfigFile");
var proxy = factory.CreateChannel();

// Create data contract
var requestDataContract = new MyRequestType();

// Call service operation.
MyResponseType responseDataContract = proxy.MyServiceOperation(requestDataContract);

在上面的示例中,IMyServiceContract 是您的服务契约,而 MyRequestType 和 MyResponseType 是您的数据契约,您可以通过引用服务也引用的程序集(定义这些类型)来使用它们.

In the above example, IMyServiceContract is your service contract, and MyRequestType and MyResponseType are your data contracts, which you can use by referencing the assembly which the service also references (which defines these types).

这篇关于任何用于频道管理的 WCF 客户端代理生成器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆