通过config为WCF服务指定运行时地址

时间:2015-02-06 22:23:29

标签: c# wcf app-config

我使用VS2010 C#创建了一个WCF库,从其他项目中引用它,在设计时间内正常工作。但是在运行时,据我所知,它使用不同的地址。那么,我该如何指定呢?

我的App.Config看起来像:

    

  <system.web>
    <compilation debug="true" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WcfService.Service1">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8732/Design_Time_Addresses/WcfService/MyWcf/" />
          </baseAddresses>
        </host>
        <endpoint address ="" binding="wsHttpBinding" contract="WcfService.IService1">
        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

0 个答案:

没有答案