Click here to Skip to main content
Email Password   helpLost your password?

Sample Image

Introduction

If any of you have written Web Services for the Windows SharePoint Services then you know how tedious (and actually boring and annoying) it is to generate the WSDL and disco files using the disco command and then make string replacements to produce new *wsdl.aspx and *disco.aspx files. Since the development is generally done not on the server where WSS (or SharePoint Portal Server) resides, it is even worse to upload the DLLs and definition files to the server and find out that you have made a syntactic error (there's no compiler to tell you that you are wrong, unfortunately). Then you have to do it all once again. Same thing happens when you add a method to the web service, you have to reflect the changes made in the asmx file to the disco and WSDL files, then generate *wsdl.aspx and *disco.aspx again and again.

Our team has written a very simple and very straightforward application that takes the URL of the web service as the argument and it produces those *wsdl.aspx and *disco.aspx files, making all necessary replacements for you. It's a very simple code, but it's very useful especially if you write or modify many web services for WSS.

Background

This article is for the developers who are developing custom web services for Windows SharePoint Services (equally SharePoint Portal Server).

Using the code

The WSSWebServicePackager.exe uses disco.exe (also provided here) to generate first the disco and WSDL files of the web service. Then the standard string replacements are made (described in MSDN documents) to make the file recognizable by WSS.

The code below starts disco.exe and generates the files. It generates the files into Temp directory. If the directory doesn't exist, it firstly creates it.

    //start disco utility to generate the wsdl and disco files

    ProcessStartInfo psi = new ProcessStartInfo();
    psi.WorkingDirectory = strPathToTempFolder;
    psi.FileName = Application.StartupPath + "\\disco.exe";
    psi.Arguments = txtURLAsmx.Text;
    Process p = Process.Start(psi);

    //wait for process to finish

    while (!p.HasExited) { }

Then the string replacements in both files are carried. The replacements are described in detail in the MSDN documentation (Writing Custom Web Services for SharePoint Products and Technologies).

The newly generated files are then copied to the folder chosen and are ready to be copied to the ISAPI directory (refer to the MSDN article above).

Hope it helps.

Points of Interest

Before we developed this small application, which actually does only the string replacements, it was a very annoying task to make those string replacements by hand after finishing writing the actual code. Now life is a little easier, hope it helps you all :)

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralUpdated Generator
Member 2865484
11:09 4 Sep '09  
This is a great little tool, I tweaked the code so it works with the latest version of MOSS, I would be happy to share if youre interested.
GeneralRe: Updated Generator
Ye Wint Aung
22:43 13 Sep '09  
Well if this the case, please do share with everyone.
Thanks.
GeneralRe: Updated Generator
Member 2865484
1:37 29 Sep '09  
Okay, please provide me instructions on how to upload the project.
GeneralNice share
guaneme
8:59 4 Dec '08  
Great job. Thanks for sharing this!

xxx

GeneralUpdated for WSSv3/MOSS
Paul Horsfall
0:41 21 Apr '07  
I did a quick update for the new versions of SharePoint, you can grab it here:

http://paulhorsfall.co.uk/archive/2007/04/20/SharePoint-Web-Service-DISCO-and-WSDL-Generator.aspx
GeneralRe: Updated for WSSv3/MOSS
RobinB
9:46 30 May '07  
Thanks for the update!
GeneralSharePoint Custom Web services VS 2005
braber
13:08 1 Nov '06  
Any insight on the creation of custom webservices within WSS using the .net 2.0 framework. The nice walk through and disco.aspx, wsdl.aspx creation doesnt seem to wrok with any 2.0 web services...

braber
QuestionDisco File Generation Error
Chuffy
6:57 9 Jan '06  
I have downloaded your app, but am having trouble generating the files. It creates the TEMP directory with no problems but doesn't see to generate a .disco file in here. It then errors when trying to read the file as it doesn't exist.

Any suggestions? I though it might be a security/permissioning thing but not sure.
GeneralIDisco file generator error
John Brancaleon
5:38 6 Jul '05  
I found an anomoly with your Service DISCO and WSDL Generator. I love the idea of not having to remember what I need to change to make the disco.aspx and wdsl.aspx files. I found that if you have a web service name something like 'XXX.YYY', disco.exe names the files XXX.disco and XXX.wsdl. To this end, I wrote a procedure that I added to your code to fix the file names if they differ from the Service Name:

private void FixFileNames(string strServiceName, string strPathToWorkDir)
{
string[] DiscoFiles = System.IO.Directory.GetFiles(strPathToWorkDir,"*.disco");
string[] WSDLFiles = System.IO.Directory.GetFiles(strPathToWorkDir,"*.wsdl");
if(System.IO.Path.GetFileNameWithoutExtension(DiscoFiles[0]).ToLower() != strServiceName.ToLower())
{
System.IO.FileInfo fi = new FileInfo(DiscoFiles[0]);
fi.CopyTo(strServiceName + ".disco",true);
fi.Delete();
}

if(System.IO.Path.GetFileNameWithoutExtension(WSDLFiles[0]).ToLower() != strServiceName.ToLower())
{
System.IO.FileInfo fi = new FileInfo(WSDLFiles[0]);
fi.CopyTo(strServiceName + ".wsdl",true);
fi.Delete();
}
}

I Added the call to this at this point in the btnGenerateAndUpload_Click:
// Code to fix the File names from disco.exe...
// by John Brancaleon
FixFileNames(strServiceName, strPathToTempFolder);

//disco file
StreamReader fileDiscoRead = File.OpenText(strServiceDiscoFileName);
string strDiscoContent = fileDiscoRead.ReadToEnd();
fileDiscoRead.Close();

GeneralRe: IDisco file generator error
rayback_2
7:15 19 Jul '05  
Thats a good point, never had such a situation though. Thanks for contribution John.

Sincerely
Ray


Last Updated 20 Jun 2005 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010