最近客户要求把服务器端程序里的二个功能用service的方式提供出来,方便调用。首先想着单独建一个wcf 服务的项目,但是因为要用到server端程序winform里的变量,因此只能在winform里添加一个wcf service的item。下面介绍详细的操作步骤:
1. winform里添加wcf service的item
添加之后,app.config里会自动加上wcf的配置项:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="OrayTalk.Server.Broadcast.BroadcastService">
<endpoint address="" binding="basicHttpBinding" contract="OrayTalk.Server.Broadcast.IBroadcastService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8111/BroadcastService" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>