WCF服务"端点未找到",原因是什么?

时间:2016-04-01 14:54:25

标签: c# web-services wcf endpoint svc

我编写了WCF服务,以下是web.config文件。 当我打入网址时:

http://localhost:50705/EmpInfoService.svc/GetEmpSalary/B1234

它给了我一个错误:

  

服务

     

端点未找到

我找到两个可疑的地方......

它要求丢失端点配置。我有端点配置:

    <services>
      <service behaviorConfiguration="servicebehaviors" 
               name="EmployeeService.EmpInfoService">
        <endpoint address="" contract="EmployeeService.IEmpInfoService" 
              binding="webHttpBinding" behaviorConfiguration="web">

        </endpoint>
      </service>
    </services>
  • 其次,出于某种原因,我无法设置

    aspNetCompatibilityEnabled="false"至&#34; true&#34;

Youtube Tutorial for WCF service

中所示
  • 以下是我的web.config文件。你能看看并可能给我一些建议吗?谢谢!

&#13;
&#13;
<?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime targetFramework="4.0"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="servicebehaviors">
          <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
          <serviceMetadata httpGetEnabled="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>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    
    <services>
      <service behaviorConfiguration="servicebehaviors" name="EmployeeService.EmpInfoService">
        <endpoint address="" contract="EmployeeService.IEmpInfoService" 
                  binding="webHttpBinding" behaviorConfiguration="web">
        
        </endpoint>
      </service>
    </services>
    
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>
    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" 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>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

如果我理解正确,我相信您创建了一个在IIS中托管的WCF服务。因此,您不需要在配置文件中指定端点。尝试使用以下内容替换整个服务模型部分,并查看它的位置

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />