最近客户要求把服务器端程序里的二个功能用service的方式提供出来,方便调用。首先想着单独建一个wcf 服务的项目,但是因为要用到server端程序winform里的变量,因此只能在winform里添加一个wcf service的item。下面介绍详细的操作步骤:

 

1. winform里添加wcf service的item

winform里宿主WCF,并传递winform变量给WCF

添加之后,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>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
  • 2022-02-25
  • 2022-02-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-14
  • 2021-10-05
  • 2022-12-23
  • 2021-08-08
  • 2022-12-23
相关资源
相似解决方案