views:

223

answers:

2

Hello there,

I have a WCF Service Library with netTcpBinding. Its app.config as follows:

<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>

I want to call it from a console application for testing purpose.
I understand that I can call by adding Service Reference or by adding proxy using svcutil.
But in both these cases, my service needs to be up and running (I used WCF Test Client)

Is there any other way I can call and test service method from console application?

A: 

For testing purposes you could use WcfSvcHost.exe to host your WCF service. To invoke a method on it you don't need a client you could use WcfTestClient.exe

Darin Dimitrov
Thanks for your reply. I have been using WCF Test Client only to make my service up and running, so that above two methods can work. At some places, I have seen example of using ServiceHost as well, though me not sure how it will work in a console application.
inutan
just one more note that I can not use WCF Test Client directly as it doesn't take the configuration settings for <readerQuotas... /> and I need to change them on every instantiation. So was looking for some other way to host it.
inutan
A: 

Those are the only ways that I can think of. However, my web service modules are usually very thin, just a simple method call into another .NET module. You could make that same call from your Console app, or if that's exposing too much, create another .NET DLL that exposes the same call for the console app. It wouldn't let you test the "web service" per se (for load bearing, etc.), but you would still be testing the functionality.

Mike Hanson