WCF服务库-从控制台应用程序拨打电话

WCF服务库-从控制台应用程序拨打电话,wcf,service,console,Wcf,Service,Console,我有一个带有netTcpBinding的WCF服务库。其app.config如下所示: <configuration> <system.serviceModel> <bindings> <netTcpBinding> <binding name="netTcp" maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000"> <readerQu

我有一个带有netTcpBinding的WCF服务库。其app.config如下所示:

<configuration>
<system.serviceModel>
<bindings>
  <netTcpBinding>
    <binding name="netTcp" maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000">
      <readerQuotas maxDepth="500" maxStringContentLength="50000000" maxArrayLength="50000000" maxBytesPerRead="50000000" maxNameTableCharCount="50000000" />
      <security mode="None"></security>
    </binding>
  </netTcpBinding>
</bindings>

<services>
  <service behaviorConfiguration="ReportingComponentLibrary.TemplateServiceBehavior"
    name="ReportingComponentLibrary.TemplateReportService">
    <endpoint address="TemplateService" binding="netTcpBinding" bindingConfiguration="netTcp"
      contract="ReportingComponentLibrary.ITemplateService"></endpoint>
    <endpoint address="ReportService" binding="netTcpBinding" bindingConfiguration="netTcp"
      contract="ReportingComponentLibrary.IReportService"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" ></endpoint>

    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:8001/TemplateReportService" />
        <add baseAddress ="http://localhost:8080/TemplateReportService" />
      </baseAddresses>
    </host>
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="ReportingComponentLibrary.TemplateServiceBehavior">
      <serviceMetadata httpGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="True" />
    </behavior>
  </serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>

我想从控制台应用程序调用它以进行测试。
我知道我可以通过添加服务引用或使用svcutil添加代理来调用。
但在这两种情况下,我的服务都需要启动并运行(我使用了WCF测试客户端)


是否有其他方法可以从控制台应用程序调用和测试服务方法?

出于测试目的,您可以使用它来托管WCF服务。要在其上调用方法,您不需要客户端,您可以使用

这些是我能想到的唯一方法。然而,我的web服务模块通常非常薄,只是对另一个.NET模块的简单方法调用。您可以从控制台应用程序中进行相同的调用,或者如果这暴露了太多,请创建另一个.NET DLL,以暴露控制台应用程序的相同调用。它不允许您测试“web服务”本身(用于承载等),但您仍将测试其功能。

感谢您的回复。我一直在使用WCF测试客户端,只是为了让我的服务启动并运行,所以上述两种方法可以工作。在某些地方,我也看到了使用ServiceHost的示例,但我不确定它在控制台应用程序中如何工作。请注意,我不能直接使用WCF测试客户端,因为它不接受配置设置,我需要在每次实例化时更改它们。所以我们在寻找其他的方式来主持。