Useful WCF Tools

WCF
WCF @Image courtesy of ddpavumba/ FreeDigitalPhotos.net

Useful WCF Tools

Welcome to CodeSpread!

When we work with WCF, we mostly concentrate on the development aspect which involves create, deploy, and manage WCF applications. As a developer, I can suggest that If we utilize various tools available in WCF for debugging, tracing and testing purpose then we can have a smooth development ride with minimum glitches.

WCF Test Client or WcfTestClient.exe

As the name implies, it is a tool which behaves as test client to consume the WCF service. In detail, when we create a service, we can test it

  • Either by creating a client application which can call the service, pass some test parameters and sends that input to the service. In reply service sends back the response and we can view the response.
  • Or, we can save our effort by using ready to use, WCF Test Client.

How to use it?

To use it, create a new WCF service project and press F5, the WCF Service Host begins to host the service in the project.

Now, WCF Test Client opens and displays a list of service endpoints available. If required, we can pass the parameters and invoke the service. The behavior of Test client will be same as any other real-time client.

WCFTestClient

WCFTestClient

 

Ref: http://msdn.microsoft.com/en-us/library/bb552364.aspx

Features supported by WCF Test Client

The following is a list of features supported by WCF Test Client:

  • Service Invocation: Request/Response and One-way message.
  • Bindings: all bindings supported by Svcutil.exe.
  • Controlling Session.
  • Message Contract.
  • XML serialization.

Configuration Editor Tool (SvcConfigEditor.exe)

Once we have created our service then we would require configuration changes to put our service for client use. This includes tasks like exposing an endpoint, contracts etc. For example:


<xml version="1.0" encoding="utf-8" ?>

<configuration>

<system.web>

<compilation debug="true" />

</system.web>

<!-- When deploying the service library project, the content of the config file must be added to the host's -->

app.config file. System.Configuration does not support config files for libraries. -->

<system.serviceModel>

<services>

<service name="CalculatorService.Service1" behaviorConfiguration="CalculatorService.Service1Behavior">

<host>

<baseAddresses>

baseAddress = "http://localhost:8731/Design_Time_Addresses/CalculatorService/Service1/" />

</baseAddresses>

</host>

<!-- Service Endpoints -->

<!-- Unless fully qualified, address is relative to base address supplied above -->

<endpoint address ="" binding="wsHttpBinding" contract="CalculatorService.IService1">

<!--

Upon deployment, the following identity element should be removed or replaced to reflect the

identity under which the deployed service runs.&nbsp; If removed, WCF will infer an appropriate identity

automatically.

-->

<identity>

<dns value="localhost"/>

</identity>

</endpoint>

<!-- Metadata Endpoints -->

<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->

<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

</service>

</services>

<behaviors>

<serviceBehaviors>

<behavior name="CalculatorService.Service1Behavior">

<!-- To avoid disclosing metadata information,

set the value below to false and remove the metadata endpoint above before deployment -->

<serviceMetadata httpGetEnabled="True"/>

<!-- To receive exception details in faults for debugging purposes,

set the value below to true.&nbsp; Set to false before deployment

to avoid disclosing exception information -->

<serviceDebug includeExceptionDetailInFaults="False" />

</behavior>

</serviceBehaviors>

</behaviors>

</system.serviceModel>

</configuration>

 

Phew! Quite a heavy task, if we do it manually. But we can avail the benefits of the Service Configuration Editor (SvcConfigEditor.exe).It allows developers to modify configuration settings for WCF services using a graphical user interface. It can be found under Program File-> Microsoft Visual Studio Tools.

ConfigProg

ConfigProg

Same config file shown above can easily be generated by following the ‘New Config’ Wizard and providing the values.

WCFConfig

WCFConfig

 

Service Trace Viewer Tool (SvcTraceViewer.exe)

First of all, we should know a little bit about Tracing. Tracing involves diagnostic information and tracing messages which shows what is happening throughout our application’s operation.

