How to visit wcf service via endpoint address?

I created a wcf service by creating a wcf application project using VS2013. My service contract is IWCFService,and I have a implement of IWCFService called WCFService

 [ServiceContract]
    public interface IWCFService
    {
        [OperationContract]
        void DoWork();
    }

public class WCFService : IWCFService
    {


        public void DoWork()
        {

          //do something
        }
}

my service config is below:

<system.serviceModel>
    <services>
      <service name="WcfService2.WCFService">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration=""
          contract="WcfService2.IWCFService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:5831/WCFService" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

When i start my application i can add a service reference via url http://localhost:5831/WCFService.svc but when i try to add service reference via http://localhost:5831/WCFService noting was found.why the address i defined in web.config could not help?


<baseAddresses> will only work if your services are hosted in a self hosted environment.

Represents a collection of baseAddress elements, which are base addresses for a service host in a self-hosted environment. If a base address is present, endpoints can be configured with addresses relative to the base address.

链接地址: http://www.djcxy.com/p/95906.html

上一篇: 如何添加Workflow Control端点?

下一篇: 如何通过终端地址访问wcf服务?