Mandar's blog about .Net & PHP Web Development

  • Archive
  • RSS

Programmatically creating wcf client using Nant build script & svcutil

You have created a WCF service.To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:

svcutil.exe http://yourdomain/Service.svc?wsdl

This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service.

wcf windows communication platform

Sounds Familiar ?

Here is simple target from continueous integration NANT build Script which can be used to generate WCF Proxy class on-the-fly , so no more generating wcf proxy class by svcutil.exe

////////////////////////////////////////////

<target name=”build.webservice.proxy.csharp.file” description=”generates proxy class for webservice”>
<mkdir dir=”${build.dir}\wsfiles” /> —> generated files will be stored here
<exec program=”tools\svcutil\SvcUtil.exe” >
<arg value=”/d:${build.dir}/wsfiles” />
<arg value=”src/SAMPLE.dll” /> —> path to dll which conatins WCF service interface & implementation classes
</exec>
<exec program=”tools\svcutil\SvcUtil.exe” > —>path to svcutil.exe
<arg value=”/d:${build.dir}/wsfiles” />
<arg value=”${build.dir}/wsfiles/*.wsdl” />
<arg value=”${build.dir}/wsfiles/*.xsd” />
<arg value=”/l:c#” />
<arg value=”/out:SAMPLEPROXY.cs” /> —> desired name of the c# proxy class
<arg value=”/noconfig” />
<arg value=”/ser:auto” />
<arg value=”/tcv:version35” />
<arg value=”/n:*,Com.NAMESPACE1.NAMESPACE2” /> —> namespace
</exec>
</target>

/////////////////////////////////

    • #wcf wcf-proxy
  • 2 years ago
  • Permalink
  • Share
    Tweet
← Previous • Next →

Get 2GB Free Cloud storage

>> Download dropbox


About

I am programmer from London specializing in web based technologies, startups and web 2.0 related stuff.

My Startup

WealthBird

Available for Freelancing work

I am available for .NET contracting work in & around London. Drop me a mail : mandarp1979 at gmail.com

  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr