Windows Communication Foundation 入门与实践
1. 生成客户端代理代码
在与远程 WCF 服务进行通信时,我们可以将相关文件包含到客户端项目中,并引用 System.ServiceModel.dll 程序集,然后使用代理类型进行通信。不过,这里我们介绍使用 Visual Studio 2010 来进一步自动化生成客户端代理文件的方法。
- 操作步骤 :
1. 对于客户端项目,从“项目”菜单中选择“添加服务引用”选项。
2. 激活该菜单选项后,会提示输入服务 URI,点击“转到”按钮查看服务描述。
以下是客户端配置示例:
<client>
<endpoint
address="http://localhost:8080/MagicEightBallService"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEightBall"
contract="IEightBall" name="BasicHttpBinding_IEightBall" />
</client>
完整的客户端代码如下:
// Location of the proxy.
using MagicEightBallServiceClient.ServiceRe
超级会员免费看
订阅专栏 解锁全文
16

被折叠的 条评论
为什么被折叠?



