如何在客户端项目中添加服务引用? [英] How to add service reference in client project?

查看:31
本文介绍了如何在客户端项目中添加服务引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 WCF 完全陌生,所以如果您发现我在这里做的完全错误,请指出.我创建了一个 WCF 服务项目(我的服务类派生自 ServiceBase 类),端点地址绑定设置为 basicHttpBinding.现在我需要创建一个客户端应用程序,该应用程序可以从此服务调用一些 API.我的问题是,在我的客户端应用程序中,如何向该服务添加服务引用.我是否需要先在 IIS 下发布此服务(这意味着我也必须在机器上安装 IIS),或者是否还有其他添加服务引用的方法.

I am totally new to WCF so please indicate if you find something that I am doing totally wrong here. I have created a WCF service project (my service class is dervied from ServiceBase class) with endpoint address binding set to basicHttpBinding. Now I need to create a client application that can call some APIs from this service. My quesion is that in my client application how can I add service reference to that service. Do I need to publish this service first under IIS (which mean I have to have IIS available on the machine too) or is there some other way of adding service reference too.

推荐答案

您需要一些东西来运行服务,同时发布元数据.这可以是 IIS,也可以是任何其他有效的托管选项.

You need something to be running the service, with the metadata being published. This can be IIS, but also any other valid hosting option.

我经常编写一个简单的控制台应用程序来自托管 WCF 服务,正是出于这个原因.它使调试和在开发的早期阶段更新服务引用变得非常容易,并且可以显着简化同时在客户端和服务器上工作时的工作.

I often write a simple console application to self-host a WCF service, exactly for this reason. It makes it super easy to debug, as well as to update service references during the earlier phases of development, and can dramatically simplify work when working on the client and server simultaneously.

这篇关于如何在客户端项目中添加服务引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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