views:

271

answers:

2

I was given a set of 170 WSDL files which I need to convert to C# class files. Is there any way to batch process this?

A: 

You can use svcutil.exe and write a batch script or (even better) PowerShell script to make code files out of your WSDL files.

Mark Seemann
+2  A: 

If you have all of them in a directory, you should probably run something like this:

$wsdls = gci | ? { $_.Name -like "*.wsdl" } | % { $_.Name }

Foreach ($wsdl in $wsdls) {
  & "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\svcutil.exe" '$wsdl' /n:*,Your.Desired.Net.Namespace /o:'$wsdl'.cs /noconfig
}

If there are on subdirectories, you can easilly make this recursive, and if you only have a list of addresses you can put them all in a .txt file, then go trough the content and call svcutil on each line.

The important part is probably how to manage the namespace of the generated code, and how to name all these files.

Philippe