自定义服务/端点地址

时间:2015-10-06 09:53:03

标签: .net wcf

我创建了IIS中托管的标准WCF服务应用程序。在web.config中输入以下代码:

<?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <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>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>

现在,我可以在http://localhost:3531/Service1.svc浏览服务,端点也具有相同的地址。我知道我的基地址现在是http://localhost:3531/Service1.svc,我可以设置端点的相对地址(例如&#34; MyEndpoint&#34; http://localhost:3531/Service1.svc/MyEndpoint)。

但我可以将服务地址更改为http://localhost:3531/MyService,将端点地址更改为http://localhost:3531/MyService/MyEndpoint吗?

1 个答案:

答案 0 :(得分:0)