WCF中配置文件部署服务
服务的三要素(ABC)
A:Address 意味着在哪里(也含有传输方式信息)
B:Binding 意味着怎么做(与地址的传输方式要匹配)
C:Contract意味着做什么(服务契约)
配置服务概述
<system.ServiceModel>
<services>
<service>
<endpoint/> /*服务和终结点*/
</service>
</services>
<bindings> /*绑定(可选)*/
<binding>
</binding>
</bindings>
<behaviors> /*行为(可选) */
<behavior>
</behavior>
</behaviors>
</system.ServiceModel>
其中绑定协议如下
Get256Bytes50000次 平均响应时间(单位:ms) 值小者为佳
配置代码
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="ClientForm.ClassThr" behaviorConfiguration="testbhavior">
<host>
<baseAddresses>
<add baseAddress="http://loclhost:8005/test/"/>
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding" contract="ClassLibrary2.Interfacethr">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="testbhavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
实例代码下载
WCF中 用配置文件部署wcf服务 下载