After schemas have been published using Web Services Publishing wizard there’s a high chance we’d want to update and re-publish them later on. In the post about web services deployment automation I mention the way of scripting publishing process. Here is some more information on it.



Web Services Publishing wizard creates temp folder under the publishing target directory. There’s a file confusingly named WebServiceDescription.xml (does not have anything to do with WSDL). It contains complete information about web service publishing configuration. We can use this file to edit existing service definition. To load configuration into publishing wizard use this command:



  BTSWebSvcWiz.exe config=”<WebServiceDescriptionXmlPath>”



For example you’ve published schema to http://localhost/MyServices where MyService is pointed to local physical path: C:\inetpub\wwwroot\MyServices then WebServiceDescriptionXmlPath would be C:\Inetpub\wwwroot\MyServices \temp\WebServiceDescription.xml. The schema of this xml is straightforward so you can edit manually if you want.




This is all good when we iterate and interactively apply changes to the published schemas during development cycle. For unattended builds it’s better to use web services publishing API programmatically like this:




using Microsoft.BizTalk.WebServices;
using Microsoft.BizTalk.WebServices.Description;

public static void Publish(string path)
{
  WebServiceDescription desc
= WebServiceDescription.LoadXml(path);
  WebServiceBuilder builder
= new WebServiceBuilder();
  builder.WebServiceDescription
= desc;
  builder.ProgressCallback
+= new ProgressEventHandler(OnProgress);
  builder.BuildWebService();

  Trace.WriteLine(
Completed publishing web services);
}

private static void OnProgress(object sender, ProgressEventArgs e)
{
  Trace.WriteLine(String.Format(
OnProgress: {0} {1}, e.Value.ToString(), e.Message));
}


As you see we even get an event that can be used for monitoring progress steps.