WCF services如何配置节

发布时间:2021-12-07 10:56:25 作者:小新
来源:亿速云 阅读:138

这篇文章将为大家详细讲解有关WCF services如何配置节,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

在WCF的快速发展,它的性能也随之增长,但是有很多人都对配置文件很头疼,现在就教教大家吧。在WCF services配置节中可以定义多个服务,每一个服务都被放到service配置节中,WCF的宿主程序可以通过配置文件找到这些定义的服务并发布这些服务。WCF services配置节包含name和behaviorConfiguration属性。其中,name配置了实现ServiceContract的类型名。类型名必须是完整地包含了命名空间和类型名。

而behaviorConfiguration的配置值则与其后的behaviors配置节的内容有关。endpoint是service配置节的主体,其中,endpoint配置节包含了endpoint的三个组成部分:Address、Binding和Contract。由于具体的binding配置是在bindings配置节中完成,因而,在endpoint中配置了bindingConfiguration属性,指向具体的binding配置。如下所示:

services  servicename="BruceZhang.MyService"behaviorConfiguration="MyBehavior"  endpointaddress="" binding="netTcpBinding" bindingConfiguration="DuplexBinding" contract="BruceZhang.IHello"/  /service  /services

我们也可以定义多个endpoint,例如:

services  service  name="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior" endpointaddress="" binding="wsHttpBinding" contract="Microsoft.ServiceModel.Samples.ICalculator"/  endpointaddress="mex" binding="mexHttpBinding" contract="Microsoft.ServiceModel.Samples.IMetadataExchange"/  /service  /services

如果address值为空,那么endpoint的地址就是默认的基地址(BaseAddress)。例如ICalculator服务的地址就是http://localhost/servicemodelsamples/service.svc,而IMetadataExchange服务的地址则为http://localhost/servicemodelsamples/service.svc/mex。这里所谓的基地址可以在WCF services配置节中通过配置host来定义:

service  name="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior" host  baseAddresses  addbaseAddress=  "http://localhost/ServiceModelSamples/service.svc"/  /baseAddresses  /host  endpoint…/  /service

关于“WCF services如何配置节”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

推荐阅读:
  1. 创建WCF服务
  2. WCF初次部署问题集锦

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

上一篇:大数据中Smartbi怎样解决垃圾短信带来的困扰

下一篇:Hyperledger fabric Chaincode开发的示例分析

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》