It can be enabled by configuring tracing in the application’s configuration file.


<system.diagnostics>

<trace autoflush="true" />

<sources>

<source name="System.ServiceModel"

switchValue="Information, ActivityTracing"

propagateActivity="true">

<listeners>

<add name="test"

type="System.Diagnostics.XmlWriterTraceListener”/>

</listeners>

</source>

</sources>

</system.diagnostics>

 

The Service Trace Viewer supports three file types:

  • WCF Tracing File (.svcLog)
  • Event Tracing File (.etl)
  • Crimson Tracing File

Have a look at it, Go to File->Open and you can open any supported file listed above.

WCFTrace

WCFTrace

 

ServiceModel Metadata Utility Tool (Svcutil.exe)

This tool allows users to create service model code from metadata documents. Users can also create metadata documents from service model code. We can see few commands here.

Commands Description
svcutil http://service/metadataEndpoint Generates client code from a running service or online metadata documents.
svcutil *.wsdl *.xsd /language:c# Generates client code from local metadata documents.
svcutil /t:metadata http://service/metadataEndpoint Downloads metadata documents from running services.
svcutil myAssembly.dll Generates metadata documents for service contracts and associated types in an assembly.

There are few more WCF tools which are not used frequently.

  • Find Private Key Tool (FindPrivateKey.exe)
  • ServiceModel Registration Tool (ServiceModelReg.exe)
  • COM+ Service Model Configuration Tool (ComSvcConfig.exe)
  • WS-AtomicTransaction Configuration Utility (wsatConfig.exe)
  • WS-AtomicTransaction Configuration MMC Snap-in
  • WorkFlow Service Registration Tool (WFServicesReg.exe)
  • Contract-First Tool

Please refer http://msdn.microsoft.com/en-us/library/ms732015.aspx for more info on these tools

Author: jackie

I am a developer.

Share This Post On

0 Comments

  1. nice superb explaination

    Post a Reply
  2. thanks for the tutorial
    I am having a problem.
    The feature “Create SQL server database” isn’t available , I can’t select it.
    Can you help, please ?

    Post a Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

More from CodeSpread:

  • Split the Web.ConfigSplit the Web.ConfigWhen we work on web projects, we usually encounter with web.config files, not one but may be many at the same time. These web.config files are ASP.NET configuration files. They can be distributed t...
  • Few lines about WCF metadataFew lines about WCF metadataWhat is WCF metadata? WCF generates metadata for service endpoints and this metadata is used to describe how to interact with the service's endpoints. This information is used by Svcutil.exe to ge...
  • Agile Encounters UnpredictabilityAgile Encounters UnpredictabilityWhat is Agile? Wikipedia says “Agile software development is a group of software development methods based on iterative and incremental development, where requirements and solutions evolve through...
  • WCF Part 3: Direct from WCF kitchen.WCF Part 3: Direct from WCF kitchen.In the last two articles WCF:Part 1 and WCF Part 2, we have covered basic knowledge and terminologies of WCF.Now we will apply that knowledge to create a WCF service.There are lot of articles avail...
  • Few lines about Static code analysisFew lines about Static code analysisStatic code analysis We divide the term into two parts: Static+code analysis. Static in programming can be referred to as non-running/non-dynamic and code analysis is a process where the code is...
  • Decision Analysis and Resolution (DAR)Decision Analysis and Resolution (DAR)We divide the terms to understand them better. Decision Analysis is related to analyze possible decisions. So we need a process to perform decision analysis. Resolution is related to a propos...
  • WCF Part 2: Fundamentals.WCF Part 2: Fundamentals.We have seen the evolution of WCF in our previous article: WCF Part 1: Why WCF?. Next, we will go through the fundamentals of WCF. I will try to make it more worthy than an interview question puff....
  • POSTMan is required.POSTMan is required.Though it looks like a job posting but in developer’s world, it is a useful tool available as a chrome extension. When my friend referred it, I tried it and liked it so I recommend it every other d...