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="Reporti开发者_StackOverflowngComponentLibrary.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?
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
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.
精彩评论