运行 时未命中 WCF Webserice

WCF Webserice not being hit when Run

我正在尝试使用 Visual Studio 2013 开发一个 wcf 服务 我已经为本地主机的客户端详细信息配置了 web.config,但它根本没有访问 Web 服务。当我点击 运行 时,它确实打开浏览器 http://localhost:4568/ 但它确实 运行 curoService 我的两个文件如下所示。

curoService.svc 其构造函数设置如下。

public class curoService : IcuroService

我的接口构造函数设置为

public 接口 IcuroService

任何人都可以告诉我我做错了什么没有错误消息出现它只是一个空白的浏览器window。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.6" />
    <httpRuntime targetFramework="4.6" />
  </system.web>
  <system.serviceModel>

    <services>
      <service name="Curo.curoService">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:4568/
                         Design_Time_Addresses/Curo/curoService/" />
          </baseAddresses>
        </host>
        <endpoint address ="" binding="wsHttpBinding"
             contract = "Curo.IcuroService">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding"
               contract = "IMetadataExchange"/>
      </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>
  <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>
  <connectionStrings>
    <add name="curoEntities" connectionString="metadata=res://*/CuroDB.csdl|res://*/CuroDB.ssdl|res://*/CuroDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=WIN-M71FFCH83PK\SQL14MOBILESERV;initial catalog=curo;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v12.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
</configuration>

您必须触发对您的服务的调用。在调试模式下点击 运行 只是附加到 .net web 开发服务器,因此是空白页面。您的浏览器是客户端。为了调试和单步执行,您必须触发服务器端方法。类似于:

http://localhost:4568/MyMethod?Param1='Test'

有许多有用的工具可以帮助您构建消息传递负载,请参阅 WCF Test Client, SoapUI, Fiddler and Wireshark 仅举几例。

所以您按 F12 启动并附加到 wcf 服务器端进程,设置断点,然后打开其中一个工具并定位您的开发端点。

注意 :还要确保您定义了完整的路径。右键单击解决方案中的 .svc 文件并 select 浏览。这将调出您可以用来测试的元数据页面。