如何硬codeA默认WCF端点服务? [英] How to hard-code a default WCF endpoint for a service?

查看:157
本文介绍了如何硬codeA默认WCF端点服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在自托管服务,我想使用在App.config中指定的端点(S),如果present,或默认端点指定code如果App.config中是空的。我怎样才能做到这一点?

In a self-hosted service, I'd like to use the endpoint(s) specified in App.config, if present, or a default endpoint specified in code if App.config is empty. How can I do this?

修改:澄清一下,这是在服务器上(服务)一侧使用的ServiceHost

Edit: to clarify, this is on the server (service) side using ServiceHost.

推荐答案

您可以配置部分如下:

var clientSection =  System.Configuration.ConfigurationManager.GetSection("system.serviceModel/client");

如果值为null,或者 clientSection.Endpoints 包含零元素则没有定义。

If value is null or if clientSection.Endpoints contains zero elements then it is not defined.

这篇关于如何硬codeA默认WCF端点服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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