WCF services are pretty well just damn amazing in every way the only real area of pain can generating service contracts setting up a batch script will definitely relieve most of those pressures!
This example will have 2 service clients generated the first DataServiceClient is compromised of 2 data contract assemblies when you return objects that are defined in dlls absolutely make sure to include the dll as a datatcontract assembly otherwise you will have tons of headaches later. It also has the generic list class added in for the service to be able to return List<DataServices.DataContracts.SomeObject> make sure not to miss adding any generic classes provided by microsoft from your definitions!
The second client will be for WorkflowService which in this example is a basic service that only accepts basic type input parameters and return values.
@echo off
echo.
echo ==========================================================================
echo GenerateServiceClients.bat
echo Runs generation scripts for the Services.Host Project
echo ==========================================================================
echo.set configuration=Debug
set vsDir=”C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\”
set outputDir=”C:\Projects\My_Project\Service Clients\
set library=C:\Projects\My_Project\Library\
@set PATH=%PATH%;%vsDir%if /i “%1″==”/c” (
set configuration=%1
SHIFT
):run
@echo —————————————-
@echo GenerateServiceClients.bat Started
@echo —————————————-
@echo.@echo —————————————-
@echo Generating DataServiceClient
@echo —————————————-
@echo.set dataContractAssembly=”C:\Projects\My_Project\DataServices.Host\bin\DataServices.DataContracts.dll”
set dataContractAssembly1=”C:\Projects\My_Project\DataServices.Host\bin\Common.ExceptionHandling.dll”
set serviceUrl=”http://localhost/DataServices.Host/DataService.svc?wsdl”
set className=DataServiceClient.cs”
svcutil /noconfig /o:%outputDir%%className% /r:%dataContractAssembly% /r:%dataContractAssembly1% /ct:System.Collections.Generic.List`1 %serviceUrl%
@if errorlevel 1 goto :error@echo —————————————-
@echo Generating WorkflowServiceClient
@echo —————————————-
@echo.set serviceUrl=”http://localhost/WorkflowServices.Host/WorkflowService.svc?wsdl”
set className=WorkflowServiceClient.cs”
svcutil /noconfig /o:%outputDir%%className% %serviceUrl%
@if errorlevel 1 goto :error@echo —————————————-
@echo GenerateServiceClients.bat Completed
@echo —————————————-
@echo.@rem —————————————-
@rem Restore the command prompt and exit
@rem —————————————-
@goto :exit@rem ——————————————-
@rem Handle errors
@rem ——————————————-
:error
@echo An error occured in GenerateServiceClients.bat – %errorLevel%
@exit errorLevel:exit
@exit
echo on
BloggingContext.ApplicationInstance.CompleteRequest();