<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Julien Blin &#187; Web Services</title>
	<atom:link href="http://blog.jblin.com/tag/web-services/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jblin.com</link>
	<description>acts_as_architect( :.net, :rails )</description>
	<lastBuildDate>Tue, 02 Mar 2010 20:00:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Create a .wsdl file from an asmx web service with NAnt</title>
		<link>http://blog.jblin.com/2009/11/create-a-wsdl-file-from-an-asmx-web-service-with-nant/</link>
		<comments>http://blog.jblin.com/2009/11/create-a-wsdl-file-from-an-asmx-web-service-with-nant/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 20:00:55 +0000</pubDate>
		<dc:creator>Julien Blin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[asmx]]></category>
		<category><![CDATA[Cassini]]></category>
		<category><![CDATA[nant]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://blog.jblin.com/?p=101</guid>
		<description><![CDATA[There are places where we are still stuck with .net framework 2.0 &#8211; so WCF is still not available. I&#8217;m currently working on such a project.
I&#8217;m using asmx web services, and i needed to be able to export the wsdl file generated by the framework, as part of an automated build.
It turns out that it seems [...]]]></description>
			<content:encoded><![CDATA[<p>There are places where we are still stuck with .net framework 2.0 &#8211; so WCF is still not available. I&#8217;m currently working on such a project.</p>
<p>I&#8217;m using asmx web services, and i needed to be able to export the wsdl file generated by the framework, as part of an automated build.<br />
It turns out that it seems there&#8217;s no way to generate a wsdl file from a web application directly without a web server.</p>
<p>So I decided to turn to <a href="http://nant.sourceforge.net/">NAnt</a> and Cassini (the web server integrated with visual studio) and came with the following target :</p>
<p><span id="more-101"></span></p>
<pre class="brush: xml;">
&lt;target name=&quot;generate-wsdl-files&quot;
        depends=&quot;build&quot;
        description=&quot;Regenerate wsdl files needed to access the web services&quot;&gt;
    &lt;property name=&quot;cassini.port&quot; value=&quot;1083&quot; /&gt;
    &lt;property name=&quot;webservices.url&quot; value=&quot;http://localhost:${cassini.port}&quot; /&gt;
    &lt;property name=&quot;wsdl.dir&quot; value=&quot;${project::get-base-directory()}\ExportWSDL&quot; /&gt;
    &lt;property name=&quot;project.web.path&quot; value=&quot;${project::get-base-directory()}\Sources\Web&quot; /&gt;

    &lt;exec program=&quot;${framework::get-tool-path('WebDev.WebServer.exe')}&quot;
          spawn=&quot;true&quot;
          pidproperty=&quot;cassini.pid&quot;&gt;
      &lt;arg value=&quot;/port:${cassini.port}&quot; /&gt;
      &lt;arg value=&quot;/path:&amp;quot;${project.web.path}&amp;quot;&quot; /&gt;
      &lt;arg value=&quot;/vpath:&amp;quot;/&amp;quot;&quot; /&gt;
    &lt;/exec&gt;

    &lt;sleep seconds=&quot;3&quot; /&gt;

    &lt;exec program=&quot;${framework::get-tool-path('disco.exe')}&quot; workingdir=&quot;${wsdl.dir}&quot;&gt;
      &lt;arg value=&quot;${webservices.url}/WebServices/AWebService.asmx&quot; /&gt;
      &lt;arg value=&quot;${webservices.url}/WebServices/AnotherWebService.asmx&quot; /&gt;
    &lt;/exec&gt;

    &lt;delete&gt;
      &lt;fileset basedir=&quot;${wsdl.dir}&quot;&gt;
        &lt;include name=&quot;*.disco&quot;/&gt;
        &lt;include name=&quot;*.discomap&quot;/&gt;
      &lt;/fileset&gt;
    &lt;/delete&gt;

    &lt;exec program=&quot;taskkill&quot;&gt;
      &lt;arg value=&quot;/PID&quot; /&gt;
      &lt;arg value=&quot;${cassini.pid}&quot; /&gt;
    &lt;/exec&gt;
  &lt;/target&gt;
</pre>
<p>What this target does is basically:</p>
<ul>
<li>set a bunch of properties: cassini port, export directory, the local path for the web project, etc.</li>
<li>line 9: start cassini (I believe you must have Visual Studio installed on the machine to do that), and very importantly <strong>spawns</strong> the process (meaning that NAnt will go on not waiting for the process to stop). The PID of the process is retained in a property (cassini.pid)</li>
<li>line 17: wait a couple of seconds for cassini to start and load the application (YMMV)</li>
<li>line 19: use the <a href="http://msdn.microsoft.com/en-us/library/cy2a3ybs(VS.80).aspx">disco.exe tool from the sdk</a> to produce a wsdl from a url &#8211; Note that you have to pass the list of all the asmx entries</li>
<li>line 24: delete the unnecessary .disco and .discomap files</li>
<li>line 31: kill the cassini process using <a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/taskkill.mspx?mfr=true">taskkill</a></li>
</ul>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jblin.com/2009/11/create-a-wsdl-file-from-an-asmx-web-service-with-nant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
