How to generate WSDL files during build time?

  • Thread starter Prasanna Padmanabhan
  • Start date
P

Prasanna Padmanabhan

Hi,

We have a web serivce in our build system. There are 2 clients for the web
service. We would like to automatically genrate the wsdl file and the client
proxies during build time, so that, if the interfaces changed at any time,
we come to know about it during build time (build would break) rather than
during run time. I know how to generate the client proxy from the WSDL file
using WSDL.exe. But how do I generate the WSDL file itself during compile
time?

Please help.

Thanks,
Prasanna Padmanabhan
 
D

Dino Chiesa [Microsoft]

The only way to do this is to run the ASMX through ASP.NET.

There are 2 approaches. One is to actually deploy the ASMX file into a
running IIS with ASP.NET installed, then just httpget the URL for thew WSDL,
eg
http://yourserver/vroot/Service1.asmx?WSDL

To get the WSDL in a build, you can use any command-line httpgetter utility,
even something as simple as this javascript:

// getWSDL.js a simple command-line WSDL getter.
// Call it like this:
// cscript getwsdl.js <url>
//
// output goes to stdout.
//

var XMLDoc, XSLDoc ;
XMLDoc = WScript.CreateObject("MSXML2.DOMDocument") ;
XMLDoc.async= false;
XMLDoc.load(WScript.Arguments(0)); // exception here if the ASMX does not
compile successfully. The result is not XML, it is HTML !!
WScript.Echo(XMLDoc.xml);
WScript.Echo("");


Option 2 is to build a utility to host ASP.NET, and compile the ASMX, and
produce the WSDL. In this case you wouldn't need IIS, but you'd need to
build this util yourself. This is attractive, because you do not need to
deploy to IIS. However, the catch is that since you are not deploying to
your server, you have to be concerned about the availability of libraries
that may be referenced by the ASMX.

Search for articles on "hosting the ASP.NET runtime" to explore this.
eg,
http://www.neward.net/ted/Papers/HostingASPNET/HostingASPNET.html

Here is an simplistic example console utility that hosts the ASP.NET
runtime, compiles an ASMX and produces the WSDL on the console.
http://www.winisp.net/cheeso/srcview.aspx?file=asmx2wsdl.cs

Cassini is an example of a pre-built server that hosts ASP.NET (and source
code is available). Using a server might be more attractive because the
startup time of an ASP.NET host is significant. A server that runs
continuously only incurs this cost once (at startup). A command line util
that hosts ASP.NET must incur the cost with every invocation.

Using Cassini to produce WSDL from ASMX is very much like using IIS to do
the same, except, it is not the full IIS. This may be a good thing or a bad
thing depending on your requirements.

Find more about cassini on
http://www.asp.net/Projects/Cassini/Download/Default.aspx?tabindex=0&tabid=1

-Dino
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top